-
Notifications
You must be signed in to change notification settings - Fork 106
Open
Description
When I run my script as Administrator, RegisterPostMessageHook does nothing. No error, just nothing happens.
Here's some minimal example:
#Requires AutoHotkey v2.0
#SingleInstance Force
Persistent
SetWorkingDir(A_ScriptDir)
MSG_VIRTUAL_DESKTOP_MENAGER := 0x1400 + 30
_hVD := DllCall("LoadLibrary", "Str", ".\WindowManagement\VirtualDesktopAccessor.dll", "Ptr")
_hProcRegisterPostMessageHook := DllCall("GetProcAddress", "Ptr", _hVD, "AStr", "RegisterPostMessageHook", "Ptr")
if (!DllCall("ChangeWindowMessageFilterEx", "Ptr", A_ScriptHwnd, "UInt", MSG_VIRTUAL_DESKTOP_MENAGER, "UInt", 1, "Ptr", 0, "Int")) { ; MSGFLT_ALLOW
MsgBox("Can't change filter EX")
}
; To be COMPLETELY sure
if (!DllCall("ChangeWindowMessageFilter", "UInt", MSG_VIRTUAL_DESKTOP_MENAGER, "UInt", 1, "Int")) { ; MSGFLT_ADD
MsgBox("Can't change filter")
}
if (DllCall(_hProcRegisterPostMessageHook, "Ptr", A_ScriptHwnd, "Int", MSG_VIRTUAL_DESKTOP_MENAGER, "Int") == -1) {
MsgBox("Can't register post message hook")
}
OnMessage(MSG_VIRTUAL_DESKTOP_MENAGER, recipient)
recipient(prevDesktop, newDesktop, msg, hwnd) {
; Not triggered from Admin
MsgBox("VDM: prev>" prevDesktop " new>" newDesktop " msg>" msg " hwnd>" hwnd)
}I already know it's not a separate process, so I don't really need ChangeWindowMessageFilterEx, but added it just to make sure it isn't some kind of a messaging problem.
I guess it's something to do with COM access, but I'm no expert at that level.
- Sytem: win 11, 24H2, 26100.4946
- Users:
My main user is NOT an admin. When I run the script as admin, it goes through the UAC, and it's technically being run from a different user, not just elevated (I guess..)
Metadata
Metadata
Assignees
Labels
No labels