It is currently March 29th, 2024, 7:09 am
Get help with installing and using Rainmeter.
red0fireus
Posts: 5 Joined: December 23rd, 2017, 5:04 pm
Post
by red0fireus » August 5th, 2020, 1:55 am
Hello, this is my second post and I need some support with Bangs and Autoit.
I found this post from 2011 on the rainmeter forum:
https://forum.rainmeter.net/viewtopic.php?f=119&t=9652&sid=1972000a769381f344cf19561dfb534f
I'm having issues with sending bangs through CMD/ShellExecute
I currently have a post on AutoIt but it seems like no one is willing to offer a hand
Post:
https://www.autoitscript.com/forum/topic/203535-running-a-exe-with-variables-rainmeter/
I'm looking to send bangs that execute with a variable attached.
Code: Select all
Global $CmdVar2 = 'Minimalist Weather Standalone\'
Global $CmdVar3 = "Minimalist Weather.ini"
ShellExecute("C:\Program Files\Rainmeter\Rainmeter.exe", "'!DeactivateConfig '" & $CmdVar2 & $CmdVar3)
I have tried multiple ways of doing this and I can't seem to find the correct way. If anyone knows I would really appreciate it.
Thank you!
Last edited by red0fireus on August 5th, 2020, 2:31 am, edited 1 time in total.
jsmorley
Developer
Posts: 22628 Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA
Post
by jsmorley » August 5th, 2020, 2:02 am
Try this:
Code: Select all
; Usage: SendBang("[!About]")
#include <SendMessage.au3>
Func SendBang($szBang)
Local Const $hWnd = WinGetHandle("[CLASS:DummyRainWClass]")
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
That is really preferable, since in theory you can't "know" where Rainmeter.exe is installed on any given user's computer.
Also,
!DeactivateConfig does not support a file name as a parameter. Only send it a config name.
To do it with ShellExecute, I would use this:
ShellExecute("C:\Program Files\Rainmeter\Rainmeter.exe", '!DeactivateConfig ' & '"' & $CmdVar2 & '"')
The goal is:
"C:\Program Files\Rainmeter\Rainmeter.exe" !DeactivateConfig "ConfigName"
red0fireus
Posts: 5 Joined: December 23rd, 2017, 5:04 pm
Post
by red0fireus » August 5th, 2020, 2:16 am
Alright so I'm checking the log file and it's showing this !DeactivateConfig: "'Minimalist" not active. It's not picking up anything past the space.
Quotes usually fixes this kind of issue but I tried them and I there's probably some special spot for them?
Code: Select all
SendBang("[!DeactivateConfig 'Minimalist Weather.ini']")
Func SendBang($szBang)
Local Const $hWnd = WinGetHandle("[CLASS:DummyRainWClass]")
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
jsmorley
Developer
Posts: 22628 Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA
Post
by jsmorley » August 5th, 2020, 2:17 am
red0fireus wrote: ↑ August 5th, 2020, 2:16 am
Alright so I'm checking the log file and it's showing this !DeactivateConfig: "'Minimalist" not active. It's not picking up anything past the space.
Quotes usually fixes this kind of issue but I tried them and I there's probably some special spot for them?
Code: Select all
SendBang("[!DeactivateConfig 'Minimalist Weather.ini']")
Func SendBang($szBang)
Local Const $hWnd = WinGetHandle("[CLASS:DummyRainWClass]")
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
You don't use file names with !DeactivateConfig. You use config names.
red0fireus
Posts: 5 Joined: December 23rd, 2017, 5:04 pm
Post
by red0fireus » August 5th, 2020, 2:18 am
Nvm I got it!
Thank you so much!!!
jsmorley
Developer
Posts: 22628 Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA
Post
by jsmorley » August 5th, 2020, 2:19 am
jsmorley
Developer
Posts: 22628 Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA
Post
by jsmorley » August 5th, 2020, 2:20 am
Great. Glad to help.