It is currently March 5th, 2024, 4:30 am

I can't find out how to use !WriteKeyValue

General topics related to Rainmeter.
User avatar
Yincognito
Rainmeter Sage
Posts: 6858
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: I can't find out how to use !WriteKeyValue

Post by Yincognito »

DemonStudios1123 wrote: November 12th, 2023, 2:30 amPerhaps since im also tweaking the clock to position that, maybe i should just make a single file for all the variables doing this and reference both the clock file and mine for positioning? If thats possible.
Yincognito wrote: November 13th, 2023, 4:15 pmI'll post a code regarding this later on.
Here's everything in a single file:

Code: Select all

[Variables]
Color=255,255,255,255
Scale=0.5
ScaleStep=0.1
IconCount=4
IconGap=(110*[#*Scale*])
IconSize=(([&*Date:XW*]-[#*IconGap*]*([#*IconCount*]-1))/[#*IconCount*])
IconSeparatorW=([#*IconSize*]*0.08)
IconSeparatorH=([#*IconSize*]*0.75)
TextGap=(20*[#*Scale*])
TextW=([&*Date:XW*]/2-[#*IconSize*]-[#*TextGap*]-[#*IconGap*]/2)

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=0,0,0,1
MouseScrollUpAction=[!SetVariable Scale ([#Scale]+#ScaleStep#)][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable Scale ([#Scale]-#ScaleStep#)][!UpdateMeter *][!Redraw]

---Measures---

[MeasureHour]
Measure=Time
Format=%I

[MeasureMinute]
Measure=Time
Format=%M

[MeasureTime]
Measure=Time
Format=%I:%M%p

[MeasureDate]
Measure=Time
Format=%B %d,%Y
FormatLocale=Local

[MeasureWeekDay]
Measure=Time
Format=%A
FormatLocale=Local

---Meters---

[Shape]
Meter=Shape
X=(100*#Scale#)
Y=(100*#Scale#)
Shape = Ellipse 0,0,(90*#Scale#) | StrokeWidth (3*#Scale#) | StrokeColor #Color# | Fill Color 0,0,0,0
Shape2= Rectangle (-4*#Scale#+(45/2)*#Scale#*cos(PI/2-([MeasureHour]*60+[MeasureMinute])/720*2*PI)),((-45/2)*#Scale#-(45/2)*#Scale#*sin(PI/2-([MeasureHour]*60+[MeasureMinute])/720*2*PI)),(8*#Scale#),(45*#Scale#),(4*#Scale#) | Rotate (([MeasureHour]*60+[MeasureMinute])/720*360) | StrokeWidth 0 
Shape3= Rectangle (-4*#Scale#+35*#Scale#*cos(PI/2-[MeasureMinute]/60*2*PI)),(-35*#Scale#-35*#Scale#*sin(PI/2-[MeasureMinute]/60*2*PI)),(8*#Scale#),(70*#Scale#),(4*#Scale#) | Rotate ([MeasureMinute]/60*360) | StrokeWidth 0 
Shape4= Ellipse 0,0,(10*#Scale#) | StrokeWidth 0 | Fill Color #Color#
Shape5= Rectangle (150*#Scale#),(-90*#Scale#),(3*#Scale#),(180*#Scale#) | StrokeWidth 0 | Fill Color #Color#
DynamicVariables=1

[Time]
Meter=String
MeasureName=MeasureTime
FontColor=#Color#
FontFace=Futurist Fixed-width
FontSize=(31*#Scale#)
StringCase=Upper
AntiAlias=1
X=(300*#Scale#)
Y=(30*#Scale#)
DynamicVariables=1

[Date]
Meter=String
MeasureName=MeasureDate
FontColor=#Color#
FontFace=Futurist Fixed-width
FontSize=(20*#Scale#)
StringCase=Upper
AntiAlias=1
X=r
Y=(10*#Scale#)R
DynamicVariables=1

[WeekDay]
Meter=String
MeasureName=MeasureWeekDay
FontColor=#Color#
FontFace=Futurist Fixed-width
FontSize=(20*#Scale#)
StringCase=Upper
AntiAlias=1
X=r
Y=(10*#Scale#)R
DynamicVariables=1

[Separators]
Meter=Shape
X=(0)
Y=(100*#Scale#)R
Shape=Rectangle (#IconSize#*1+#IconGap#*0.5-#IconSeparatorW#/2),((#IconSize#-#IconSeparatorH#)/2),(#IconSeparatorW#),(#IconSeparatorH#) | StrokeWidth 0 | Stroke Color 0,0,0,0 | Fill Color 255,255,255,200
Shape2=Rectangle (#IconSize#*2+#IconGap#*1.5-#IconSeparatorW#/2),((#IconSize#-#IconSeparatorH#)/2),(#IconSeparatorW#),(#IconSeparatorH#) | StrokeWidth 0 | Stroke Color 0,0,0,0 | Fill Color 255,255,255,200
Shape3=Rectangle (#IconSize#*3+#IconGap#*2.5-#IconSeparatorW#/2),((#IconSize#-#IconSeparatorH#)/2),(#IconSeparatorW#),(#IconSeparatorH#) | StrokeWidth 0 | Stroke Color 0,0,0,0 | Fill Color 255,255,255,200
Shape4=Rectangle ([Date:XW]/2-#IconSeparatorW#/2),(#IconSize#+92*#Scale#),(#IconSeparatorW#),(#IconSize#*2+50*#Scale#*1) | StrokeWidth 0 | Stroke Color 0,0,0,0 | Fill Color 255,255,255,200
DynamicVariables=1

[AppIcon0]
Meter=Image
ImageName=#@#Images\vs_code_white.png
X=(0)r
Y=(0)r
W=(#IconSize#)
LeftMouseUpAction=["#@#Shortcuts\Code.exe - Shortcut"]
DynamicVariables=1

[AppIcon1]
Meter=Image
ImageName=#@#Images\intellij_white.png
X=(#IconGap#)R
Y=(0)r
W=(#IconSize#)
LeftMouseUpAction=["#@#Shortcuts\idea64.exe - Shortcut"]
DynamicVariables=1

[AppIcon2]
Meter=Image
ImageName=#@#Images\unity-white.png
X=(#IconGap#)R
Y=(0)r
W=(#IconSize#)
LeftMouseUpAction=["#@#Shortcuts\unity.exe - Shortcut"]
DynamicVariables=1

[AppIcon3]
Meter=Image
ImageName=#@#Images\blender_outline.png
X=(#IconGap#)R
Y=(0)r
W=(#IconSize#)
LeftMouseUpAction=["C:\Users\USR\Desktop\programming"]
DynamicVariables=1

[FolderIcon0]
Meter=Image
ImageName=#@#Images\folder_white.png
X=(0)
Y=(92*#Scale#)R
W=(#IconSize#)
LeftMouseUpAction=["C:\Users\USR\Desktop\programming"]
DynamicVariables=1

[FolderText0]
Meter=String
Text=PROJECTs
FontColor=#Color#
FontFace=Futurist Fixed-width
FontSize=(18*#Scale#)
AntiAlias=1
StringAlign=LeftBottom
ClipString=2
X=(#TextGap#)R
Y=(0)R
W=(#TextW#)
DynamicVariables=1

[FolderIcon1]
Meter=Image
ImageName=#@#Images\folder_white.png
X=([Date:XW]/2+#IconGap#/2)
Y=(-#IconSize#)r
W=(#IconSize#)
LeftMouseUpAction=["C:\Users\USR\Desktop\programming"]
DynamicVariables=1

[FolderText1]
Meter=String
Text=NOTEs
FontColor=#Color#
FontFace=Futurist Fixed-width
FontSize=(18*#Scale#)
AntiAlias=1
StringAlign=LeftBottom
ClipString=2
X=(#TextGap#)R
Y=(0)R
W=(#TextW#)
DynamicVariables=1

[FolderIcon2]
Meter=Image
ImageName=#@#Images\folder_white.png
X=(0)
Y=(50*#Scale#)r
W=(#IconSize#)
LeftMouseUpAction=["C:\Users\USR\Desktop\programming"]
DynamicVariables=1

[FolderText2]
Meter=String
Text=GAME DEV
FontColor=#Color#
FontFace=Futurist Fixed-width
FontSize=(18*#Scale#)
AntiAlias=1
StringAlign=LeftBottom
ClipString=2
X=(#TextGap#)R
Y=(0)R
W=(#TextW#)
DynamicVariables=1

[FolderIcon3]
Meter=Image
ImageName=#@#Images\folder_white.png
X=([Date:XW]/2+#IconGap#/2)
Y=(-#IconSize#)r
W=(#IconSize#)
LeftMouseUpAction=["C:\Users\USR\Desktop\programming"]
DynamicVariables=1

[FolderText3]
Meter=String
Text=PDFs
FontColor=#Color#
FontFace=Futurist Fixed-width
FontSize=(18*#Scale#)
AntiAlias=1
StringAlign=LeftBottom
ClipString=2
X=(#TextGap#)R
Y=(0)R
W=(#TextW#)
DynamicVariables=1
Changes:
- I implemented changing the scale when scrolling, in the [Rainmeter] section (so I added dynamic variable lines to all meters)
- I used the nested variable syntax (so that the defined variables change automatically when changing the variables they are based on) and escaped variables (so that variables are defined as literal strings instead of actual values in order to facilitate their automatic adjustment) in the [Variables] and the [Rainmeter] sections, making referencing various values easier in the code and shortening the formulas by avoiding repetition
- I simplified the separators, using the rightmost meter's (Date) rightmost point (:XW) as the clock's total width and dividing it into IconCount icons and IconCount-1 gaps for the rest of the code; as a result, the icon size is automatically determined by the total width, the extent of an icon gap and the number of icons, making adding another icon a matter of duplicating the last one with a different name, inserting the corresponding separator's rectangle shape and incrementing the icon count in [Variables]
- I used relative positioning for app icons, folder icons and folder texts, to simplify arranging them one after (and based on) the other, with the folder texts being placed at a distance of text gap from folder icons; similarly, adding another row of folders is a matter of duplicating the last row with different names for the meters and incrementing the 2 and 1 factors in the formula for the last separator's rectangle height

Result, using my suite's renamed icons for testing:
Clock & Launcher.jpg
Notice how folder texts are clipped and wrapped when they don't fit their reserved space (also computed automatically). Increasing the value of the icon gap variable from [Variables] to make icons a bit smaller will create additional space for the folder texts.

This is meant as a demonstration code, feel free to adjust it, use it or not use it, ask what you don't understand, and so on.
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth