Kip Posted September 8, 2007 Posted September 8, 2007 hi is there a way to set my own cursor for a Gui? for example: i wanna set My Documents/cursor.gif to the cursor of my GUI (or a single object) Kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
Zedna Posted September 8, 2007 Posted September 8, 2007 (edited) Look at LoadCursorFromFile, SetCursor, SetSystemCursor API functions.Here is MSDN linkEDIT: also look at my old post about similar system cursor problem: here Edited September 8, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Kip Posted September 8, 2007 Author Posted September 8, 2007 yes, but i want a custom cursor for only 1 GUI MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
Zedna Posted September 8, 2007 Posted September 8, 2007 (edited) yes, but i want a custom cursor for only 1 GUII gave you MSDN link, so look at all cursor API functions listed there and play with them. Edited September 8, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Kip Posted September 8, 2007 Author Posted September 8, 2007 ok, i found this: http://msdn2.microsoft.com/en-us/library/ms633561.aspxPROP_CURSORbut there are a million of combinations how you can put this in a DllCall.please somebody? MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
Valuater Posted September 8, 2007 Posted September 8, 2007 Straight from help #include <GUIConstants.au3> $IDC = -1 $newIDC = 0 HotkeySet("{Esc}", "Increment") GUICreate("Press Esc to Increment", 400, 400,0,0,0x04CF0000, 0x00000110) GUISetState () While GUIGetMsg()<> $GUI_EVENT_CLOSE If $newIDC <> $IDC Then $IDC = $newIDC GUISetCursor($IDC) EndIf ToolTip("GUI Cursor #" & $IDC) WEnd Exit Func Increment() $newIDC = $IDC + 1 If $newIDC > 15 Then $newIDC = 0 EndFunc 8)
Kip Posted September 8, 2007 Author Posted September 8, 2007 I want that (for example: image.gif ) will be my cursor, not the standard system cursors MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
Valuater Posted September 8, 2007 Posted September 8, 2007 (edited) Maybe... 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(@WindowsDir & "\cursors\3dgarro.cur", $OCR_NORMAL) ;~ _SetCursor(@WindowsDir & "\cursors\3dwarro.cur", $OCR_NORMAL) _SetCursor(@WindowsDir & "\cursors\banana.ani", $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 ... to be helpful by gafrost 8) Edited September 8, 2007 by Valuater
Valuater Posted September 8, 2007 Posted September 8, 2007 That and Many More great additions to your script are hereAutoit Wrappers8)
therks Posted September 8, 2007 Posted September 8, 2007 Also: A .gif file cannot be a proper cursor. It will need to be a .cur or .ani. My AutoIt Stuff | My Github
Kip Posted September 8, 2007 Author Posted September 8, 2007 Maybe...: Script... to be helpfulby gafrost8)thnx, but thats not for 1 window Also: A .gif file cannot be a proper cursor. It will need to be a .cur or .ani.lets quote something: 'FOR EXAMPLE: image.gif' MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
The Kandie Man Posted September 8, 2007 Posted September 8, 2007 (edited) thnx, but thats not for 1 window lets quote something: 'FOR EXAMPLE: image.gif'Yes and Saunders clearly stated that it cannot be a .gif image. For that matter, it cannot be a .bmp, .jpg, or .png image either. It must be a .cur or .ani file in order to work as a cursor. That is because the cursor has specific points that are mapped for where the active clicking point is and where transparancies are located. If you want, convert the .gif image to a .cur and set the active clicking point that way. I don't know of any programs that do this off the top of my head. A google search should be adequate to find some programs to do this though.- The Kandie Man ;-) Edited September 8, 2007 by The Kandie Man "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire
Kip Posted September 9, 2007 Author Posted September 9, 2007 someone? MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
Kip Posted September 17, 2007 Author Posted September 17, 2007 please, im not a expert with all those external functions (dll, com) if it can be done with the Cursor API functions, please tell me wich one? MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
Kip Posted December 11, 2007 Author Posted December 11, 2007 (edited) ok, I've got this. but this will set the cursor for both GUIs. MSDN doesnt say anything about a Gui Handle. #include <GuiConstants.au3> $Gui = GuiCreate("Test", 300, 200) GUISetState() $Gui2 = GuiCreate("Test", 300, 200,750) GUISetState() $Cur = DllCall("user32.dll", "int", "LoadCursorFromFile", "str","pen_m.cur") if @error Then MsgBox(0,"dd","whoopsie!") While 1 $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE Exit EndSelect DllCall("user32.dll", "int", "SetCursor", "int", $Cur[0]) WEnd Edited December 11, 2007 by kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
Kip Posted December 12, 2007 Author Posted December 12, 2007 kabumb! MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
therks Posted December 13, 2007 Posted December 13, 2007 Using what you provided, I was able to come up with this: #include <GuiConstants.au3> $Gui = GuiCreate("Test", 300, 200) GUISetState() $Gui2 = GuiCreate("Test", 300, 200,750) GUISetState() GUIRegisterMsg($WM_SETCURSOR, 'WM_SETCURSOR') $Cur = DllCall("user32.dll", "int", "LoadCursorFromFile", "str","C:\windows\cursors\pen_m.cur") if @error Then MsgBox(0,"dd","whoopsie!") While 1 $Msg = GUIGetMsg(1) Select Case $Msg[0] = $GUI_EVENT_CLOSE Exit EndSelect WEnd Func WM_SETCURSOR($hWnd, $iMsg, $iWParam, $iLParam) If $hWnd = $Gui Then DllCall("user32.dll", "int", "SetCursor", "int", $Cur[0]) Return 0 EndIf EndFunc My AutoIt Stuff | My Github
Valuater Posted December 13, 2007 Posted December 13, 2007 Using what you provided, I was able to come up with this: #include <GuiConstants.au3> $Gui = GuiCreate("Test", 300, 200) GUISetState() $Gui2 = GuiCreate("Test", 300, 200,750) GUISetState() GUIRegisterMsg($WM_SETCURSOR, 'WM_SETCURSOR') $Cur = DllCall("user32.dll", "int", "LoadCursorFromFile", "str","C:\windows\cursors\pen_m.cur") if @error Then MsgBox(0,"dd","whoopsie!") While 1 $Msg = GUIGetMsg(1) Select Case $Msg[0] = $GUI_EVENT_CLOSE Exit EndSelect WEnd Func WM_SETCURSOR($hWnd, $iMsg, $iWParam, $iLParam) If $hWnd = $Gui Then DllCall("user32.dll", "int", "SetCursor", "int", $Cur[0]) Return 0 EndIf EndFunc Nice one... added to Autoit wrappers thx 8)
Madza91 Posted December 13, 2007 Posted December 13, 2007 expandcollapse popup#include <GUIConstants.au3> $GUI = GUICreate("OSdesign",@DesktopWidth/2,@DesktopHeight/2,-1,-1,$WS_POPUP) GUISetBkColor(0xeeeeee) GuiCtrlCreateGraphic(220, 10) GUICtrlSetGraphic(-1, 0, 0x000000) GUISetCursor(16,1) $MOUSE_GRAPHIC = GUICtrlCreateGraphic(0,0,12,12) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_COLOR,0x000000) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,0,0) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,1,0) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,0,1) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,0,2) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,0,3) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,0,4) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,0,5) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,0,6) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,0,7) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,0,8) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,0,9) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,1,9) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,2,8) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,3,7) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,4,7) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,5,7) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,6,7) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,7,7) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,7,6) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,6,5) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,5,4) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,4,3) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,3,2) GUICtrlSetGraphic($MOUSE_GRAPHIC,$GUI_GR_PIXEL,2,1) GUISetState(@SW_SHOW) While 1 $MousePos = GUIGetCursorInfo($GUI) GUICtrlSetPos($MOUSE_GRAPHIC,$MousePos[0],$MousePos[1]) Sleep(10) WEnd or #include <GUIConstants.au3> $GUI = GUICreate("OSdesign",@DesktopWidth/2,@DesktopHeight/2,-1,-1,$WS_POPUP) GUISetBkColor(0xeeeeee) GuiCtrlCreateGraphic(220, 10) GUICtrlSetGraphic(-1, 0, 0x000000) GUISetCursor(16,1) $MOUSE_GRAPHIC = GUICtrlCreatePic("image.bmp",0,0,100,100) GUISetState(@SW_SHOW) While 1 $MousePos = GUIGetCursorInfo($GUI) GUICtrlSetPos($MOUSE_GRAPHIC,$MousePos[0],$MousePos[1]) Sleep(10) WEnd [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now