It is currently April 28th, 2024, 1:03 am

Rainmeter Command Line - Calling a Mouse Click

Get help with installing and using Rainmeter.
marstriple
Posts: 3
Joined: June 17th, 2023, 7:57 am

Rainmeter Command Line - Calling a Mouse Click

Post by marstriple »

Hi Guys,

Just wondering if anyone could please assist if they know the answer. I've been researching it everywhere and cannot seem to find a resolution.

I have pasted the ini file.

I have a rainmeter that sits at the bottom corner of my screen and toggles different sound devices (its either my monitor audio or my speakers when clicked). It also turns them on and off on a click, changes the sleep settings and turns Bluetooth on and off. Feel free to customize it if its of use to you. It powers the speakers on and off by calling a curl command to my TPlink Power Swich.

I was looking at toggleing the meter either [1] or [2] from the command line and its not executing the execute command as part of the meter when its called...

C:\Program Files\Rainmeter>Rainmeter.exe !ToggleMeter 2 "SoundDevice"

Code: Select all

[2]
meter=image
imagename=speakers.png
x=20
y=8
leftmouseupaction=!execute [!CommandMeasure "MeasureWin7Audio" "SetOutPutIndex #speakers_Phillips#"][!hidemeter 2][!showmeter 1]
Ideally, I would like to be able to click/toggle the speakers (including the action involved which executes the code to change the speakers, its currently changing the speaker image but not the actual audio output), any assistance would be appreciated :)

Thank you,
Mario
You do not have the required permissions to view the files attached to this post.
Last edited by balala on June 17th, 2023, 12:09 pm, edited 1 time in total.
Reason: Please use <code> tags whenever are you posting codes. It's the </> button.
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Rainmeter Command Line - Calling a Mouse Click

Post by Yincognito »

marstriple wrote: June 17th, 2023, 8:13 amI was looking at toggleing the meter either [1] or [2] from the command line and its not executing the execute command as part of the meter when its called...

C:\Program Files\Rainmeter>Rainmeter.exe !ToggleMeter 2 "SoundDevice"

[2]
meter=image
imagename=speakers.png
x=20
y=8
leftmouseupaction=!execute [!CommandMeasure "MeasureWin7Audio" "SetOutPutIndex #speakers_Phillips#"][!hidemeter 2][!showmeter 1]
A couple of things:
- the !Execute bang is deprecated, you can safely remove those parts from your skins
- your command does exactly what you told it to, aka toggling (hide/show) the "2" meter; this is not a measure that you can "execute" by updating
- even if updating the "2" meter, the bangs in the mouse actions will not run since they're triggered only by that specific mouse action (i.e. click)
- to do what you want, you have to use the same bangs from your mouse action at the command line, something like this:

Code: Select all

"C:\Program Files\Rainmeter\Rainmeter.exe" [!CommandMeasure "MeasureWin7Audio" "SetOutPutIndex <YourPhillipsSpeakerIndex>" "SoundDevice"][!HideMeter "2" "SoundDevice"][!ShowMeter "2" "SoundDevice"][!Redraw "SoundDevice"]
where <YourPhillipsSpeakerIndex> is what you defined it to be, aka 5, as per your .ini code, and redrawing is optionally needed to display the results right away, without waiting for the skin update to do it.

As far as I can tell, Rainmeter does not parse variables to their value when run from the command line, so using the #speakers_Phillips# variable at the command line will probably be ineffective (but you can try, if you want).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
marstriple
Posts: 3
Joined: June 17th, 2023, 7:57 am

Re: Rainmeter Command Line - Calling a Mouse Click

Post by marstriple »

Thank you for taking the time to reply.

Your guidance is helpful. (Although still have not yet achieved the final result)

I will keep toying with it and post the end result here in case anyone wishes to use it. Pretty handy having code that changes the audio output of speakers and flicks them on and off (then being able to call this with a custom keyboard key ie. the cmd call)
marstriple
Posts: 3
Joined: June 17th, 2023, 7:57 am

Re: Rainmeter Command Line - Calling a Mouse Click

Post by marstriple »

So I went with you suggestions cleaned up and modified the code a little.

If you have your audio speakers hooked up to a smartswitch such as the HS100 (TP-Link), you can run curl commands to switch them on and off. The curl commands need to be pasted into this code.

It will also turn the speakers on and off, alternate between Audio Output devices on your PC, open the sound panel for diagnosis, and can set the display to go to sleep within a few minutes as specified.

Its a pretty cool little utility if you have studio monitors and would like to flick them on at the click of a button whilst also changing the audio output device :)

Now running the code will handle this, say if I would like to attach a keyboard key to it I can also do all of this at the click of a button.

rainmeter.exe [!SetOption ToggleSpeakers Formula (1-[ToggleSpeakers])][!WriteKeyValue ToggleSpeakers Formula (1-[ToggleSpeakers])][!UpdateMeasure ToggleSpeakers][!UpdateMeasure TogglePower][!Redraw]

If anyone finds this useful or makes any cool adjustments - please feel free to share them with everyone.
You do not have the required permissions to view the files attached to this post.
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Rainmeter Command Line - Calling a Mouse Click

Post by Yincognito »

Glad you found a solution - nice work! :thumbup:
I don't have your type of devices so I can test, but the approach will certainly be useful to anyone reading this and having a similar setup. Thanks for sharing!
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth