How do I send a message to a window handle using AutoHotKey?

1.1k views Asked by At

I'm trying to detect if ffdshow is currently running on the computer using AutoHotKey.

Someone has suggested that I can achieve this by sending a message to the to the ffdshow window handle. If it succeeds, then ffdshow is running.

According to ffdshow, the window handle is 32786 and, according to the AutoHotKey documentation, I want to use PostMessage and then check ErrorLevel.

However at that point, I'm struggling to understand the documentation. I've got the following:

ControlHwnd := 32786
VarContainingID := 32786
PostMessage, 0x00, , , ,ahk_id %ControlHwnd%, ahk_id %VarContainingID%
MsgBox %ErrorLevel%

but that always reports a 1 indicating that it was unable to connect to the window handle - even though ffdshow is running.

I've also tried changing PostMessage to the blocking SendMessage but that always reports FAIL.

I'm clearly doing something wrong, but I'm not really sure what. Can anyone help?

1

There are 1 answers

0
Richard On BEST ANSWER

Thanks to blackholyman and MCL, I found the problem.

After digging around in the sample code found here, it turns out there is a window class for ffdshow called ffdshow_remote_class.

As a result, the following code:

DetectHiddenWindows, On
WinGet, activeid, ID, ahk_class ffdshow_remote_class
MsgBox activeid = %activeid%

will return a hWnd value for ffdshow (stored in activeid) if it is running or nothing if it is not.