Closed achim-t closed 1 year ago
The code is pretty much from the example:
RegisterPostMessageHookProc := DllCall("GetProcAddress", "Ptr", hVirtualDesktopAccessor, "AStr", "RegisterPostMessageHook", "Ptr") DllCall(RegisterPostMessageHookProc, "Ptr", A_ScriptHwnd, "Int", 0x1400 + 30, "Int") OnMessage(0x1400 + 30, "OnChangeDesktop") OnChangeDesktop(wParam, lParam, msg, hwnd) { Critical, 100 OldDesktop := wParam + 1 NewDesktop := lParam + 1 OutputDebug % "Desktop changed from " OldDesktop " to " NewDesktop }
When I change the desktop (by Win+Tab and click on different desktop) I would expect a message in the debugger. But there is no output.
Other functions like GetDesktopCount work.
What version of Windows is that? Try opening "winver.exe" I have 22621.2283, with lastest DLL the OnChangeDesktop works.
Well, it works now. I guess I had a mix up with different versions of the DLL. Thank you.
The code is pretty much from the example:
When I change the desktop (by Win+Tab and click on different desktop) I would expect a message in the debugger. But there is no output.
Other functions like GetDesktopCount work.
full script
```ahk #SingleInstance, Force SendMode Input SetWorkingDir, %A_ScriptDir% ; Path to the DLL, relative to the script VDA_PATH := A_ScriptDir . "\libraries\virtual-desktop-accessor.dll" hVirtualDesktopAccessor := DllCall("LoadLibrary", "Str", VDA_PATH, "Ptr") GetDesktopCountProc := DllCall("GetProcAddress", "Ptr", hVirtualDesktopAccessor, "AStr", "GetDesktopCount", "Ptr") GetDesktopCount() { global GetDesktopCountProc count := DllCall(GetDesktopCountProc, "Int") return count } CountDesktops() { c := GetDesktopCount() OutputDebug, % "There are " c " virtual desktops" } RegisterPostMessageHookProc := DllCall("GetProcAddress", "Ptr", hVirtualDesktopAccessor, "AStr", "RegisterPostMessageHook", "Ptr") DllCall(RegisterPostMessageHookProc, "Ptr", A_ScriptHwnd, "Int", 0x1400 + 30, "Int") OnMessage(0x1400 + 30, "OnChangeDesktop") OnChangeDesktop(wParam, lParam, msg, hwnd) { Critical, 100 OldDesktop := wParam + 1 NewDesktop := lParam + 1 OutputDebug % "Desktop changed from " OldDesktop " to " NewDesktop } F1::CountDesktops() ```