AndyS19 Posted September 5, 2017 Share Posted September 5, 2017 I need help embedding cursor images in a compiled exe file. I tried several #AutoIt3Wrapper definitions, but I could not figure out how to use the embedded cursor image to change the visible cursor. Here is my test code (modified, from the SciTE help file): expandcollapse popup; Add icons to the file resource table ; As no resource names are specified, they will be set automatically to 201+ #AutoIt3Wrapper_Res_Icon_Add=C:\Program Files\AutoIt3\Icons\MyAutoIt3_Blue.ico #AutoIt3Wrapper_Res_Icon_Add=C:\Program Files\AutoIt3\Icons\MyAutoIt3_Red.ico #AutoIt3Wrapper_Res_Icon_Add=C:\Program Files\AutoIt3\Examples\Helpfile\Extras\Lens.cur #AutoIt3Wrapper_Res_Icon_Add=C:\Windows\Cursors\up_il.cur _Main() Func _Main() Local $str, $hGUI, $cButton, $cLabel, $rc2 ; Create the GUI $hGUI = GUICreate("Demo icon resources") $cButton = GUICtrlCreateButton("", 10, 10, 40, 40, 0x0040) ; 0x0040 Specifies that the button displays an icon $cLabel = GUICtrlCreateLabel("", 70, 25, 200, 20) GUISetState(@SW_SHOW, $hGUI) For $x = 201 To 204 ; Run through the added icons in the resource table $rc2 = GUICtrlSetImage($cButton, @ScriptFullPath, $x) ; Change the icon in the button GUICtrlSetData($cLabel, "Icon Name: " & $x) $str = "Added icon: " & $x & ", GUICtrlSetImage rc2: " & $rc2 logMsg($str) ; TBD ... set the cursor from image embedded in the exe file Sleep(2000) ; Allow time for icon/cursor to be seen Next ; Delete the GUI GUIDelete($hGUI) EndFunc ;==>_Main Func logMsg($msg, $lnum = @ScriptLineNumber) ConsoleWrite("+++:" & $lnum & ": " & $msg & @CRLF) EndFunc ;==>logMsg Link to comment Share on other sites More sharing options...
UEZ Posted September 5, 2017 Share Posted September 5, 2017 Try 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
AndyS19 Posted September 5, 2017 Author Share Posted September 5, 2017 That's creating them in memory. I have 2 .cur files and I want to embed them in the exe file. Link to comment Share on other sites More sharing options...
UEZ Posted September 6, 2017 Share Posted September 6, 2017 (edited) 10 hours ago, AndyS19 said: That's creating them in memory. I have 2 .cur files and I want to embed them in the exe file. Yes, the cursor is loaded from the variable which is in the memory but did you compile the test script? Or just have a look to Edited September 6, 2017 by 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
AndyS19 Posted September 6, 2017 Author Share Posted September 6, 2017 I did compile it and the icon stuff worked, but I'm not sure how to set a cursor using embedded resources, so the test script isn't complete. That's what I need help with. Link to comment Share on other sites More sharing options...
AndyS19 Posted September 7, 2017 Author Share Posted September 7, 2017 OK, I used Zedna's UDF code and it worked. Here's my working test code: expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Res_File_Add=%AUTOITDIR%\Examples\Helpfile\Extras\horse.ani, RT_ANICURSOR, ANI_CUR_1 #include <ResourcesEX.au3> ; Improved by guinness. Opt("GUICloseOnESC", 1) ; ESC closes GUI? (0 = no, 1 = yes) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Opt('MustDeclareVars', 1) OnAutoItExitRegister("ExitStageLeft") Opt("GUIEventOptions", 1) ;0=default, 1=just notification, 2=GuiCtrlRead tab index Opt("WinTitleMatchMode", -2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Global $g_hCursor, $g_hGUI, $iLoadCursor _Main() Func _Main() Local $str, $cButton, $cLabel, $rc2 #forceref $str, $cButton, $cLabel, $rc2, $iLoadCursor ; Create the GUI $g_hGUI = GUICreate("Demo icon resources") $cButton = GUICtrlCreateButton("", 10, 10, 40, 40, 0x0040) ; 0x0040 Specifies that the button displays an icon $cLabel = GUICtrlCreateLabel("", 70, 25, 200, 20) $iLoadCursor = GUICtrlCreateButton('Load Cursor', 10, 125, 85, 25) GUICtrlSetOnEvent($iLoadCursor, "handle_btn") logMsg("+++: $iLoadCursor = " & $iLoadCursor) GUISetOnEvent(-3, 'ExitStageLeft') GUISetState(@SW_SHOW, $g_hGUI) While 1 Sleep(27) WEnd GUIDelete($g_hGUI) ; Delete the GUI ExitStageLeft() EndFunc ;==>_Main Func ExitStageLeft() logMsg("+++: DONE ...") Exit EndFunc ;==>ExitStageLeft Func handle_btn() logMsg("+++: handle_btn() entered") $g_hCursor = _Resource_GetAsCursor('ANI_CUR_1', $RT_ANICURSOR) If ($g_hCursor) Then _WinAPI_SetCursor($g_hCursor) Else Local $err = @error MsgBox(0, "ERROR", "Error loading cursor resource. @error = " & $err) EndIf EndFunc ;==>handle_btn Func logMsg($msg, $lnum = @ScriptLineNumber) #forceref $lnum, $msg ConsoleWrite("+++:" & $lnum & ": " & $msg & @CRLF) EndFunc ;==>logMsg Thank you. Link to comment Share on other sites More sharing options...
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