Created
December 19, 2016 12:46
-
-
Save leonardosnt/e1935311ac22a935aee7bbc0ec98ec06 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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