I have rewritten the function, so that I can understand the code. I share my result with you, maybe this helps someone out there.
Code: Select all
;-------------------------------------------------------------------------------
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"
, "UInt", 0x57 ; UINT uiAction (SPI_SETCURSORS)
, "UInt", 0 ; UINT uiParam
, "Ptr", 0 ; PVOID pvParam
, "UInt", 0 ; UINT fWinIni
, "Cdecl Int") ; return BOOL
If Not BlankCursor { ; create BlankCursor only once
VarSetCapacity(ANDmask, 32 * 4, 0xFF)
VarSetCapacity(XORmask, 32 * 4, 0x00)
BlankCursor := DllCall("CreateCursor"
, "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
, "Cdecl Ptr") ; return HCURSOR
}
; set all system cursors to blank, each needs a new copy
Loop, Parse, CursorList, `,, %A_Space%
{
CursorHandle := DllCall("CopyImage"
, "Ptr", BlankCursor ; HANDLE hImage
, "UInt", 2 ; UINT uType (IMAGE_CURSOR)
, "Int", 0 ; int cxDesired
, "Int", 0 ; int cyDesired
, "UInt", 0 ; UINT fuFlags
, "Cdecl Ptr") ; return HANDLE
DllCall("SetSystemCursor"
, "Ptr", CursorHandle ; HCURSOR hcur
, "UInt", A_Loopfield ; DWORD id
, "Cdecl Int") ; return BOOL
}
}