It is currently April 27th, 2024, 1:44 am

Sending Bangs to Rainmeter with AutoIt

Tips and Tricks from the Rainmeter Community
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Sending Bangs to Rainmeter with AutoIt

Post by jsmorley »

If you ever do AutoIt "addons", and want to be able to send bangs from your application to Rainmeter, here is a function with a sample call to show you how to do it. This approach eliminates the need to either put the addon in \Addons\YourFolder\YourApp.exe in the Rainmeter home folder, or hard code the location of Rainmeter.exe. This will send the bang directly to the Rainmeter "window", bypassing any need to send the bang on a command line to Rainmeter.exe.

-> http://rainmeter.net/cms/Developers-API-WindowMessage
dragonmage
Developer
Posts: 1270
Joined: April 3rd, 2009, 4:31 am
Location: NC, US

Re: Sending Bangs to Rainmeter with AutoIt

Post by dragonmage »

Just curious. Getting the handle for RainmeterMeterWindow will only work if at least one skin is active correct?
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Sending Bangs to Rainmeter with AutoIt

Post by poiru »

dragonmage wrote:Just curious. Getting the handle for RainmeterMeterWindow will only work if at least one skin is active correct?
Yeah.

You can also use send the bangs to a window with class "DummyRainWClass" and name "Rainmeter control window" that always exists regardless of having skins active or not. However, the "RainmeterMeterWindow" window should be preferred in addons where it can be assumed that the executable was invoked through the skin.
User avatar
~Faradey~
Posts: 366
Joined: November 12th, 2009, 4:47 pm
Location: Ukraine

Re: Sending Bangs to Rainmeter with AutoIt

Post by ~Faradey~ »

jsmorley wrote:If you ever do AutoIt "addons", and want to be able to send bangs from your application to Rainmeter, here is a function with a sample call to show you how to do it. This approach eliminates the need to either put the addon in \Addons\YourFolder\YourApp.exe in the Rainmeter home folder, or hard code the location of Rainmeter.exe. This will send the bang directly to the Rainmeter "window", bypassing any need to send the bang on a command line to Rainmeter.exe.
i've always used such action through command line, but i think it would be better to use method what you suggested, or not?
what differences in functionality between these two methods, i mean which one is better for performance, stability and so on? i've noticed that when using command line a mouse cursor changes into a "loading" state in very short time and get back to normal, it is almost unseen, still, i can see it...but using your example nothing happens with cursor. It makes me think that using command line actions causes Rainmeter.exe to load every time i send a bang and after finishing it closes, and if these actions are more then one then cursor is changing...
For me is most important to know which method is best in all conditions?
and just a notice (not a bug, but may be it is):
When sending a bang through command line and there is a "[something]" (in square brackets) it causes Rainmeter to become unresponsive and i need to kill process manually :(
What about using through "window"?
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Sending Bangs to Rainmeter with AutoIt

Post by jsmorley »

The biggest advantage to using a window message over the command line is that you don't need to know where Rainmeter.exe is. I think functionally they are the same otherwise.

I had not ever noticed the cursor change to "working" before with the command line method, as you get a working / busy cursor when your addon application loads anyway, and I always just thought it was that. You may be right though. You certainly won't get a busy cursor from sending a window message to Rainmeter in memory.

Yeah, you need to be careful about "[something]" in either case, command line or not.
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Sending Bangs to Rainmeter with AutoIt

Post by poiru »

~Faradey~ wrote:what differences in functionality between these two methods, i mean which one is better for performance, stability and so on?
When you start execute a bang using the command line, you create a (temporary) Rainmeter.exe process, which then forwards the bang to the "real" Rainmeter.exe process. There is always a performance cost associated with creating processes, so you should use window messages whenever possible.
User avatar
~Faradey~
Posts: 366
Joined: November 12th, 2009, 4:47 pm
Location: Ukraine

Re: Sending Bangs to Rainmeter with AutoIt

Post by ~Faradey~ »

jsmorley wrote:The biggest advantage to using a window message over the command line is that you don't need to know where Rainmeter.exe is. I think functionally they are the same otherwise.

I had not ever noticed the cursor change to "working" before with the command line method, as you get a working / busy cursor when your addon application loads anyway, and I always just thought it was that. You may be right though. You certainly won't get a busy cursor from sending a window message to Rainmeter in memory.
Thank you for the answer and for sharing this method with us :great:
Yeah, you need to be careful about "[something]" in either case, command line or not.
ok) StringReplace is helping me in this :)
poiru wrote: When you start execute a bang using the command line, you create a (temporary) Rainmeter.exe process, which then forwards the bang to the "real" Rainmeter.exe process. There is always a performance cost associated with creating processes, so you should use window messages whenever possible.
aha! :)
Thanks a lot! this is what i was needed to make a choice :)
Now i'm going to edit all my addons. 8-)

Thank you guys!
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Sending Bangs to Rainmeter with AutoIt

Post by jsmorley »

There is no need to completely avoid sending "[SomeText]" in a bang, you just need to be sure Rainmeter treats it as a literal and doesn't try to evaluate it as a measure you want the value of. You can do that with the "magic quote" for measures... "[*SomeText*]"
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Sending Bangs to Rainmeter with AutoIt

Post by poiru »

Just to confirm, is "[something]" a measure or just text? Can you post a complete bang that causes a crash?
User avatar
~Faradey~
Posts: 366
Joined: November 12th, 2009, 4:47 pm
Location: Ukraine

Re: Sending Bangs to Rainmeter with AutoIt

Post by ~Faradey~ »

Recently i've made a radio (one of my addons) for future Kotoko Suite update, it almost done and in testing mode coz of strange crash, after investigating i found the reason why, it's because of square brackets ([])
The app runs with command line parameters in rainmeter.

Code: Select all

LeftMouseUpAction=!execute ["#PathToRadio#" "#CURRENTPATH#stations\Radio1.wpl" RadioTrack Text "#PROGRAMPATH#" "#CURRENTCONFIG#"]
In AutoIt:

Code: Select all

ShellExecute($CmdVar5, "!RainmeterSetOption " & $CmdVar2 & " " & $CmdVar3 & ' "' & $curName & '"' & ' "' & $CmdVar6 & '"')
where,
$CmdVar1 = $CmdLine[1] ;Radio link
$CmdVar2 = $CmdLine[2] ;Section Name [RadioTrack]
$CmdVar3 = $CmdLine[3] ;Option Name
$CmdVar4 = IniRead(@ScriptDir & "\..\RAD.inc", "Variables", "RadioVolume", "") ;Volume
$CmdVar5 = $CmdLine[4] & "\Rainmeter.exe"
$CmdVar6 = $CmdLine[5] ;Config Name

and
$curName = $owmp.currentMedia.name() ; name of current track
then i did a StringReplace to get rid of them, :) not quite actually, i replaced them to "-", and looks like now Rainmeter not crashing :)
....end of story :)