It is currently March 28th, 2024, 6:26 pm

Help With Layouts

Get help with creating, editing & fixing problems with skins
BillNoMind
Posts: 2
Joined: September 10th, 2020, 5:40 am

Help With Layouts

Post 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.
User avatar
CodeCode
Posts: 1363
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Help With Layouts

Post 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 *]
Last edited by CodeCode on September 10th, 2020, 6:31 am, edited 2 times in total.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Help With Layouts

Post 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.
BillNoMind
Posts: 2
Joined: September 10th, 2020, 5:40 am

Re: Help With Layouts

Post 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 *]
Last edited by balala on September 10th, 2020, 11:38 am, edited 1 time in total.
Reason: Please use <code> tags, not <Snippet>, whenever are posting code snippets. It's the </> button.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Help With Layouts

Post 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?
Last edited by mak_kawa on September 10th, 2020, 11:52 am, edited 3 times in total.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help With Layouts

Post 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).
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Help With Layouts

Post 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.
Last edited by mak_kawa on September 10th, 2020, 10:01 pm, edited 1 time in total.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help With Layouts

Post by jsmorley »

Nothing that comes after !LoadLayout is ever going to be executed.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help With Layouts

Post 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).
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Help With Layouts

Post by mak_kawa »

Ouch!!... :-)
Post Reply