Skip to content

Instantly share code, notes, and snippets.

@leonardosnt
Created December 19, 2016 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonardosnt/e1935311ac22a935aee7bbc0ec98ec06 to your computer and use it in GitHub Desktop.
Save leonardosnt/e1935311ac22a935aee7bbc0ec98ec06 to your computer and use it in GitHub Desktop.
DetectHiddenWindows, On
hwnd := WinExist("ahk_pid " . DllCall("GetCurrentProcessId", "Uint"))
hwnd += 0x1000 << 32
VD_LIB_PATH := "C:\Users\leonardo\Desktop\VirtualDesktopAccessor.dll"
hVirtualDesktopAccessor := DllCall("LoadLibrary", Str, VD_LIB_PATH, "Ptr")
MoveWindowToDesktopNumberProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "MoveWindowToDesktopNumber", "Ptr")
RestartVirtualDesktopAccessorProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "RestartVirtualDesktopAccessor", "Ptr")
; Restart the virtual desktop accessor when Explorer.exe crashes, or restarts (e.g. when coming from fullscreen game)
explorerRestartMsg := DllCall("user32\RegisterWindowMessage", "Str", "TaskbarCreated")
OnMessage(explorerRestartMsg, "OnExplorerRestart")s
OnExplorerRestart(wParam, lParam, msg, hwnd) {
global RestartVirtualDesktopAccessorProc
DllCall(RestartVirtualDesktopAccessorProc, UInt, result)
}
DllCall("RegisterShellHookWindow", UInt, hWnd)
MsgNum := DllCall("RegisterWindowMessage", Str, "SHELLHOOK")
OnMessage(MsgNum, "OnShellMessage")
OnShellMessage(wParam, lParam) {
; HSHELL_WINDOWCREATED
If (wParam = 1) {
WinGetTitle, title, ahk_id %lParam%
strIndex := InStr(title, "Unturned.exe")
if (strIndex != 0) {
global MoveWindowToDesktopNumberProc
DllCall(MoveWindowToDesktopNumberProc, UInt, lParam, UInt, 0)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment