Jump to content

Custom Mouse Cursor


Recommended Posts

Hello All!

I made a GUI but I would like to change the mouse cursor ONLY for the GUI. The thing is that I found that which work perfectly but for everywhere in the screen and in any application :)

Global Const $OCR_APPSTARTING = 32650
Global Const $OCR_NORMAL = 32512
Global Const $OCR_CROSS = 32515
Global Const $OCR_HAND = 32649
Global Const $OCR_IBEAM = 32513
Global Const $OCR_NO = 32648
Global Const $OCR_SIZEALL = 32646
Global Const $OCR_SIZENESW = 32643
Global Const $OCR_SIZENS = 32645
Global Const $OCR_SIZENWSE = 32642
Global Const $OCR_SIZEWE = 32644
Global Const $OCR_UP = 32516
Global Const $OCR_WAIT = 32514


_SetCursor("Project11.cur", $OCR_NORMAL)

;==================================================================
; $s_file - file to load cursor from
; $i_cursor - system cursor to change
;==================================================================
Func _SetCursor($s_file, $i_cursor)
   Local $newhcurs, $lResult
   $newhcurs = DllCall("user32.dll", "int", "LoadCursorFromFile", "str", $s_file)
   If Not @error Then
      $lResult = DllCall("user32.dll", "int", "SetSystemCursor", "int", $newhcurs[0], "int", $i_cursor)
      If Not @error Then
         $lResult = DllCall("user32.dll", "int", "DestroyCursor", "int", $newhcurs[0])
      Else
         MsgBox(0, "Error", "Failed SetSystemCursor")
      EndIf
   Else
      MsgBox(0, "Error", "Failed LoadCursorFromFile")
   EndIf
EndFunc  ;==>_SetCursor

Cursor File : http://www.mediafire.com/?x8xf92a7u9n1rx6

Thanks !

Edited by jamesstp20
Link to comment
Share on other sites

I found the function example from the WinAPIEx library, and i do some mods to adapt it.

#include <winapiex.au3>
$hGUI = Guicreate("My Cursos by monoscout999",-1,-1)
$Label = GUICtrlCreateLabel('', 100, 100, 200, 200)
$hCursor = _winapi_LoadCursorFromFile(@Scriptdir&"\Project11.cur")
GUIRegisterMsg($WM_SETCURSOR, 'WM_SETCURSOR')
Guisetstate()
Do
until GuigetMsg() = -3
_WinAPI_DestroyCursor($hCursor)
Func WM_SETCURSOR($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hGUI
            _WinAPI_SetCursor($hCursor)
                Return 0
    EndSwitch
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_SETCURSOR

Link to download and place it in the include folder in the autoit instaled folder.

Maybe this place: C:\Program Files (x86)\AutoIt3\Include

Put you cursor file in the same of the script or edit the line whit the function _winapi_LoadCursorFromFile(...Path and filename of the cursor...)

You need to use the functions

_winapi_LoadCursorFromFile()

_WinAPI_SetCursor()

And register the message WM_SETCURSOR

...to make it work.

If you have any question don`t doubt to do it here :)

Good Look.

EDITED: Added some info.

EDIT: Maybe the problem is from the function or maybe is your cursor, but the hotspot is a few pixels left from the arrow point.

EDITTED: More info.

Edited by monoscout999
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...