It is currently April 27th, 2024, 5:46 am

I can't find out how to use !WriteKeyValue

General topics related to Rainmeter.
DemonStudios1123
Posts: 2
Joined: November 11th, 2023, 3:34 pm

I can't find out how to use !WriteKeyValue

Post by DemonStudios1123 »

This is wild, i searched up and down this forum and cant find a simple use of the magical `!WriteKeyValue`
The docs:https://docs.rainmeter.net/manual/variables/#Changing and https://docs.rainmeter.net/manual/bangs/#WriteKeyValue

They dont show a working example and i have no idea how to use this.
Just trying to make a single variable the past hour XD

Code: Select all

[Rainmeter]
Update=3000
AccurateText=1
DynamicWindowSize=1

[Variables]
;myVarX=50
[!WriteKeyValue Variables myVarX 500]
myVarX=[!WriteKeyValue Variables myVarX 500]
; @IncludeVariables=Box.inc

[Test]
Meter=Shape
; [!WriteKeyValue Test myVarX 500]
; Shape=Rectangle #myVarX#, #myVarX#, 200, 200 | FillColor 255,255,255 | StrokeWidth 0
Shape=Rectangle #myVarX#,0,200,200 | FillColor 255,255,255 | StrokeWidth 0
Im VERY desperate XD
I wanted to know if i could take the height variable of a clock skin i have and just give that to the skin im making so i can update the skin im making more frequently than the clock, since i move my skin based on the height of the clock.

include and writekeyvalue could do this right?
I think i need my skin pretty fast as i want to add hover effects on icons.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5407
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

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

Post by eclectic-tech »

DemonStudios1123 wrote: November 11th, 2023, 3:47 pm This is wild, i searched up and down this forum and cant find a simple use of the magical `!WriteKeyValue`
The docs:https://docs.rainmeter.net/manual/variables/#Changing and https://docs.rainmeter.net/manual/bangs/#WriteKeyValue

They dont show a working example and i have no idea how to use this.
Just trying to make a single variable the past hour XD

Code: Select all

[Rainmeter]
Update=3000
AccurateText=1
DynamicWindowSize=1

[Variables]
;myVarX=50
[!WriteKeyValue Variables myVarX 500]
myVarX=[!WriteKeyValue Variables myVarX 500]
; @IncludeVariables=Box.inc

[Test]
Meter=Shape
; [!WriteKeyValue Test myVarX 500]
; Shape=Rectangle #myVarX#, #myVarX#, 200, 200 | FillColor 255,255,255 | StrokeWidth 0
Shape=Rectangle #myVarX#,0,200,200 | FillColor 255,255,255 | StrokeWidth 0
Im VERY desperate XD
I wanted to know if i could take the height variable of a clock skin i have and just give that to the skin im making so i can update the skin im making more frequently than the clock, since i move my skin based on the height of the clock.

include and writekeyvalue could do this right?
I think i need my skin pretty fast as i want to add hover effects on icons.
The !WriteKeyValue only works when used in an Action Bang: OnUpdateAction=, OnChangeAction=, LeftMouseUpAction=, etc.
LeftMouseUpAction=[!WriteKeyValue Variables "myVarX" "500"] to write it in the [Variables] section of the current skin or
OnRefreshAction=[!WriteKeyValue Variables "myVarX" "500" "#@#variables.inc"] to write it to [Variables] section of an external '@Resources\variables.inc' file.

Note in order to see the change the skins must be refreshed.

To use the written variable immediately use both !WriteKeyValue bang to permanently change the value, and a !SetVariable bang to update it in the current skin. Meters using this value have to have DynamicVariables=1 in them.
LeftMouseUpAction=[!WriteKeyValue Variables "myVarX" "500"][!SetVariable "myVarX" "500"]

Hope this helps your understanding...
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
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 11th, 2023, 3:47 pm This is wild, i searched up and down this forum and cant find a simple use of the magical `!WriteKeyValue`
The docs:https://docs.rainmeter.net/manual/variables/#Changing and https://docs.rainmeter.net/manual/bangs/#WriteKeyValue

They dont show a working example and i have no idea how to use this.
Just trying to make a single variable the past hour XD

Code: Select all

[Rainmeter]
Update=3000
AccurateText=1
DynamicWindowSize=1

[Variables]
;myVarX=50
[!WriteKeyValue Variables myVarX 500]
myVarX=[!WriteKeyValue Variables myVarX 500]
; @IncludeVariables=Box.inc

[Test]
Meter=Shape
; [!WriteKeyValue Test myVarX 500]
; Shape=Rectangle #myVarX#, #myVarX#, 200, 200 | FillColor 255,255,255 | StrokeWidth 0
Shape=Rectangle #myVarX#,0,200,200 | FillColor 255,255,255 | StrokeWidth 0
Im VERY desperate XD
I wanted to know if i could take the height variable of a clock skin i have and just give that to the skin im making so i can update the skin im making more frequently than the clock, since i move my skin based on the height of the clock.

include and writekeyvalue could do this right?
I think i need my skin pretty fast as i want to add hover effects on icons.
Well, eclectic-tech already answered this, but just for the record, what you're looking for is here in the manual:
https://docs.rainmeter.net/manual/skins/option-types/#Action
Basically, that !WriteKeyValue can't be executed out of nowhere, some kind of "action" should trigger that. These actions are options that typically end up in "Action", as explained there and by eclectic-tech above, and which one you attach !WriteKeyValue to depends on WHEN you want to execute such bangs (on a click of mouse, on updating something, and so on). By the way, such bangs cannot be placed within the [Variables] section, unless you define a variable that stores some chain of bangs for easier use in other sections.

Other than that, I don't fully understand what you need to do, despite the relatively reasonable description. I have the feeling that your goal might be achievable in another fashion, perhaps even easier. Can you offer some additional details, maybe a screenshot or something? What I suspect you want to do is position a skin based on the position / height of another skin, is that it? Plus, I don't understand why you need such bangs or variables since you could simply use the height value from your clock skin in the other skin you're making, if that value is static (aka doesn't change). Also, where exactly you want to use that value in the skin you're making? :???:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16174
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

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

Post by balala »

In addition to eclectic-tech's and Yincognito's replies, I'd add one more: the [!WriteKeyValue Variables myVarX 500] bang, as has been placed into the [Variables] section, does nothing and can't be used, however the myVarX=[!WriteKeyValue Variables myVarX 500] is a perfectly valid variable and can be used accordingly. For instance instead of eclectic-tech proposed LeftMouseUpAction=[!WriteKeyValue Variables myVarX "500"] option, you could use the option this way: LeftMouseUpAction=#myVarX#, because as said above, the myVarX variable has set to the bang which has to be executed.
Yincognito wrote: November 11th, 2023, 4:31 pm Other than that, I don't fully understand what you need to do, despite the relatively reasonable description.
Same here...
DemonStudios1123
Posts: 2
Joined: November 11th, 2023, 3:34 pm

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

Post by DemonStudios1123 »

Yincognito wrote: November 11th, 2023, 4:31 pm Other than that, I don't fully understand what you need to do, despite the relatively reasonable description. I have the feeling that your goal might be achievable in another fashion, perhaps even easier. Can you offer some additional details, maybe a screenshot or something? What I suspect you want to do is position a skin based on the position / height of another skin, is that it?
Well im sort of new to rainmeter, and i been trying to align things as perfectly as i can along with being changable:
Image(https://imgur.com/a/6iqKT5F)

The code is HUGE, im sorry, its all brute force XD (as i said, new to this)
https://drive.google.com/file/d/13mmgCq1Dm-6O6GvTCEoIljhyInJx3BPN/view?usp=sharing

I'm using a clock skin from someone else which i removed from my script, ill exlain why(other than not wanting to post his code as if its "my creaction")
I liked the clock used, However, to move it around i use variables of the clock, to shift it to the right side of the screen and shift my menus down.
If you notice the script, it uses a LOT of variables, they all work together to position things, but as well as scale, such as icons.

I feel its "clean" this way, tho all in one file.....maybe not so much?

Also, the reason i want to get the height of the screen(to shift everything down the same way with variables) is to make it cleaner.
To keep the clock's skin in it's own skin, rn the entirity of it is all in the same file, and i want hover effects on my icons and i feel like it would be nice to not wildly update the clock every some ms, and the icons much more frequently.

So the goal is to keep clock in it's own place, and just somehow take the height of it and give it to my skin to shift the icons down.
Perhaps 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.

The clock used: https://github.com/khanhas/mnmlUI/tree/master/Clock%20Future%20Style
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
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 am Well im sort of new to rainmeter, and i been trying to align things as perfectly as i can along with being changable:
Image(https://imgur.com/a/6iqKT5F)

The code is HUGE, im sorry, its all brute force XD (as i said, new to this)
https://drive.google.com/file/d/13mmgCq1Dm-6O6GvTCEoIljhyInJx3BPN/view?usp=sharing

I'm using a clock skin from someone else which i removed from my script, ill exlain why(other than not wanting to post his code as if its "my creaction")
I liked the clock used, However, to move it around i use variables of the clock, to shift it to the right side of the screen and shift my menus down.
If you notice the script, it uses a LOT of variables, they all work together to position things, but as well as scale, such as icons.

I feel its "clean" this way, tho all in one file.....maybe not so much?

Also, the reason i want to get the height of the screen(to shift everything down the same way with variables) is to make it cleaner.
To keep the clock's skin in it's own skin, rn the entirity of it is all in the same file, and i want hover effects on my icons and i feel like it would be nice to not wildly update the clock every some ms, and the icons much more frequently.

So the goal is to keep clock in it's own place, and just somehow take the height of it and give it to my skin to shift the icons down.
Perhaps 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.

The clock used: https://github.com/khanhas/mnmlUI/tree/master/Clock%20Future%20Style
Thanks for the details, they help in understanding what you meant. I believe you're overcomplicating things here though.

If the clock and the rest of the things you want aligned to it are in the same skin / code, then using the relative r or R positioning (or section variable positional parameters :X, :Y, :W, :H based on the clock's Shape meter coordinates, like you already do but in a needlessly complicated way) would be much easier:
https://docs.rainmeter.net/manual/meters/general-options/#XY
https://docs.rainmeter.net/manual/variables/section-variables/
Also, using the width and height of the screen is not needed at all, there are bangs like !SetWindowPosition that can be executed in an OnRefreshAction from the [Rainmeter] section and place your skin where you want it, e.g. to the right of the screen:
https://docs.rainmeter.net/manual/bangs/#Skin

If you still want to keep the clock and the other code in different skins, then you'll need to pass whatever value you want from your clock skin as a variable in the other skin, by using your other skin as the optional Config parameter of the !SetVariable bang, then similarly !UpdateMeter and !Redraw stuff in the other skin using the same parameter:
https://docs.rainmeter.net/manual/bangs/#SetVariable
https://docs.rainmeter.net/manual/skins/#Config

So, it basically depends on whether you merge those codes or not. Once you decided on that, some basic sample code on how things would look like based on the above could be provided.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16174
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

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

Post by balala »

DemonStudios1123 wrote: November 12th, 2023, 2:30 am The code is HUGE, im sorry, its all brute force XD (as i said, new to this)
https://drive.google.com/file/d/13mmgCq1Dm-6O6GvTCEoIljhyInJx3BPN/view?usp=sharing
Unfortunately the code is unusable, unless I'm missing something, because:
  • It uses lot of resources, which we don't have (me at least definitely don't have them). In order to can see what is going on, those are absolutely needed.
  • You (or the author) are using lot of section variables referring to non-existing sections. For instance in the ShapeX options of the [ICONS] meter, you're
    using the [Shape:H] section variable. Unfortunately a [Shape] meter doesn't even exist. Accordingly, using the mentioned section variable leads to lot of error messages in the log.
  • Even if this is not something which could prevent the skin working, using an Update option set to Update=3000 for a clock skin is weird, or at least is definitely not too common.
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

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

Post by Yincognito »

balala wrote: November 12th, 2023, 7:49 pm Unfortunately the code is unusable, unless I'm missing something, because:
  • It uses lot of resources, which we don't have (me at least definitely don't have them). In order to can see what is going on, those are absolutely needed.
  • You (or the author) are using lot of section variables referring to non-existing sections. For instance in the ShapeX options of the [ICONS] meter, you're
    using the [Shape:H] section variable. Unfortunately a [Shape] meter doesn't even exist. Accordingly, using the mentioned section variable leads to lot of error messages in the log.
  • Even if this is not something which could prevent the skin working, using an Update option set to Update=3000 for a clock skin is weird, or at least is definitely not too common.
The [Shape] meter does exist, but it's in the original clock code from the last link posted by the OP. He excluded the latter from the GoogleDrive link to avoid looking like he's plagiarizing the original skin - the explanation is even written in the comments, as well as his reply. That's probably why he decided to create his own skin (or using another separate code from another skin) and position it based on the original clock skin instead of just editing the clock skin in the first place.

He's clearly confused about positioning the meters from his GoogleDrive code (in terms of skin coordinates) in relation to how the original clock skin is positioned (but in screen coordinates!), which is why he needlessly uses the built in monitor variables to try and replicate the latter in the former. His original clock skin is positioned in the top right corner of his screen, hence his formulas for the X and Y from his meters trying to place them below the clock but still on the right side of his screen.

His mistake is thinking of coordinates in the skin as equivalent to skin coordinates on the screen. The original clock skin is already positioned in the top right corner of his screen, so he could just edit that skin, use either relative R positioning or positional section variable parameters as a base for his other meters' positioning, and get rid of the pointless #SCREENAREAWIDTH# and similar altogether.

Or, if he still wants to have two skins, i.e. the original clock skin and his other code, he'd need to pass the size / coordinate values as variables from the former to the latter, by using the Config parameter in the !SetVariable, !UpdateMeter and !Redraw bangs, as already explained above.

Hopefully this clears up things a bit. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16174
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

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

Post by balala »

Yincognito wrote: November 12th, 2023, 10:11 pm Hopefully this clears up things a bit. ;-)
Yep, it does. Now makes sense a little bit more. And as far as I can tell, you did offer a solution, right? You'll have to wait the OP to come back and tell if he succeeded in implementing your recommendations.
But this is another story...
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

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

Post by Yincognito »

balala wrote: November 13th, 2023, 1:08 pm Yep, it does. Now makes sense a little bit more. And as far as I can tell, you did offer a solution, right? You'll have to wait the OP to come back and tell if he succeeded in implementing your recommendations.
But this is another story...
Yeah, I did, at least the theoretical part. I'll post a code regarding this later on.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth