Page 1 of 2

Help With Layouts

Posted: September 10th, 2020, 5:45 am
by BillNoMind
I want to be able to change my skin Layout with a keyboard shortcut. Is this possible?
I switch between two resolutions (from 4k to 1080p) with a keyboard shortcut using a utility called HRC. When I do this my layout becomes a mangled mess. To fix this I made a layout for both resolutions I would like to be able to switch between them with a keyboard shortcut just like I do with my resolutions.

Re: Help With Layouts

Posted: September 10th, 2020, 6:27 am
by CodeCode
You can do it, but another external program dll is needed utilising rainmeter. It is called HotKey.

You can also do it with rainmeter with a mouse click using the bang !LoadLayout.

https://docs.rainmeter.net/manual/bangs/#LoadLayout

Code: Select all

[MeterClicky]
Meter=Image
X=0
Y=0
W=40
H=40
SolidColor=100,100,100,100
LeftMouseUpAction=[!LoadLayout "My Saved Layout"][!Refesh *]

Re: Help With Layouts

Posted: September 10th, 2020, 6:30 am
by mak_kawa
Hi BillNoMind

I didn't try actually, but I think it is possible using Hotkey plugin and of course !LoadLayout bang as CodeCode said.

Re: Help With Layouts

Posted: September 10th, 2020, 7:19 am
by BillNoMind
mak_kawa wrote: September 10th, 2020, 6:30 am Hi BillNoMind

I didn't try actually, but I think it is possible using Hotkey plugin and of course !LoadLayout bang as CodeCode said.
What would the code look like if I wanted to use Ctrl + 1 for layout 1 and Ctrl + 2 for layout 2 as the keyboard shortcut (using the code that "CodeCode" posted

Edit I figured it out

Code: Select all

[Rainmeter]
Update=1000

[Meter4k]
Meter=image
X=0
Y=0
W=40
H=40
SolidColor=100,100,100,100
LeftMouseUpAction=[!LoadLayout "4k Final"][!Refesh *]

[Meter2k]
Meter=image
X=42
Y=0
W=40
H=40
SolidColor=100,100,100,100
LeftMouseUpAction=[!LoadLayout "2k Final"][!Refesh *]

[4k]
Measure=Plugin
Plugin=HotKey
HotKey=Ctrl 1
KeyDownAction=[!LoadLayout "4k Final"][!Redraw *]

[2k]
Measure=Plugin
Plugin=HotKey
HotKey=Ctrl 2
KeyDownAction=[!LoadLayout "2k Final"][!Redraw *]

Re: Help With Layouts

Posted: September 10th, 2020, 9:00 am
by mak_kawa
Hi BillNoMind

First to say, I have not changed my monitor resolution, so followings is just an idea, not real test result. Please do trial-and-error by yourself, sorry.

When you changed monitor resolution, width and height of the monitor work area are changed, of course. Rainmeter can get these parameters as system variables #WORKAREAWIDTH# and #WORKAREAHEIGHT#.
So, probably you can switch action for single hot key according with whether current monitor is set to 2K or 4K, like as;

Code: Select all

[HotKeyMeasure]
Measure=Plugin
Plugin=HotKey
HotKey=Ctrl 1
KeyDownAction=[!EnableMeasure 2K4KDetect]

[2K4KDetect]
Measure=Calc
Formula=#WORKAREAWIDTH#
IfCondition=(2K4KDetect > 2000)
IfTrueAction=[!LoadLayout "4k Final"][!Redraw][!DisableMeasure 2K4KDetect]
IfFalseAction=[!LoadLayout "2k Final"][!Redraw][!DisableMeasure 2K4KDetect]
DynamicVariables=1
Disabled=1
** EDIT: sorry, IfCondition expression was reversed... IfCondition=(2K4KDetect > 2000), instead of IfCondition=(2K4KDetect < 2000).

1. Assumed #WORKAREAWIDTH# in 4K monitor is larger than 2000 pixels, right?
2. Possibly, [!UpdateMeasure 2K4KDetect] is needed after [!EnableMeasure 2K4KDetect]...?

As already said, I am not sure this idea in fact works well or not... hope this doesn't break your system. :-)

Ps. Idea background: if you press hotkey (or click button) for 4K layout when current monitor is 2K, wouldn't it cause a mess?

Re: Help With Layouts

Posted: September 10th, 2020, 11:42 am
by balala
CodeCode wrote: September 10th, 2020, 6:27 am

Code: Select all

[MeterClicky]
Meter=Image
X=0
Y=0
W=40
H=40
SolidColor=100,100,100,100
LeftMouseUpAction=[!LoadLayout "My Saved Layout"][!Refesh *]
If you're loading a layout all skins belongign to that layout are reloaded and all skin not belonging to it, are unloaded. Anyway all skins are reloaded, so there is no need to refresh anything (so the [!Refesh *] bang is useless).

Re: Help With Layouts

Posted: September 10th, 2020, 12:06 pm
by mak_kawa
Hi BillNoMind

Further idea... Maybe, hotkey action in Rainmeter is not necessary? That is, watching #WORKAREAWIDTH#, and when it was changed, automatically !LoadLayout. How about this?

Code: Select all

[2K4KWatch]
Measure=Calc
Formula=#WORKAREAWIDTH#
OnChangeAction=[!EnableMeasure 2K4KSwitch]
DynamicVariables=1

[2K4KSwitch]
Measure=Calc
Formula=1
IfCondition=([2K4KWatch] > 2000)
IfTrueAction=[!LoadLayout "4k Final"][!Redraw][!DisableMeasure 2K4KSwitch]
IfFalseAction=[!LoadLayout "2k Final"][!Redraw][!DisableMeasure 2K4KSwitch]
DynamicVariables=1
Disabled=1
Will this work?? I am not sure, but seems to be worth trying...

Edit: Caution! This code is dangerous, may cause infinite loop of !LoadLayout. Don't try it. Sorry.

Re: Help With Layouts

Posted: September 10th, 2020, 12:12 pm
by jsmorley
Nothing that comes after !LoadLayout is ever going to be executed.

Re: Help With Layouts

Posted: September 10th, 2020, 12:14 pm
by balala
mak_kawa wrote: September 10th, 2020, 12:06 pm Further idea... Maybe, hotkey action in Rainmeter is not necessary? That is, watching #WORKAREAWIDTH#, and when it was changed, automatically !LoadLayout. How about this?
Not sure the [2K4KWatch] measure is needed. I think you could replace the Formula option of the [2K4KSwitch] measure with Formula=#WORKAREAWIDTH# and could remove the Disabled=1 option of the [2K4KSwitch] measure, to get directly executed the appropriate !LoadLAyout bang. No need to disable the measure, so the [!Redraw][!DisableMeasure 2K4KSwitch] options are also not needed, I'd remove them as well (see jsmorley's reply above).

Re: Help With Layouts

Posted: September 10th, 2020, 12:18 pm
by mak_kawa
Ouch!!... :-)