Jump to content
Sign in to follow this  

[SOLVED] Set system cursor

Recommended Posts



I would like to know how to set the system mouse cursor, meaning the global cursor shown if moving the mouse outside an AutoIT gui. I know that this can be only done by DllCall() and read all KIP's posts regarding this topic. But to my great disappointment I seem to be to stupid to understand...would someone here be able to come up with a working function _SetCursor()?

Many thanks for your upcoming efforts,

Best Regards and a beautiful weekend,


Edited by cherdeg

Share this post

Link to post
Share on other sites

I tried that code, but 1) it uses a cursor from another theme but the standard white one and 2) the reset to the cursor set before running the script fails on my system, I've got to use the control panel to get the default cursor back.

The following one works:

Global Const $OCR_NORMAL = 32512
Global Const $OCR_IBEAM = 32513
Global Const $OCR_WAIT = 32514

$GUI = GuiCreate("test")
    Local $hWaitCur
    $hWaitCur = _LoadCursor($OCR_WAIT)
    While 1
         If GUIGetMsg() = -3 Then ExitLoop
    $hWaitCur = 0

Func _LoadCursor($iCursor)
    Return SetError(@error,@extended ,_API(DllCall("user32.dll", "int", "LoadCursorA", "hwnd", 0, "int", $iCursor)))
EndFunc   ;==>_LoadCursor

Func _SetSystemCursor($hCursor,$iCursor)
    Return SetError(@error,@extended ,_API(DllCall("user32.dll", "int" ,"SetSystemCursor","int",$hCursor,"int",$iCursor)))

Func _API($v_ret)
    Local $err = @error
    Local $ext = @extended
    If Not $err Then
        If IsArray($v_ret) Then
            Return $v_ret[0]
            Return $v_ret
    Return SetError($err, $ext, 0)
EndFunc   ;==>_API
Edited by cherdeg

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this