It is currently April 23rd, 2024, 8:21 pm

Sending Bangs to Rainmeter with AutoIt

Tips and Tricks from the Rainmeter Community
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Sending Bangs to Rainmeter with AutoIt

Post by poiru »

Which of those parameters/variables contained the square brackets?
User avatar
~Faradey~
Posts: 366
Joined: November 12th, 2009, 4:47 pm
Location: Ukraine

Re: Sending Bangs to Rainmeter with AutoIt

Post by ~Faradey~ »

poiru wrote:Which of those parameters/variables contained the square brackets?
ShellExecute($CmdVar5, "!RainmeterSetOption " & $CmdVar2 & " " & $CmdVar3 & ' "' & $curName & '"' & ' "' & $CmdVar6 & '"')

$curName means name of track, so it can be so:
Every Little Thing - キヲク [iTunes Originals Version]

Just try it for yourself using command line (or link)
"C:\Program Files\Rainmeter\Rainmeter.exe" !RainmeterSetOption NameOfSelection NameOfOption "Every Little Thing - キヲク [iTunes Originals Version]" "Config"
result=crash/freeze

and then for testing
"C:\Program Files\Rainmeter\Rainmeter.exe" !RainmeterSetOption NameOfSelection NameOfOption "Every Little Thing - キヲク ~iTunes Originals Version~" "Config"
result=option changed ;)
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Sending Bangs to Rainmeter with AutoIt

Post by poiru »

~Faradey~ wrote:...
Thanks, I'll fix this for the next beta :)
User avatar
~Faradey~
Posts: 366
Joined: November 12th, 2009, 4:47 pm
Location: Ukraine

Re: Sending Bangs to Rainmeter with AutoIt

Post by ~Faradey~ »

Looks like this approach can't be used with other than latin characters, as i noticed, too bad(
but maybe it's possible to make a encoding/decoding somewhere, i still don't get it, where it's converts...or may by this is in AutoIt script?

This part of string "Фарадей" converts to "Ôàðàäåé"
and, Rainmeter can't find the image

Code: Select all

Image: Unable to open: C:\Users\Ôàðàäåé\Documents\Rainmeter\Skins...
Any ideas?
Fixed an infinite loop / hang when Rainmeter.exe is called with a bang containing square brackets (e.g. Rainmeter.exe !Bang "[Text]")
Tested! Confirmed! :thumbup:
User avatar
santa_ryan
Posts: 397
Joined: June 22nd, 2010, 4:11 am

Re: Sending Bangs to Rainmeter with AutoIt

Post by santa_ryan »

Well, first...
Unicode includes few precomposed accented Cyrillic letters, the others can be combined by adding U+0301 ("combining acute accent") after the accented vowel.

But that's just a bit of added information for future reference.

Now, real problem...
For troubleshooting purposes to test your script try dumping your output to a file instead of handing it off to rainmeter. If you're script successfully dumps the output to file then the problem is not with the script grabbing the data.

This is a troubleshooting dump function that I created and use.

Code: Select all

;~ _TroubleshootingDump( _
;~ Info to dump - Default = Line number of the currently executed script line, _
;~ Dump Filename - Default = "Troubleshooting.txt", _
;~ Directory to create file - Default = Working Directory, _
;~ File Open Mode - Default = 42 (http://www.autoitscript.com/autoit3/docs/functions/FileOpen.htm), _
;~ Add date and time to the dump, Default = True _
;~ ) 

Func _TroubleshootingDump($aDumpText = @ScriptLineNumber, $aDumpFilename = "TextDump.txt", $WorkingDirectory = @WorkingDir, $DumpOptions = "42", $aAddTimeDate = True)
	Local $aDumpFileHandle
	$aDumpFileHandle = FileOpen($aDumpFilename, $DumpFormat)
	If $aAddTimeDate Then 
		Local $aTimeDateInfo = "| " & @Hour & ":" & @MIN & ":" & @SEC & " - " & @MON & "/" & @MDAY & "/" & @YEAR & " |"
		FileWrite($aDumpFileHandle, "Start & $aTimeDateInfo & @LF & @LF)
	EndIf
	FileWrite($aDumpFileHandle, $aDumpText)
	If $aAddTimeDate Then FileWrite($aDumpFileHandle, "End " & $aTimeDateInfo & @LF & @LF & "---------------------------------------------------" & @LF & @LF & @LF)
	FileClose($aDumpFileHandle)
EndFunc
If it does in fact dump successfully, then there is either a problem with the sendmessage command or with rainmeter. Make sure the sendmessage is done in UTF-16 Little Endian. If it is then the problem is most likely with rainmeter itself.
Last edited by santa_ryan on December 29th, 2011, 4:38 pm, edited 4 times in total.
I have three rules when I'm trying to help you.
  • Don't get mad when you don't understand something
  • Be VERY specific with what you ask for.
    The more specific you are, the higher the quality of support you receive.
  • Do not just copy and paste what I put in examples and come back saying it doesn't work.
    It does work, but I purposely left blanks that you need to fill for your specific needs.
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Sending Bangs to Rainmeter with AutoIt

Post by poiru »

~Faradey~ wrote:Looks like this approach can't be used with other than latin characters, as i noticed, too bad(
but maybe it's possible to make a encoding/decoding somewhere, i still don't get it, where it's converts...or may by this is in AutoIt script?

This part of string "Фарадей" converts to "Ôàðàäåé"
and, Rainmeter can't find the image

Code: Select all

Image: Unable to open: C:\Users\Ôàðàäåé\Documents\Rainmeter\Skins...
Any ideas?
You need to use SendMessageW (AFAIK, _SendMessage uses SendMessageW internally) and make sure the data is UTF-16LE. I have barely used AutoIT, so I don't know how to do this in it. Googling might yield an answer.

EDIT: Check next post.
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Fix for Unicode support

Post by poiru »

~Faradey~ wrote:Looks like this approach can't be used with other than latin characters, as i noticed, too bad(
but maybe it's possible to make a encoding/decoding somewhere, i still don't get it, where it's converts...or may by this is in AutoIt script?
santa_ryan wrote:If it does in fact dump successfully, then there is either a problem with the sendmessage command or with rainmeter. Make sure the sendmessage is done in UTF-16 Little Endian. If it is then the problem is most likely with rainmeter itself.
Here is a fixed version of SendBang that properly supports Unicode:

Code: Select all

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <SendMessage.au3>

Opt("WinTitleMatchMode", 4)

; Example:
SendBang("!About")

Func SendBang($szBang)
	Local Const $hWnd = WinGetHandle("classname=RainmeterMeterWindow")
	If $hWnd <> 0 Then
		Local Const $iSize = StringLen($szBang) + 1

		Local Const $pMem = DllStructCreate("wchar[" & $iSize & "]")
		DllStructSetData($pMem, 1, $szBang)

		Local Const $pCds = DllStructCreate("dword;dword;ptr")
		DllStructSetData($pCds, 1, 1)
		DllStructSetData($pCds, 2, ($iSize * 2))
		DllStructSetData($pCds, 3, DllStructGetPtr($pMem))

		Local Const $WM_COPYDATA = 0x004A
		_SendMessage($hWnd, $WM_COPYDATA, 0, DllStructGetPtr($pCds))
	EndIf
EndFunc
User avatar
~Faradey~
Posts: 366
Joined: November 12th, 2009, 4:47 pm
Location: Ukraine

Re: Fix for Unicode support

Post by ~Faradey~ »

poiru wrote: Here is a fixed version of SendBang that properly supports Unicode:

Code: Select all

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <SendMessage.au3>

Opt("WinTitleMatchMode", 4)

; Example:
SendBang("!About")

Func SendBang($szBang)
	Local Const $hWnd = WinGetHandle("classname=RainmeterMeterWindow")
	If $hWnd <> 0 Then
		Local Const $iSize = StringLen($szBang) + 1

		Local Const $pMem = DllStructCreate("wchar[" & $iSize & "]")
		DllStructSetData($pMem, 1, $szBang)

		Local Const $pCds = DllStructCreate("dword;dword;ptr")
		DllStructSetData($pCds, 1, 1)
		DllStructSetData($pCds, 2, ($iSize * 2))
		DllStructSetData($pCds, 3, DllStructGetPtr($pMem))

		Local Const $WM_COPYDATA = 0x004A
		_SendMessage($hWnd, $WM_COPYDATA, 0, DllStructGetPtr($pCds))
	EndIf
EndFunc
It WORKS!!!
Yahoo)))
Thank you!!!
partially i solved this issue myself a bit erlier but it was ugly way and not tested completely, so i didn't post it and now i'm definitely can say that i will use this approach, thanx
And one more thing, your help, from all of you guys, made it possible to release Kotoko Suite today) :bow: :bow: :bow:
User avatar
~Faradey~
Posts: 366
Joined: November 12th, 2009, 4:47 pm
Location: Ukraine

Re: Sending Bangs to Rainmeter with AutoIt

Post by ~Faradey~ »

Hi Guys)
Is there any Rainmeter WindowMessage or DllCall to get to know if skin is active (loaded) or not? I remember, it was a list of all Rainmeter WindowsMessages in manual, but now it's gone, or i can't just find it :confused:
I don't think that rainmeter reads Rainmeter.ini file every time it needs to check skin's state.
Or would it be hard to implant OnExitAction thing in rainmeter?
Pls) Tnx in advance :bow:
poiru
Developer
Posts: 2872
Joined: April 17th, 2009, 12:18 pm

Re: Sending Bangs to Rainmeter with AutoIt

Post by poiru »

~Faradey~ wrote:Is there any Rainmeter WindowMessage or DllCall to get to know if skin is active (loaded) or not? I remember, it was a list of all Rainmeter WindowsMessages in manual, but now it's gone, or i can't just find it :confused:
They are indeed gone temporarily. I just now added what you want here (note: I haven't tested the GetSkinWindow AutoIT function).