It is currently May 19th, 2024, 5:38 pm
Receiving Window Messages
-
- Posts: 104
- Joined: June 7th, 2021, 11:46 am
Receiving Window Messages
Hello there. From what I understand, The WindowMessage plugin only sends window messages, and listens to the reply. Is there a way to make the skin window receive specific window messages with an id? Or is there a plugin for this task?
-
- Posts: 104
- Joined: June 7th, 2021, 11:46 am
Re: Receiving Window Messages
Does anyone have any ideas about this?
-
- Developer
- Posts: 2695
- Joined: November 24th, 2011, 1:42 am
- Location: Utah
Re: Receiving Window Messages
Not with this plugin, but then again, a Windows message might not be the best way to send information to a Rainmeter skin.
It might help if you could describe what you are trying to do, because it sounds as if you are trying to send a specific skin some information from another application (or script). If that is the case, it would probably be best to just send a bang to the main Rainmeter application (utilizing the config parameter of the bang to make sure it gets to the right skin).
https://docs.rainmeter.net/manual/bangs/
Example: "C:\Program Files\Rainmeter\Rainmeter.exe" !SetOption SomeStringMeter Text "SomeValue" "MySuite\MySkin"
Another option is using the Rainmeter API from an external application, but this is mainly for getting Rainmeter path information, or a skins window handle. We have some information here to get you started, but obviously implementing this from whatever external application you are using is going be difficult to provide support for, at least on our end.
https://docs.rainmeter.net/developers/#SendMessage
Some of the query id's are located here: https://github.com/rainmeter/rainmeter/blob/master/Library/RainmeterQuery.h
-Brian
-
- Posts: 104
- Joined: June 7th, 2021, 11:46 am
Re: Receiving Window Messages
I am trying to send a window message to rainmeter from an ahk script for this project. Currently, it works by the method you mentioned (sending a bang to the application), but it causes a loading icon to appear next to the most cursor (since it is starting a new instance of the program). I am able to send window messages to the skin window with ahk with ease, but there are no ways to interpret them in Rainmeter.Brian wrote: ↑June 18th, 2022, 6:01 am It might help if you could describe what you are trying to do, because it sounds as if you are trying to send a specific skin some information from another application (or script). If that is the case, it would probably be best to just send a bang to the main Rainmeter application (utilizing the config parameter of the bang to make sure it gets to the right skin).
-
- Posts: 12
- Joined: February 2nd, 2019, 2:10 pm
Re: Receiving Window Messages
It might be too late, but...
Code: Select all
Bang(str) {
d := Buffer(24, 0)
l := (StrLen(str) + 1) * 2
NumPut("UPtr", 1, d)
NumPut("UPtr", l, d, 8)
NumPut("UPtr", StrPtr(str), d, 16)
dhw := A_DetectHiddenWindows
DetectHiddenWindows 1
SendMessage(0x4a, 0, d.Ptr,, WinExist("ahk_class DummyRainWClass"))
DetectHiddenWindows dhw
}
-
- Rainmeter Sage
- Posts: 7287
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Receiving Window Messages
Is this tested? And if so, is it for AHK v.1, or for AHK v.2 (as the NumPut() syntax imples)? If the latter, then it's definitely not too late, at least for me. I've been successfully using this for AHK v.1:Smurth wrote: ↑May 4th, 2024, 4:24 pm It might be too late, but...Code: Select all
Bang(str) { d := Buffer(24, 0) l := (StrLen(str) + 1) * 2 NumPut("UPtr", 1, d) NumPut("UPtr", l, d, 8) NumPut("UPtr", StrPtr(str), d, 16) dhw := A_DetectHiddenWindows DetectHiddenWindows 1 SendMessage(0x4a, 0, d.Ptr,, WinExist("ahk_class DummyRainWClass")) DetectHiddenWindows dhw }
Code: Select all
SendBang(ByRef Bang)
{
cWnd := "RainmeterMeterWindow"
iLen := (StrLen(Bang) + 1) * (A_IsUnicode ? 2 : 1)
VarSetCapacity(pCds, 3 * A_PtrSize, 0)
NumPut(1, pCds)
NumPut(iLen, pCds, A_PtrSize)
NumPut(&Bang, pCds, 2 * A_PtrSize)
SendMessage, 0x004A, 0, &pCds,, ahk_class %cWnd%
return ErrorLevel
}
One other thing, I suppose your:
Code: Select all
dhw := A_DetectHiddenWindows
DetectHiddenWindows 1
DetectHiddenWindows dhw
-
- Posts: 12
- Joined: February 2nd, 2019, 2:10 pm
Re: Receiving Window Messages
Yes, it's for v2 (that's the "official" release now).
And yes, is equivalent to .
And yes,
Code: Select all
DetectHiddenWindows 1
Code: Select all
DetectHiddenWindows, On
-
- Rainmeter Sage
- Posts: 7287
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Receiving Window Messages
Thanks, I'll test it later on. Hopefully, it will work (which it does).Smurth wrote: ↑May 7th, 2024, 5:44 am Yes, it's for v2 (that's the "official" release now).
And yes,is equivalent toCode: Select all
DetectHiddenWindows 1
.Code: Select all
DetectHiddenWindows, On
-
- Posts: 12
- Joined: February 2nd, 2019, 2:10 pm
Re: Receiving Window Messages
@Yincognito:
Out of subject but you might find this usefull: sending strings from Rainmeter to AHK
default.ini :
default.lua :
myScript.ahk (v2) :
Out of subject but you might find this usefull: sending strings from Rainmeter to AHK
default.ini :
Code: Select all
[Message]
Measure=Plugin
Plugin=WindowMessagePlugin
WindowClass=AutoHotkey
;WindowName=
[lua]
UpdateDivider=-1
Measure=Script
ScriptFile=default.lua
[MyMeter]
Meter=Image
LeftMouseUpAction=[!CommandMeasure lua "Send('#CURRENTSECTION#')"]
default.lua :
Code: Select all
function Send(str)
for c in string.gmatch(str, ".") do
SKIN:Bang('!CommandMeasure', 'Message', 'SendMessage 8192 0 ' .. string.byte(c))
end
SKIN:Bang('!CommandMeasure', 'Message', 'SendMessage 8192 1 0')
end
Code: Select all
OnMessage 0x2000, Msg
Msg(wParam, lParam, msg, hwnd, *) {
Static str := ""
if wParam {
ProcessTheReceivedString(str)
str := ""
} else
str .= Chr(lParam)
}
ProcessTheReceivedString(str) {
MsgBox str
}
-
- Rainmeter Sage
- Posts: 7287
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Receiving Window Messages
Actually, this is precisely on (my own) subject, since I do indeed have a string communication system between the skin and AutoHotKey / AutoIt, based on passing script parameters (like the returned bang structure, for example) in a RunCommand measure from the former, and sending bangs (with the script result) from the latter. As you probably realize though, passing script parameters is only suited for sending the string at the moment when the script is run, while your excellent solution should also work at any moment during the script's execution, which is great and something I've been wondering about too!
Thanks again for these nice solutions - I'll test them later on, but for sure they will be very useful if I want to change the value of some script parameter after I already spawned the script executable from the skin.