Commanding Rainmeter with AHK (and vice versa)
Re: Commanding Rainmeter with AHK (and vice versa)
Glad I could help!
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
- Yincognito
- Posts: 1
- Joined: 23 Nov 2023, 14:29
Re: Commanding Rainmeter with AHK (and vice versa)
I know it's a v1 section of the forum, but can someone convert the 2nd code from the initial post here to one that can be compiled with v2 (32bit mostly, though 64bit wouldn't hurt):
I tried to do it myself, but even after adapting some obvious parts like NumPut(), A_IsUnicode or SendMessage to v2, I'm still getting various errors and warnings...
Code: Select all
SendRainmeterCommand(command) {
Send_WM_COPYDATA(command, "DummyRainWClass")
}
Send_WM_COPYDATA(ByRef StringToSend, ByRef TargetWindowClass) ; ByRef saves a little memory in this case.
; This function sends the specified string to the specified window and returns the reply.
; Cribbed from https://www.autohotkey.com/docs/commands/OnMessage.htm
{
VarSetCapacity(CopyDataStruct, 3*A_PtrSize, 0) ; Set up the structure's memory area.
; First set the structure's cbData member to the size of the string, including its zero terminator:
SizeInBytes := (StrLen(StringToSend) + 1) * (A_IsUnicode ? 2 : 1)
NumPut(1, CopyDataStruct) ; Per example at https://docs.rainmeter.net/developers/
NumPut(SizeInBytes, CopyDataStruct, A_PtrSize) ; OS requires that this be done.
NumPut(&StringToSend, CopyDataStruct, 2*A_PtrSize) ; Set lpData to point to the string itself.
SendMessage, 0x4a, 0, &CopyDataStruct,, ahk_class %TargetWindowClass% ; 0x4a is WM_COPYDATA. Must use Send not Post.
return ErrorLevel ; Return SendMessage's reply back to our caller.
}
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: gongnl, jiming0516 and 82 guests