Unc3nZureD Posted December 27, 2013 Posted December 27, 2013 I tried to apply a custom cursor to my GUI but it isn't working for me. Here's my code: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Include <APIConstants.au3> #Include <WinAPIEx.au3> $hCursor = _WinAPI_LoadCursorFromFile(@ScriptDir & '\Cursor.ani') $Form1 = GUICreate("Form1", 501, 301, 192, 124) $Button1 = GUICtrlCreateButton("Button1", 120, 96, 91, 41) $Pic1 = GUICtrlCreatePic("", 0, 0, 500, 300) GUICtrlSetState(-1, $GUI_DISABLE) GUIRegisterMsg($WM_SETCURSOR, 'WM_SETCURSOR') GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _WinAPI_DestroyCursor($hCursor) Exit EndSwitch WEnd Func WM_SETCURSOR($hWnd, $iMsg, $wParam, $lParam) Switch $hWnd Case $Form1 Local $Cursor = GUIGetCursorInfo($Form1) If (Not @error) And ($Cursor[4] = $Button1) Then _WinAPI_SetCursor($hCursor) Return 0 EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc Well,basically it shows up the new cursor, however it doesn't change the cursor, just shows up the y custom one (I mean it shows dual mouse)
reb Posted December 27, 2013 Posted December 27, 2013 Not sure what you are trying to do but have you looked at these: GUICtrlSetCursor - over a control GUISetCursor - entire window Seems like these might do REB MEASURE TWICE - CUT ONCE
Unc3nZureD Posted December 27, 2013 Author Posted December 27, 2013 (edited) The probem is that I'd like to use a custom cursor, not an inbuilt one. Edited December 27, 2013 by Unc3nZureD
Unc3nZureD Posted December 27, 2013 Author Posted December 27, 2013 Here's another code I tried, but still not working properly: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Include <APIConstants.au3> #Include <WinAPIEx.au3> $Form1 = GUICreate("Form1", 501, 301, 192, 124) $Button1 = GUICtrlCreateButton("Button1", 120, 96, 91, 41) $Pic1 = GUICtrlCreatePic("", 0, 0, 500, 300) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_SETCURSOR, 'WM_SETCURSOR') $Cur = DllCall("user32.dll", "int", "LoadCursorFromFile", "str",@ScriptDir & "\Cursor.ani") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_SETCURSOR($hWnd, $iMsg, $iWParam, $iLParam) If $hWnd = $Form1 Then DllCall("user32.dll", "int", "SetCursor", "int", $Cur[0]) Return 0 EndIf EndFunc
reb Posted December 27, 2013 Posted December 27, 2013 Found these by goggling "gui custom cursor autoit" '?do=embed' frameborder='0' data-embedContent>> '?do=embed' frameborder='0' data-embedContent>> REB MEASURE TWICE - CUT ONCE
reb Posted December 27, 2013 Posted December 27, 2013 This works for me #include <winapiex.au3> Global $WM_SETCURSOR $hGUI = Guicreate("My Cursos by monoscout999",-1,-1) $Label = GUICtrlCreateLabel('lable', 100, 100, 200, 200) $hCursor = _winapi_LoadCursorFromFile(@Scriptdir&"\Untitled.cur") ;~ _WinAPI_SetCursor($hCursor) GUIRegisterMsg(0x0020, '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 Put your cursor in the same folder as this code and replace "Untitled.cur" with name of your cursor. REB custom cursor.au3 MEASURE TWICE - CUT ONCE
Unc3nZureD Posted December 27, 2013 Author Posted December 27, 2013 Is this perfectly work for you? Interesting, sinc it isn't for me. Somewhere it works, but if your corusor gets near to the lable it starts flashing just like at "my" scripts.
reb Posted December 28, 2013 Posted December 28, 2013 I believe the cursor is for the window and the label is exempt . I guess you want it the other way around? I don't know if I can do that. I will study it some more. No promises. REB MEASURE TWICE - CUT ONCE
Unc3nZureD Posted December 28, 2013 Author Posted December 28, 2013 I want to apply the cursor to the whole GUI including the window and all of its controls.
johnmcloud Posted December 28, 2013 Posted December 28, 2013 (edited) This work also on Label-Button: expandcollapse popup; Johnmcloud #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> Global Const $OCR_NORMAL = 32512 Global $Flag $hGUI = GUICreate("Assing Cursor to my GUI", 300, 200, -1, -1) $Label = GUICtrlCreateLabel("Label", 8, 8, 36, 17) $Button = GUICtrlCreateButton("Button", 70, 8, 75, 25) GUISetState(@SW_SHOW) If _CheckMouseOver() = True Then ConsoleWrite("MOUSE OVER GUI" & @CRLF) _SetCursor(@ScriptDir & "\Cursor.ani", $OCR_NORMAL) $Flag = False Else ConsoleWrite("MOUSE OUTSIDE GUI" & @CRLF) _SetCursor(@WindowsDir & "\Cursors\3dwarro.cur", $OCR_NORMAL) $Flag = True EndIf While 1 $aMPos = MouseGetPos() Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _SetCursor(@WindowsDir & "\Cursors\3dwarro.cur", $OCR_NORMAL) Exit EndSwitch If _CheckMouseOver() = True Then If $Flag Then ConsoleWrite("MOUSE OVER GUI" & @CRLF) _SetCursor(@ScriptDir & "\Cursor.ani", $OCR_NORMAL) $Flag = False EndIf Else If Not $Flag Then ConsoleWrite("MOUSE OUTSIDE GUI" & @CRLF) _SetCursor(@WindowsDir & "\Cursors\3dwarro.cur", $OCR_NORMAL) $Flag = True EndIf EndIf WEnd Func _CheckMouseOver() Local $RET = False If WinActive($hGUI) Then Local $aMousePos = MouseGetPos() Local $aGuiPos = WinGetPos($hGUI) If ($aMousePos[0] > $aGuiPos[0]) And ($aMousePos[0] < ($aGuiPos[0] + $aGuiPos[2])) And _ ($aMousePos[1] > $aGuiPos[1]) And ($aMousePos[1] < ($aGuiPos[1] + $aGuiPos[3])) Then $RET = True EndIf EndIf Return $RET EndFunc ;==>_CheckMouseOver Func _SetCursor($s_file, $i_cursor) Local $newhcurs, $lResult $newhcurs = DllCall("user32.dll", "int", "LoadCursorFromFile", "str", $s_file) $lResult = DllCall("user32.dll", "int", "SetSystemCursor", "int", $newhcurs[0], "int", $i_cursor) $lResult = DllCall("user32.dll", "int", "DestroyCursor", "int", $newhcurs[0]) EndFunc ;==>_SetCursor The only thing i'll leave to you is to get the active system cursor ( i have set 3dwarro.cur for testing purpose ) so you can replace with 3dwarro.cur ( maybe is someware in registry key ) and finally replace Cursor.ani with yours custom cursor. Make some research Edited December 28, 2013 by johnmcloud
Solution mikell Posted December 28, 2013 Solution Posted December 28, 2013 A few minor adjustments using the Autoit UDF WinApi funcs expandcollapse popup#include <GUIConstantsEx.au3> #include <winapiex.au3> #include <WinAPIRes.au3> Global $Flag $hold_cursor = _WinAPI_CopyCursor(_WinAPI_LoadCursor (0, $OCR_NORMAL)) $hnew_Cursor = _WinApi_LoadCursorFromFile(@Scriptdir & "\1.ani") $hGUI = GUICreate("Assing Cursor to my GUI", 300, 200, -1, -1) $Label = GUICtrlCreateLabel("Label", 8, 8, 36, 17) $Button = GUICtrlCreateButton("Button", 70, 8, 75, 25) GUISetState(@SW_SHOW) While 1 $aMPos = MouseGetPos() Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_SetSystemCursor($hold_Cursor, $OCR_NORMAL) _WinAPI_DestroyCursor($hnew_Cursor) _WinAPI_DestroyCursor($hold_cursor ) Exit EndSwitch If _CheckMouseOver() = True Then If $Flag Then _WinAPI_SetSystemCursor($hnew_Cursor, $OCR_NORMAL, 1) $Flag = False EndIf Else If Not $Flag Then _WinAPI_SetSystemCursor($hold_Cursor, $OCR_NORMAL, 1) $Flag = True EndIf EndIf WEnd Func _CheckMouseOver() Local $RET = False If WinActive($hGUI) Then Local $aMousePos = MouseGetPos() Local $aGuiPos = WinGetPos($hGUI) If ($aMousePos[0] > $aGuiPos[0]) And ($aMousePos[0] < ($aGuiPos[0] + $aGuiPos[2])) And _ ($aMousePos[1] > $aGuiPos[1]) And ($aMousePos[1] < ($aGuiPos[1] + $aGuiPos[3])) Then $RET = True EndIf EndIf Return $RET EndFunc ;==>_CheckMouseOver
qwert Posted August 2, 2014 Posted August 2, 2014 I understand this method for MessageLoop mode and have run this example. But how would you configure it for OnEvent mode? I don't see a way to implement the CheckMouseOver function.
mikell Posted August 2, 2014 Posted August 2, 2014 Here it is expandcollapse popup#include <GUIConstantsEx.au3> #include <winapiex.au3> #include <WinAPIRes.au3> Opt("GUIOnEventMode", 1) Global $Flag $hold_cursor = _WinAPI_CopyCursor(_WinAPI_LoadCursor (0, $OCR_NORMAL)) $hnew_Cursor = _WinApi_LoadCursorFromFile(@Scriptdir & "\1.ani") $hGUI = GUICreate("Assing Cursor to my GUI", 300, 200, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "_CheckCursor") $Label = GUICtrlCreateLabel("Label", 8, 8, 36, 17) $Button = GUICtrlCreateButton("Button", 70, 8, 75, 25) GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd Func _CheckCursor() If _CheckMouseOver() = True Then If $Flag Then _WinAPI_SetSystemCursor($hnew_Cursor, $OCR_NORMAL, 1) $Flag = False EndIf Else If Not $Flag Then _WinAPI_SetSystemCursor($hold_Cursor, $OCR_NORMAL, 1) $Flag = True EndIf EndIf EndFunc Func _Quit() _WinAPI_SetSystemCursor($hold_Cursor, $OCR_NORMAL) _WinAPI_DestroyCursor($hnew_Cursor) _WinAPI_DestroyCursor($hold_cursor ) Exit EndFunc Func _CheckMouseOver() Local $RET = False If WinActive($hGUI) Then Local $aMousePos = MouseGetPos() Local $aGuiPos = WinGetPos($hGUI) If ($aMousePos[0] > $aGuiPos[0]) And ($aMousePos[0] < ($aGuiPos[0] + $aGuiPos[2])) And _ ($aMousePos[1] > $aGuiPos[1]) And ($aMousePos[1] < ($aGuiPos[1] + $aGuiPos[3])) Then $RET = True EndIf EndIf Return $RET EndFunc ;==>_CheckMouseOver
qwert Posted August 3, 2014 Posted August 3, 2014 Thanks for the quick response. Your script works great. Unfortunately (for me), when I moved the components into my au3 application, I first have to click somewhere on the GUI to cause it to perform the CheckCursor ... and, even then, activation of my custom cursor is very indeterminate. Sometimes it does, sometimes it doesn't. I think it's related to the fact that I have child windows active ... or, that the main window is a popup tool window. But now that I see the approach to take, I'll sort out the details. Thanks for your help.
mikell Posted August 3, 2014 Posted August 3, 2014 It should work if you put _CheckCursor() inside the main While loop, initialize $Flag = true and remove the WinActive($hGUI) test
qwert Posted August 3, 2014 Posted August 3, 2014 Indeed, that does work. But, now, I don't understand why ... even though your first two scripts made perfect sense. Here's my interpretation of the changes you recommended: expandcollapse popup#include <GUIConstantsEx.au3> ;;;;;;#include <winapiex.au3> #include <WinAPIRes.au3> Opt("GUIOnEventMode", 1) Global $Flag = 1 ;<<<<<<<<<< force ON, initially $hold_cursor = _WinAPI_CopyCursor(_WinAPI_LoadCursor (0, $OCR_NORMAL)) $hnew_Cursor = _WinApi_LoadCursorFromFile(@Scriptdir & "\1.ani") $hGUI = GUICreate("Custom Cursor to my GUI", 300, 200, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "_CheckCursor") $Label = GUICtrlCreateLabel("Label", 8, 8, 36, 17) $Button = GUICtrlCreateButton("Button", 70, 8, 75, 25) GUISetState(@SW_SHOW) While 1 _CheckCursor() ; add function call Sleep(100) WEnd Func _CheckCursor() If _CheckMouseOver() = True Then If $Flag Then _WinAPI_SetSystemCursor($hnew_Cursor, $OCR_NORMAL, 1) $Flag = False EndIf Else If Not $Flag Then _WinAPI_SetSystemCursor($hold_Cursor, $OCR_NORMAL, 1) $Flag = True EndIf EndIf EndFunc Func _Quit() _WinAPI_SetSystemCursor($hold_Cursor, $OCR_NORMAL) _WinAPI_DestroyCursor($hnew_Cursor) _WinAPI_DestroyCursor($hold_cursor ) Exit EndFunc Func _CheckMouseOver() Local $RET = False ;;;;; If WinActive($hGUI) Then ; removed check Local $aMousePos = MouseGetPos() Local $aGuiPos = WinGetPos($hGUI) If ($aMousePos[0] > $aGuiPos[0]) And ($aMousePos[0] < ($aGuiPos[0] + $aGuiPos[2])) And _ ($aMousePos[1] > $aGuiPos[1]) And ($aMousePos[1] < ($aGuiPos[1] + $aGuiPos[3])) Then $RET = True EndIf ;;;;; EndIf Return $RET EndFunc ;==>_CheckMouseOver . So, I need to ask: what is the role of CheckCursor() in the main loop? My script needs it, but your example doesn't seem to. Yet, they're both operating in OnEvent mode. And why is the WinActive check no longer needed? Or, to put it another way, what role did it serve in your OnEvent example? Thanks for your additional help on this.  Â
Belini Posted August 3, 2014 Posted August 3, 2014 I change the cursor like this: expandcollapse popupOpt("MustDeclareVars", 1) Const $OCR_NORMAL = 32512 Local $Form1, $Button1, $Button2, $Button3, $nMsg, $cursor1 ="", $cursor2 ="", $cursor3 ="" Local $Hcursor = 0 $cursor1= _normal(true) $cursor2= _point(true) $cursor3= _invisible(true) #include <GUIConstants.au3> $Form1 = GUICreate("Mouse cursor", 265, 65, 193, 115) $Button1 = GUICtrlCreateButton("Normal", 8, 16, 73, 33, 0) $Button2 = GUICtrlCreateButton("point", 104, 16, 65, 33, 0) $Button3 = GUICtrlCreateButton("invisible", 192, 16, 65, 33, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $Button1 $Hcursor = DllCall("user32.dll","int","LoadCursorFromFileA", "str", $cursor1) If Not @error Then DllCall("user32.dll","int","SetSystemCursor", "int", $Hcursor[0], "int", $OCR_NORMAL) EndIf Case $Button2 $Hcursor = DllCall("user32.dll","int","LoadCursorFromFileA", "str", $cursor2) If Not @error Then DllCall("user32.dll","int","SetSystemCursor", "int", $Hcursor[0], "int", $OCR_NORMAL) EndIf Case $Button3 $Hcursor = DllCall("user32.dll","int","LoadCursorFromFileA", "str", $cursor3) If Not @error Then DllCall("user32.dll","int","SetSystemCursor", "int", $Hcursor[0], "int", $OCR_NORMAL) EndIf EndSwitch WEnd ; #FUNCTION# ==================================================================================================================== ; Name ..........: _invisible() ; Description ...: Compressed file embedded in your .au3 file ; Syntax ........: _invisible( [ lToSave [, sPath [, lExecute ]]] ) ; Parameters ....: lToSave - [optional] If True, save the file, else, return binary data. Default is False. ; sPath - [optional] The path of the file to be save. Default is @TempDir ; lExecute - [optional] Flag to execute file saved. Default is False ; Return values .: Success - Returns decompressed invisible.cur binary data or saved. ; Failure - Returns 0 and set @error to 1. ; Author(s) .....: João Carlos (Jscript FROM Brazil) ; Modified ......: ; Remarks .......: This function uses _LZNTDecompress() and _Base64Decode() by trancexx. ; Related .......: ; Link ..........: ; Example .......; _invisible() ; =============================================================================================================================== Func _invisible( $lToSave = False, $sPath = @TempDir, $lExecute = False ) Local $hFileHwnd, $bData, $sFileName = $sPath & "\invisible.cur" ; Original: D:\00 _Importantes\06 ARCADE\00 Fazer nova instalação da multijogos\Mudar ponteiro do mouse\Alterar cursor (Temporário)\invisible.cur $bData = "QLAAAAACAAEAICAIAAAKABAwAQAAYBYAAAAoABgAkACaQAA4AQB8ABgAgAEQHQQMAgAcAQwBOP///w8BDHoGAIN6Ag==" If $lToSave Then $hFileHwnd = FileOpen($sFileName, 10) If @error Then Return SetError(1, 0, 0) FileWrite($hFileHwnd, __invisible(__invisibleB64($bData))) FileClose($hFileHwnd) If $lExecute Then RunWait($sFileName, "") FileDelete($sFileName) Return 1 EndIf If FileExists($sFileName) Then Return $sFileName Else Return __invisible(__invisibleB64($bData)) EndIf Return SetError(1, 0, 0) EndFunc ;==>_invisible ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __invisibleB64 ; Description ...: Base64 decode input data. ; Syntax.........: __invisibleB64($bBinary) ; Parameters ....: $sInput - String data to decode ; Return values .: Success - Returns decode binary data. ; - Sets @error to 0 ; Failure - Returns empty string and sets @error: ; |1 - Error calculating the length of the buffer needed. ; |2 - Error decoding. ; Author ........: trancexx ; Modified ......: João Carlos (Jscript FROM Brazil) ; Related .......: _Base64Encode() ; =============================================================================================================================== Func __invisibleB64($sInput) Local $struct = DllStructCreate("int") Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _ "str", $sInput, _ "int", 0, _ "int", 1, _ "ptr", 0, _ "ptr", DllStructGetPtr($struct, 1), _ "ptr", 0, _ "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(1, 0, "") ; error calculating the length of the buffer needed EndIf Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]") $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _ "str", $sInput, _ "int", 0, _ "int", 1, _ "ptr", DllStructGetPtr($a), _ "ptr", DllStructGetPtr($struct, 1), _ "ptr", 0, _ "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(2, 0, ""); error decoding EndIf Return DllStructGetData($a, 1) EndFunc ;==>__invisibleB64 ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __invisible ; Original Name..: _LZNTDecompress ; Description ...: Decompresses input data. ; Syntax.........: __invisible($bBinary) ; Parameters ....: $vInput - Binary data to decompress. ; Return values .: Success - Returns decompressed binary data. ; - Sets @error to 0 ; Failure - Returns empty string and sets @error: ; |1 - Error decompressing. ; Author ........: trancexx ; Related .......: _LZNTCompress ; Link ..........; http://msdn.microsoft.com/en-us/library/bb981784.aspx ; =============================================================================================================================== Func __invisible($bBinary) $bBinary = Binary($bBinary) Local $tInput = DllStructCreate("byte[" & BinaryLen($bBinary) & "]") DllStructSetData($tInput, 1, $bBinary) Local $tBuffer = DllStructCreate("byte[" & 16 * DllStructGetSize($tInput) & "]") ; initially oversizing buffer Local $a_Call = DllCall("ntdll.dll", "int", "RtlDecompressBuffer", _ "ushort", 2, _ "ptr", DllStructGetPtr($tBuffer), _ "dword", DllStructGetSize($tBuffer), _ "ptr", DllStructGetPtr($tInput), _ "dword", DllStructGetSize($tInput), _ "dword*", 0) If @error Or $a_Call[0] Then Return SetError(1, 0, "") ; error decompressing EndIf Local $tOutput = DllStructCreate("byte[" & $a_Call[6] & "]", DllStructGetPtr($tBuffer)) Return SetError(0, 0, DllStructGetData($tOutput, 1)) EndFunc ;==>__invisible ; #FUNCTION# ==================================================================================================================== ; Name ..........: _point() ; Description ...: Compressed file embedded in your .au3 file ; Syntax ........: _point( [ lToSave [, sPath [, lExecute ]]] ) ; Parameters ....: lToSave - [optional] If True, save the file, else, return binary data. Default is False. ; sPath - [optional] The path of the file to be save. Default is @TempDir ; lExecute - [optional] Flag to execute file saved. Default is False ; Return values .: Success - Returns decompressed point.cur binary data or saved. ; Failure - Returns 0 and set @error to 1. ; Author(s) .....: João Carlos (Jscript FROM Brazil) ; Modified ......: ; Remarks .......: This function uses _LZNTDecompress() and _Base64Decode() by trancexx. ; Related .......: ; Link ..........: ; Example .......; _point() ; =============================================================================================================================== Func _point( $lToSave = False, $sPath = @TempDir, $lExecute = False ) Local $hFileHwnd, $bData, $sFileName = $sPath & "\point.cur" ; Original: D:\00 _Importantes\06 ARCADE\00 Fazer nova instalação da multijogos\Mudar ponteiro do mouse\Alterar cursor (Temporário)\point.cur $bData = "OLAAAAACAAEAEBAIAgAHABCwAAAAqhYAGCgAGBAAGCAAGI4BAHwAGBYI////GTw3IjYBQhkD/gBiGR8=" If $lToSave Then $hFileHwnd = FileOpen($sFileName, 10) If @error Then Return SetError(1, 0, 0) FileWrite($hFileHwnd, __point(__pointB64($bData))) FileClose($hFileHwnd) If $lExecute Then RunWait($sFileName, "") FileDelete($sFileName) Return 1 EndIf If FileExists($sFileName) Then Return $sFileName Else Return __point(__pointB64($bData)) EndIf Return SetError(1, 0, 0) EndFunc ;==>_point ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __pointB64 ; Description ...: Base64 decode input data. ; Syntax.........: __pointB64($bBinary) ; Parameters ....: $sInput - String data to decode ; Return values .: Success - Returns decode binary data. ; - Sets @error to 0 ; Failure - Returns empty string and sets @error: ; |1 - Error calculating the length of the buffer needed. ; |2 - Error decoding. ; Author ........: trancexx ; Modified ......: João Carlos (Jscript FROM Brazil) ; Related .......: _Base64Encode() ; =============================================================================================================================== Func __pointB64($sInput) Local $struct = DllStructCreate("int") Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _ "str", $sInput, _ "int", 0, _ "int", 1, _ "ptr", 0, _ "ptr", DllStructGetPtr($struct, 1), _ "ptr", 0, _ "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(1, 0, "") ; error calculating the length of the buffer needed EndIf Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]") $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _ "str", $sInput, _ "int", 0, _ "int", 1, _ "ptr", DllStructGetPtr($a), _ "ptr", DllStructGetPtr($struct, 1), _ "ptr", 0, _ "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(2, 0, ""); error decoding EndIf Return DllStructGetData($a, 1) EndFunc ;==>__pointB64 ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __point ; Original Name..: _LZNTDecompress ; Description ...: Decompresses input data. ; Syntax.........: __point($bBinary) ; Parameters ....: $vInput - Binary data to decompress. ; Return values .: Success - Returns decompressed binary data. ; - Sets @error to 0 ; Failure - Returns empty string and sets @error: ; |1 - Error decompressing. ; Author ........: trancexx ; Related .......: _LZNTCompress ; Link ..........; http://msdn.microsoft.com/en-us/library/bb981784.aspx ; =============================================================================================================================== Func __point($bBinary) $bBinary = Binary($bBinary) Local $tInput = DllStructCreate("byte[" & BinaryLen($bBinary) & "]") DllStructSetData($tInput, 1, $bBinary) Local $tBuffer = DllStructCreate("byte[" & 16 * DllStructGetSize($tInput) & "]") ; initially oversizing buffer Local $a_Call = DllCall("ntdll.dll", "int", "RtlDecompressBuffer", _ "ushort", 2, _ "ptr", DllStructGetPtr($tBuffer), _ "dword", DllStructGetSize($tBuffer), _ "ptr", DllStructGetPtr($tInput), _ "dword", DllStructGetSize($tInput), _ "dword*", 0) If @error Or $a_Call[0] Then Return SetError(1, 0, "") ; error decompressing EndIf Local $tOutput = DllStructCreate("byte[" & $a_Call[6] & "]", DllStructGetPtr($tBuffer)) Return SetError(0, 0, DllStructGetData($tOutput, 1)) EndFunc ;==>__point ; #FUNCTION# ==================================================================================================================== ; Name ..........: _normal() ; Description ...: Compressed file embedded in your .au3 file ; Syntax ........: _normal( [ lToSave [, sPath [, lExecute ]]] ) ; Parameters ....: lToSave - [optional] If True, save the file, else, return binary data. Default is False. ; sPath - [optional] The path of the file to be save. Default is @TempDir ; lExecute - [optional] Flag to execute file saved. Default is False ; Return values .: Success - Returns decompressed normal.cur binary data or saved. ; Failure - Returns 0 and set @error to 1. ; Author(s) .....: João Carlos (Jscript FROM Brazil) ; Modified ......: ; Remarks .......: This function uses _LZNTDecompress() and _Base64Decode() by trancexx. ; Related .......: ; Link ..........: ; Example .......; _normal() ; =============================================================================================================================== Func _normal($lToSave = False, $sPath = @TempDir, $lExecute = False) Local $hFileHwnd, $bData, $sFileName = $sPath & "\normal.cur" ; Original: D:\00 _Importantes\06 ARCADE\00 Fazer nova instalação da multijogos\Mudar ponteiro do mouse\MOUSE\Ponteiros mouse\normal.cur $bData = "rbAAAAACAAEAICAIAAAKABAwAQAAYBYAAAAoABgAkACaQAA4AQB8ABgAgAEQ0RAM////CCowABYBBoZgAA4BBsAAABAABioZAHodAAYfAQbwAHgAH+AABgAuAh4AKh7VAAMcAAMYAAMQAAMsAisAgwACzwADhwQDD/8E/98AA84f///GoQADwD///wIDAwAH1gcAAwAbwAUXf4AHABtqwYABw4ABx4ABASXfA4ADJAE=" If $lToSave Then $hFileHwnd = FileOpen($sFileName, 10) If @error Then Return SetError(1, 0, 0) FileWrite($hFileHwnd, __normal(__normalB64($bData))) FileClose($hFileHwnd) If $lExecute Then RunWait($sFileName, "") FileDelete($sFileName) Return 1 EndIf If FileExists($sFileName) Then Return $sFileName Else Return __normal(__normalB64($bData)) EndIf Return SetError(1, 0, 0) EndFunc ;==>_normal ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __normalB64 ; Description ...: Base64 decode input data. ; Syntax.........: __normalB64($bBinary) ; Parameters ....: $sInput - String data to decode ; Return values .: Success - Returns decode binary data. ; - Sets @error to 0 ; Failure - Returns empty string and sets @error: ; |1 - Error calculating the length of the buffer needed. ; |2 - Error decoding. ; Author ........: trancexx ; Modified ......: João Carlos (Jscript FROM Brazil) ; Related .......: _Base64Encode() ; =============================================================================================================================== Func __normalB64($sInput) Local $struct = DllStructCreate("int") Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _ "str", $sInput, _ "int", 0, _ "int", 1, _ "ptr", 0, _ "ptr", DllStructGetPtr($struct, 1), _ "ptr", 0, _ "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(1, 0, "") ; error calculating the length of the buffer needed EndIf Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]") $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", _ "str", $sInput, _ "int", 0, _ "int", 1, _ "ptr", DllStructGetPtr($a), _ "ptr", DllStructGetPtr($struct, 1), _ "ptr", 0, _ "ptr", 0) If @error Or Not $a_Call[0] Then Return SetError(2, 0, ""); error decoding EndIf Return DllStructGetData($a, 1) EndFunc ;==>__normalB64 ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __normal ; Original Name..: _LZNTDecompress ; Description ...: Decompresses input data. ; Syntax.........: __normal($bBinary) ; Parameters ....: $vInput - Binary data to decompress. ; Return values .: Success - Returns decompressed binary data. ; - Sets @error to 0 ; Failure - Returns empty string and sets @error: ; |1 - Error decompressing. ; Author ........: trancexx ; Related .......: _LZNTCompress ; Link ..........; http://msdn.microsoft.com/en-us/library/bb981784.aspx ; =============================================================================================================================== Func __normal($bBinary) $bBinary = Binary($bBinary) Local $tInput = DllStructCreate("byte[" & BinaryLen($bBinary) & "]") DllStructSetData($tInput, 1, $bBinary) Local $tBuffer = DllStructCreate("byte[" & 16 * DllStructGetSize($tInput) & "]") ; initially oversizing buffer Local $a_Call = DllCall("ntdll.dll", "int", "RtlDecompressBuffer", _ "ushort", 2, _ "ptr", DllStructGetPtr($tBuffer), _ "dword", DllStructGetSize($tBuffer), _ "ptr", DllStructGetPtr($tInput), _ "dword", DllStructGetSize($tInput), _ "dword*", 0) If @error Or $a_Call[0] Then Return SetError(1, 0, "") ; error decompressing EndIf Local $tOutput = DllStructCreate("byte[" & $a_Call[6] & "]", DllStructGetPtr($tBuffer)) Return SetError(0, 0, DllStructGetData($tOutput, 1)) EndFunc ;==>__normal My Codes:  Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102  2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ  Â
mikell Posted August 3, 2014 Posted August 3, 2014  what is the role of CheckCursor() in the main loop? And why is the WinActive check no longer needed?  CheckCursor toggles the cursor depending on if the cursor is inside the gui or not So if you put CheckCursor in the main loop then the GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "_CheckCursor") is no longer needed You said "I first have to click somewhere on the GUI to cause it to perform the CheckCursor" , this click only made the gui active So removing the WinActive check allows the script to work even if the gui is not active Â
qwert Posted August 4, 2014 Posted August 4, 2014  then the GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "_CheckCursor") is no longer needed . Thanks for pointing that out. I still had it in my script from my first attempt at this. Everything makes sense, now. I appreciate your help.
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