Sedoc94 Posted August 8, 2011 Posted August 8, 2011 Hello,How would I go check with AutoIt if my cursor has beenchanged to cursor x?It should check if the cursor has changed to cursor x(a cursor thats not installed with windows)x = should be the custom installed cursorThanks a bunch!- Sedoc94
wakillon Posted August 8, 2011 Posted August 8, 2011 Did you try MouseGetCursor ? AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
Sedoc94 Posted August 8, 2011 Author Posted August 8, 2011 Yeah, but as the cursors are all custom cursors it would always return id 0 (unkown), right?
Sedoc94 Posted August 8, 2011 Author Posted August 8, 2011 My script doesn't have a GUI... So in another window, yeah...
wakillon Posted August 8, 2011 Posted August 8, 2011 Sorry, MouseGetCursor doesn't recognize external cursor ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
monoscout999 Posted August 8, 2011 Posted August 8, 2011 but your idea is monitoring contantly the cursor and know when it change?
monoscout999 Posted August 8, 2011 Posted August 8, 2011 #Include <WinAPI.au3> local $hCursor, $hOldCursor = 0 While True $hCursor = _WinAPI_GetCursorInfo() If $hOldCursor <> $hCursor[2] Then $hOldCursor = $hCursor[2] consolewrite("The Cursor has changed the handle to the new cursor is "&$hCursor[2]&@CRLF) EndIf Sleep(500) WEnd This is an easy way to do it.
wakillon Posted August 9, 2011 Posted August 9, 2011 @monoscout999That doesn't permit him to identify the custom installed cursor. AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
Sedoc94 Posted August 9, 2011 Author Posted August 9, 2011 @monoscout999That doesn't permit him to identify the custom installed cursor.Yeah...So I guess with AutoIt that is impossible.. sankar18 1
jvanegmond Posted August 9, 2011 Posted August 9, 2011 Yeah...So I guess with AutoIt that is impossible..Did you try the example or are you just saying "Yeah.." because you are too lazy to try it?I don't think wakillon is right in this case. Because $aCursor (return from function) element 2 is a handle to the cursor, which is a HCURSOR. A quote from MSDN:A cursor handle is a unique value of the HCURSOR type that identifies a standard or custom cursor. github.com/jvanegmond
UEZ Posted August 9, 2011 Posted August 9, 2011 Will this help you? expandcollapse popup$old = _WinAPI_GetCursor () ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $old = ' & $old & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console _WinAPI_SetCursor(5) If _WinAPI_GetCursor() <> $old Then MsgBox(0, "Test", "Cursor has changed") _WinAPI_SetCursor($old) ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_GetCursor ; Description....: Retrieves a handle to the current cursor. ; Syntax.........: _WinAPI_GetCursor ( ) ; Parameters.....: None ; Return values..: Success - Handle to the current cursor. If there is no cursor, the return value is 0. ; Failure - 0 and sets the @error flag to non-zero. ; Author.........: Yashied ; Modified.......: ; Remarks........: None ; Related........: ; Link...........: @@MsdnLink@@ GetCursor ; Example........: Yes ; =============================================================================================================================== Func _WinAPI_GetCursor() Local $Ret = DllCall('user32.dll', 'ptr', 'GetCursor') If @error Then Return SetError(1, 0, 0) Return $Ret[0] EndFunc ;==>_WinAPI_GetCursor ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_SetCursor ; Description ...: Establishes the cursor shape ; Syntax.........: _WinAPI_SetCursor($hCursor) ; Parameters ....: $hCursor - Identifies the cursor ; Return values .: Success - The handle of the previous cursor, if there was one. If there was no previous cursor, the ; +return value is 0. ; Author ........: Paul Campbell (PaulIA) ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: @@MsdnLink@@ SetCursor ; Example .......: ; =============================================================================================================================== Func _WinAPI_SetCursor($hCursor) Local $aResult = DllCall("user32.dll", "handle", "SetCursor", "handle", $hCursor) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_SetCursor Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
wakillon Posted August 9, 2011 Posted August 9, 2011 Did you try the example or are you just saying "Yeah.." because you are too lazy to try it?I don't think wakillon is right in this case. Because $aCursor (return from function) element 2 is a handle to the cursor, which is a HCURSOR. A quote from MSDN:Ok for the handle, but that doesn't permit to identify ( find his name or path ) the custom ( or external ) installed cursor AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
monoscout999 Posted August 9, 2011 Posted August 9, 2011 (edited) Ok for the handle, but that doesn't permit to identify ( find his name or path ) the custom ( or external ) installed cursor Yes I know what you mean, I have done this another example. expandcollapse popupGlobal Const $aCheckCursor[15][2] = [["IDC_APPSTARTING", 32650], _ ["IDC_HAND", 32649], _ ["IDC_ARROW", 32512], _ ["IDC_CROSS", 32515], _ ["IDC_IBEAM", 32513], _ ["IDC_ICON", 32641], _ ["IDC_NO", 32648], _ ["IDC_SIZE", 32640], _ ["IDC_SIZEALL", 32646], _ ["IDC_SIZENESW", 32643], _ ["IDC_SIZENS", 32645], _ ["IDC_SIZENWSE", 32642], _ ["IDC_SIZEWE", 32644], _ ["IDC_UPARROW", 32516], _ ["IDC_WAIT", 32514]] #include <WinAPI.au3> Local $hCursor, $hOldCursor = 0 While True $hCursor = _WinAPI_GetCursorInfo() If $hOldCursor <> $hCursor[2] Then $hOldCursor = $hCursor[2] For $i = 0 To UBound($aCheckCursor) - 1 If _WinAPI_LoadCursor(0, $aCheckCursor[$i][1]) = $hCursor[2] Then ConsoleWrite("The Cursor has changed the handle to the new cursor is " & $hCursor[2] & @CRLF & "And the name of the cursor resource is " & $aCheckCursor[$i][0] & @CRLF) EndIf Next EndIf Sleep(500) WEnd ; _WinAPI_LoadCursor() Also you can find it in the WinAPIEx.au3 UDF ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_LoadCursor ; Description....: Loads the specified cursor resource from the executable (.EXE) file. ; Syntax.........: _WinAPI_LoadCursor ( $hInstance, $sName ) ; Parameters.....: $hInstance - Handle to an instance of the module whose executable file contains the cursor to be loaded. ; $sName - The name of the cursor resource or resource identifier to be loaded. To use one of the predefined ; cursors, the application must set the $hInstance parameter to 0 and the $sName parameter to one ; of the following values. ; ; $IDC_APPSTARTING ; $IDC_HAND ; $IDC_ARROW ; $IDC_CROSS ; $IDC_IBEAM ; $IDC_ICON ; $IDC_NO ; $IDC_SIZE ; $IDC_SIZEALL ; $IDC_SIZENESW ; $IDC_SIZENS ; $IDC_SIZENWSE ; $IDC_SIZEWE ; $IDC_UPARROW ; $IDC_WAIT ; ; Return values..: Success - Handle to the newly loaded cursor. ; Failure - 0 and sets the @error flag to non-zero. ; Author.........: Yashied ; Modified.......: ; Remarks........: This function loads the cursor resource only if it has not been loaded; otherwise, it retrieves the handle to ; the existing resource. ; Related........: ; Link...........: @@MsdnLink@@ LoadCursor ; Example........: Yes ; =============================================================================================================================== Func _WinAPI_LoadCursor($hInstance, $sName) Local $TypeOfName = 'int' If IsString($sName) Then $TypeOfName = 'wstr' EndIf Local $Ret = DllCall('user32.dll', 'ptr', 'LoadCursorW', 'ptr', $hInstance, $TypeOfName, $sName) If (@error) Or (Not $Ret[0]) Then Return SetError(1, 0, 0) EndIf Return $Ret[0] EndFunc ;==>_WinAPI_LoadCursor This also retrieve the cursor name form the resource and compare the handles to mach what handle is being used. If you are using external cursors maybe this will be more complicated. Edited August 9, 2011 by monoscout999
wakillon Posted August 9, 2011 Posted August 9, 2011 @monoscout999I have tried your solution and it doesn't work with an external cursor ( .cur )It returns IDC_IBEAM for all cursor tried.It seems to be valid only for a cursor installed with windows.Sedoc94 wants to know when his external cursor has been choose. AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
monoscout999 Posted August 9, 2011 Posted August 9, 2011 (edited) If Sedoc94 knows what .cur files he have, maybe he can do a sctipt that saves all the cursors handles into a variable and later make the comparison, like i did with the default windows cursors. he need to load all the cursors using the function _WinAPI_LoadCursorFromFile() this function returns cursor handles, save all the handles in an array and compare these handles with the one returned by _WinAPI_GetCursorInfo() Edited August 9, 2011 by monoscout999
Bert Posted August 9, 2011 Posted August 9, 2011 Why do I think this is for a game? The Vollatran project My blog: http://www.vollysinterestingshit.com/
monoscout999 Posted August 9, 2011 Posted August 9, 2011 (edited) Why do I think this is for a game?I don`t know. Why do you think that? Edited August 9, 2011 by monoscout999
Yashied Posted August 9, 2011 Posted August 9, 2011 You can try to use the GetIconInfoEx() function. See szModName and szResName members from the ICONINFOEX structure. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
monoscout999 Posted August 9, 2011 Posted August 9, 2011 (edited) You can try to use the GetIconInfoEx() function. See szModName and szResName members from the ICONINFOEX structure. Thanks @yashired. Most of it is extracted fromthe help file of the _WinAPI_GetIconInfoEx() function located in the The only member of the struct that is not retrieving is the "ResName". i don`t have any idea why not. #include <WinAPIex.au3> Local $hCursor, $hOldCursor = 0 While True $hCursor = _WinAPI_GetCursorInfo() If $hOldCursor <> $hCursor[2] Then $hOldCursor = $hCursor[2] $tIIEX = _WinAPI_GetIconInfoEx($hCursor[2]) ConsoleWrite('Handle: ' & $hCursor[2] & @CR) ConsoleWrite('Path: ' & DllStructGetData($tIIEX, 'ModName') & @CR) ConsoleWrite('ID: ' & DllStructGetData($tIIEX, 'ResID') & @CR) ConsoleWrite('Name: ' & DllStructGetData($tIIEX, 'ResName') & @CR) EndIf Sleep(500) WEnd Can you try this? EDIt: For me is not working with custom cursors, i do a test with a game and it gets the handle of the cursor but not the any other info. Edited August 9, 2011 by monoscout999
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