Created
December 23, 2022 23:44
-
-
Save NtTestAlert/b59531c54b954e02bd3a098829c357d2 to your computer and use it in GitHub Desktop.
[AHK] Parsec dual cursor fix
This file contains 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
;based on: | |
;https://www.autohotkey.com/boards/viewtopic.php?f=6&t=37781 | |
;https://www.autohotkey.com/boards/viewtopic.php?t=51265 | |
#Persistent | |
;------------------------------------------------------------------------------- | |
show_Mouse(bShow := True) { ; show/hide the mouse cursor | |
;------------------------------------------------------------------------------- | |
; WINAPI: SystemParametersInfo, CreateCursor, CopyImage, SetSystemCursor | |
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724947.aspx | |
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms648385.aspx | |
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms648031.aspx | |
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms648395.aspx | |
;--------------------------------------------------------------------------- | |
static BlankCursor | |
static CursorList := "32512, 32513, 32514, 32515, 32516, 32640, 32641" | |
. ",32642, 32643, 32644, 32645, 32646, 32648, 32649, 32650, 32651" | |
local ANDmask, XORmask, CursorHandle | |
If bShow ; shortcut for showing the mouse cursor | |
Return, DllCall("SystemParametersInfo" ; returns BOOL | |
, "UInt", 0x57 ; UINT uiAction (SPI_SETCURSORS) | |
, "UInt", 0 ; UINT uiParam | |
, "Ptr", 0 ; PVOID pvParam | |
, "UInt", 0) ; UINT fWinIni | |
If Not BlankCursor { ; create BlankCursor only once | |
VarSetCapacity(ANDmask, 32 * 4, 0xFF) | |
VarSetCapacity(XORmask, 32 * 4, 0x00) | |
BlankCursor := DllCall("CreateCursor" ; returns HCURSOR | |
, "Ptr", 0 ; HINSTANCE hInst | |
, "Int", 0 ; int xHotSpot | |
, "Int", 0 ; int yHotSpot | |
, "Int", 32 ; int nWidth | |
, "Int", 32 ; int nHeight | |
, "Ptr", &ANDmask ; const VOID *pvANDPlane | |
, "Ptr", &XORmask) ; const VOID *pvXORPlane | |
} | |
; set all system cursors to blank, each needs a new copy | |
Loop, Parse, CursorList, `,, %A_Space% | |
{ | |
CursorHandle := DllCall("CopyImage" ; returns HANDLE | |
, "Ptr", BlankCursor ; HANDLE hImage | |
, "UInt", 2 ; UINT uType (IMAGE_CURSOR) | |
, "Int", 0 ; int cxDesired | |
, "Int", 0 ; int cyDesired | |
, "UInt", 0) ; UINT fuFlags | |
DllCall("SetSystemCursor" ; returns BOOL | |
, "Ptr", CursorHandle ; HCURSOR hcur | |
, "UInt", A_Loopfield) ; DWORD id | |
} | |
} | |
OnWinActiveChange(hWinEventHook, vEvent, hWnd) | |
{ | |
;EVENT_SYSTEM_FOREGROUND := 0x3 | |
static _ := DllCall("user32\SetWinEventHook", UInt,0x3, UInt,0x3, Ptr,0, Ptr,RegisterCallback("OnWinActiveChange"), UInt,0, UInt,0, UInt,0, Ptr) | |
DetectHiddenWindows, On | |
; WinGetClass, vWinClass, % "ahk_id " hWnd | |
WinGetActiveTitle, Title | |
if(Title == "Parsec"){ | |
show_Mouse(False) | |
}else{ | |
show_Mouse(True) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment