Jump to content

change mouse cursos


buzz44
 Share

Recommended Posts

as people seemed to take no notice to my previous thread i have started 2 new ones...

i want to Change the mouse cursor when i press a button ..

how can i do it and does it have to be throught dll which i have no idea to do and i suk at it

thx

qq

Link to comment
Share on other sites

IM A STILL WAITING >>> i can not believe this ... i know people are ignoring .. why. .. all i want is some help and i have made 3 posts with no reply in about 5 days... bumping CONSTANLY ... all i want to do is know if u can change the mose cursor and if so is it dll .. that is all.

qq

Link to comment
Share on other sites

Well this is what I've got so far.. but I don't understand calling dll's very well. I did manage to get it to return something besides 0, so I think I might be partially succeeding.. maybe?

$cursor = DllCall('user32.dll', 'hwnd', 'LoadCursorFromFile', 'str', 'test.cur')
$set = DllCall('user32.dll', 'hwnd', 'SetCursor', 'hwnd', $cursor[0])
TrayTip('Debuginfo', 'LoadCursor: ' & $cursor[0] & @LF & 'SetCursor: ' & $set[0], 30)

While 1
    Sleep(100)
WEnd
Link to comment
Share on other sites

LoadCursorFromFile

If the function is successful, the return value is a handle to the new cursor.

If the function fails, the return value is NULL. To get extended error information, call GetLastError. GetLastError may return the following value:

In your litlle debug tooltip thinf Loadcursor returns 0 .. i manages to get the handle of the new cursor lol .. just gotta be more specific where to look

$Dir = "C:\WINDOWS\Cursors\arrow_r.cur"; can pick any cursor from that diretory
$cursor = DllCall('user32.dll', 'hwnd', 'LoadCursorFromFile', 'str', $Dir)
$set = DllCall('user32.dll', 'hwnd', 'SetCursor', 'hwnd', $cursor[0])
TrayTip('Debuginfo', 'LoadCursor: ' & $cursor[0] & @LF & 'SetCursor: ' & $set[0], 30)

While 1
    Sleep(100)
WEnd
Edited by burrup

qq

Link to comment
Share on other sites

Err no, sorry. That was a confusing response from me, too vague. I just meant that my LoadCursor didn't return 0 cus the file test.cur actually existed for me. Sorry for the confusion (and for taking 7 hours to clear it up).

I'd really like to see someone who knows what they're doing with DllCall weigh in on this topic though. Changing the mouse cursor would be an interesting thing to do. (Although I have to admit now, I don't know of any programs that change the mouse cursor outside of their own windows, so maybe it's just not possible.)

Link to comment
Share on other sites

its cool.. i posted then i went to bed and have just checked it now lol .. yeah it would be good to change the cursor =( ... i really want to make into the "eyedropper" cursor that comes with paint but that only changes the shape when its over the default label thing. which is wat GUICtrlSetCursor does... but i it it to people able to reach outside by little window and go ANY where on the screen =( ... and yea we should get dome dll pro in here lol

qq

Link to comment
Share on other sites

  • 1 year later...

Did anyone ever have an answer to this???

Thanks

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

Did anyone ever have an answer to this???

Thanks

I haven't got the answer but there are some mistakes in the answers given so far I think.

The function LoadCursor from file is

====================================

HCURSOR LoadCursorFromFile(

LPCTSTR lpFileName

);

Parameters

lpFileName

[in] Specifies the source of the file data to be used to create the cursor. The data in the file must be in either .CUR or .ANI format.

If the high-order word of lpFileName is nonzero, it is a pointer to a string that is a fully qualified name of a file containing cursor data.

Â

If the high-order word of lpFileName is zero, the low-order word is a system cursor identifier. The function then searches the [cursors]section in the WIN.INI file for the file associated with the name of that system cursor. For a list of cursor identifiers, see Remarks.

========================================================

LPCTSTR is a dword I think not a string.

The cursors in WIN.INI are

++++++++++++++++++++++++++++++++++++++++++++++++++

Value Description

OCR_NORMAL normal arrow cursor

OCR_IBEAM I-beam cursor

OCR_WAIT larger hourglass cursor

OCR_CROSS crosshair cursor

OCR_UP up arrow cursor

OCR_SIZE size cursor

OCR_ICON icon cursor

OCR_SIZENWSE NW to SE sizing cursor

OCR_SIZENESW NE to SW sizing cursor

OCR_SIZEWE horizontal sizing cursor

OCR_SIZENS vertical sizing cursor

OCR_SIZEALL horizontal and vertical sizing cursor

OCR_SIZENO international no symbol cursor

OCR_APPSTARTING smaller hourglass with arrow cursor

The constants for these cursors are:

OCR_NORMAL 32512

OCR_IBEAM 32513

OCR_WAIT 32514

OCR_CROSS 32515

OCR_UP 32516

OCR_SIZE 32640

OCR_ICON 32641

OCR_SIZENWSE 32642

OCR_SIZENESW 32643

OCR_SIZEWE 32644

OCR_SIZENS 32645

OCR_SIZEALL 32646

OCR_ICOCUR 32647

++++++++++++++++++++++++++++++++++++++++++++++++++

The way to call the function might be something like this (not tried it)

1) to set the cursor to one in the WIN.INI file

$ds = DllStructCreate("dword")

$newcursor = 32515;try a cross cursor

bitshift($newcursor,-16);??get the value of the cursor into the leftmost bits which I think are read as the low order word - could be wrong here

;and need to get the high order word to zero so the cursor number is read from WIN.INI

DllStructSetData($ds,1,$newcursor)

DllCall("user32.dll","int","LoadCursorFromFile","dword",$ds)

2) Since my WIN.INI file doesn't have any cursors in it I guess the most useful way is to set a pointer to the file name.

Again I am making this up and haven't tried this

$dt=DllStructCreate("string")

DllStructSetData($dt,1,"c:\windows\cursors\e_cross.cur")

$ps = DllStructGetPtr($dt)

$ds = DllStructCreate("dword")

DllStructSetData($ds,1,$ps)

DllCall("user32.dll""int","LoadCursorFromFile","dword",$ds)

Hope this adds to the confusion.

EDIT :Added bit 2)

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Yeah, I thought there was something wrong with those but I don't know dllcalls very well.

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

Still nothing?

this should be a main function!

[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Link to comment
Share on other sites

Still nothing?

this should be a main function!

I've tried a few things but no answer yet. This is my latest attempt which is what I think should work.

#include <GUIConstants.au3>
$Form1 = GUICreate("Cursor Test", 200, 200, 200, 200)
$BtnC = GUICtrlCreateButton("set cross", 60,100, 75, 30)

GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $BtnC
            
            $dt=DllStructCreate("string")
            DllStructSetData($dt,1,"d:\windows\cursors\e_cross.cur")   ;location of cursor file on my PC
            $ps = DllStructGetPtr($dt);make a pointer to the string
            $ds = DllStructCreate("dword")
            DllStructSetData($ds,1,$ps);
            $Res = DllCall("user32.dll","int","LoadCursorFromFile","dword",$ds)
;should return a handle to the cursor
;but returns 0
;tried using $ps instead of $ds but $Res is same
            DllCall("user32.dll","int","SetCursor","hwnd",$Res[0]);set the cursor using the handle returned
            

    EndSwitch
WEnd

Can anyone tell me what's wrong?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...