Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Requires AutoHotkey 2.0
- A_CoordModeMouse := "Screen"
- SetDefaultMouseSpeed(0)
- #HotIf (WinActive("ahk_exe explorer.exe"))
- RButton::
- {
- static EVENT_OBJECT_CREATE := 0x8000
- Critical(-1)
- while (GetKeyState("RButton", "P"))
- {
- if (KeyWait("LButton", "D T0.05"))
- {
- HotIf()
- Hotkey("LButton", (*) => 0, "On")
- Hotkey("RButton", (*) => 0, "On")
- Hotkey("LButton up", (*) => 0, "On")
- DllCall("SetWinEventHook", "UInt", EVENT_OBJECT_CREATE, "UInt", EVENT_OBJECT_CREATE, "Ptr", 0, "Ptr", CallbackCreate(HandleDragImageEvent), "UInt", 0, "UInt", 0, "UInt", 0)
- MouseGetPos(&previousCursorX, &previousCursorY)
- SystemCursor("Toggle")
- Send("{Click " previousCursorX + 5 " " previousCursorY " 0}")
- Sleep(10)
- Send("{Click " previousCursorX - 5 " " previousCursorY " 0}")
- Sleep(10)
- Send("{Click " previousCursorX " " previousCursorY " 0}")
- SystemCursor("Toggle")
- Run("chrome.exe https://github.dev/ --start-maximized --disable-features=GlobalMediaControls")
- Sleep(100)
- WinWaitActive("Visual Studio")
- MouseGetPos(&previousCursorX, &previousCursorY)
- SystemCursor("Toggle")
- Send("{Click " A_ScreenWidth / 2 " " A_ScreenHeight / 2 " 0}")
- Sleep(50)
- Send("{Click " A_ScreenWidth / 2 " " A_ScreenHeight / 2 " U}")
- Send("{Click " previousCursorX " " previousCursorY " 0}")
- SystemCursor("Toggle")
- Hotkey("LButton", "Off")
- Hotkey("RButton", "Off")
- Hotkey("LButton up", "Off")
- return
- }
- }
- Send("{RButton}")
- }
- SystemCursor(cmd) ; cmd = "Show|Hide|Toggle|Reload"
- {
- static visible := true, c := Map()
- static sys_cursors := [32512, 32513, 32514, 32515, 32516, 32642, 32643, 32644, 32645, 32646, 32648, 32649, 32650]
- if (cmd = "Reload" || !c.Count) ; Reload when requested or at first call
- {
- for (i, id in sys_cursors)
- {
- h_cursor := DllCall("LoadCursor", "Ptr", 0, "Ptr", id)
- h_default := DllCall("CopyImage", "Ptr", h_cursor, "UInt", 2, "Int", 0, "Int", 0, "UInt", 0)
- h_blank := DllCall("CreateCursor", "Ptr", 0, "Int", 0, "Int", 0, "Int", 32, "Int", 32, "Ptr", Buffer(32 * 4, 0xFF), "Ptr", Buffer(32 * 4, 0))
- c[id] := {Default: h_default, Blank: h_blank}
- }
- }
- switch (cmd)
- {
- case "Show": visible := true
- case "Hide": visible := false
- case "Toggle": visible := !visible
- default: return
- }
- for (id, handles in c)
- {
- h_cursor := DllCall("CopyImage", "Ptr", visible ? handles.Default : handles.Blank, "UInt", 2, "Int", 0, "Int", 0, "UInt", 0)
- DllCall("SetSystemCursor", "Ptr", h_cursor, "UInt", id)
- }
- }
- HandleDragImageEvent(hWinEventHook, event, hWnd, *)
- {
- static hiddenImagesAmount := 0
- try
- if (WinGetClass(hWnd) = "SysDragImage") ; Both explorer.exe and chrome.exe have one
- {
- WinKill(hWnd)
- if (++hiddenImagesAmount = 2)
- DllCall("UnhookWinEvent", "Ptr", hWinEventHook)
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement