Zedna Posted May 17, 2008 Author Posted May 17, 2008 Quick question,When installing Resource hacker and AutoIT3Wrapper, where should i place them so they work correctly?This is a great UDF and once i've gotten the above issue solved i'll be sure to use it AutoIT3Wrapper is part of Scite4AutoIt3 package. It installs into "c:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\" directory by default. On my computer I put ResHacker.exe into AutoIt3Wrapper directory and also into some "Windows search path" directory (or in some dir listed in PATH env) for example C:\Windows\ Resources UDF ResourcesEx UDF AutoIt Forum Search
ProgAndy Posted May 17, 2008 Posted May 17, 2008 (edited) An other function to load the image from resource to use it with GDIplus, I think with transparency CODE;=============================================================================== ; ; Function Name: _ResourceGetImageToGDIPImage( ; Description:: Loads the Image into GDIplus-Image, Transparency should be used ; Parameter(s): ResourceName, ResourceType, Optional Dll-Filename to Load from ; Requirement(s): Resources.au3 with Dll extension ; Return Value(s): GDIP-Image Handle ; Author(s): Prog@ndy, from _ResourceSetImageToCtrl() ; ; Remarks: Needs _GDIplus_StartUP() before call ; ;=============================================================================== ; Func _ResourceGetImageToGDIPImage($ResName, $ResType = 10,$DLL=-1); $RT_RCDATA = 10 Local $ResData, $nSize, $hData, $pData, $pStream, $pBitmap, $hBitmap $ResData = _ResourceGet($ResName, $ResType,0,$DLL) If @error Then Return SetError(1, 0, 0) $nSize = @extended ; thanks ProgAndy $hData = _MemGlobalAlloc($nSize,2) $pData = _MemGlobalLock($hData) _MemMoveMemory($ResData,$pData,$nSize) _MemGlobalUnlock($hData) $pStream = DllCall( "ole32.dll","int","CreateStreamOnHGlobal", "int",$hData, "long",1, "Int*",0) $pStream = $pStream[3] $pBitmap = DllCall($ghGDIPDll,"int","GdipCreateBitmapFromStream", "ptr",$pStream, "int*",0) $pBitmap = $pBitmap[2] _WinAPI_DeleteObject($pStream) _MemGlobalFree($hData) Return $pBitmap EndFunc Edited May 17, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
Zedna Posted May 17, 2008 Author Posted May 17, 2008 An other function to load the image from resource to use it with GDIplus, I think with transparency Good idea! Thanks again.It returns "hImage". I will add this into my UDF too. Resources UDF ResourcesEx UDF AutoIt Forum Search
slayerz Posted June 16, 2008 Posted June 16, 2008 @ProgAndy Is it possible to play wav files from dll file? AUTOIT[sup] I'm lovin' it![/sup]
Zedna Posted June 16, 2008 Author Posted June 16, 2008 Is it possible to play wav files from dll file?Yes. Concept:- load WAV from DLL to memory- use PlaySound from winmm.dll with $SND_MEMORY instead of $SND_RESOURCE Resources UDF ResourcesEx UDF AutoIt Forum Search
ProgAndy Posted June 17, 2008 Posted June 17, 2008 It works with $SND_RESOURCE, too :Global Const $SND_RESOURCE = 0x00040004 ; ( REsource saved as WAVE Resource, name = WAV1 ) _ResourcePlaySound("WAV1",0,@ScriptDir&"\Resource.dll") ; thanks Larry ; MSDN: http://msdn2.microsoft.com/en-us/library/ms712879.aspx ; default flag is $SND_SYNC = 0 Func _ResourcePlaySound($ResName, $Flag = 0,$DLL=-1) If $DLL == -1 Then $hInstance = 0 Else $hInstance = DllCall("kernel32.dll","int","LoadLibrary","str",$DLL) EndIf $hInstance = $hInstance[0] Local $ret = DllCall("winmm.dll", "int", "PlaySound", "str", $ResName, "hwnd", $hInstance, "int", BitOr($SND_RESOURCE,$Flag)) If @error Then Return SetError(1, 0, 0) Return $ret[0] If $DLL <> -1 Then DllCall("Kernel32.dll","int","FreeLibrary","str",$hInstance) EndFuncOr, the other way: http://msdn.microsoft.com/en-us/library/ms712876(VS.85).aspx *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
Zedna Posted June 17, 2008 Author Posted June 17, 2008 It works with $SND_RESOURCE, too : ... Or, the other way: http://msdn.microsoft.com/en-us/library/ms712876(VS.85).aspx The other way is the same concept as I meant. This week I will probably release new version of my UDF with all above aditions - thanks ProgAndy. Resources UDF ResourcesEx UDF AutoIt Forum Search
slayerz Posted June 18, 2008 Posted June 18, 2008 @Zedna @ProgAndy Thanks to you both...It's what I'm looking for....Now my GUI looks more interactive. Again, thanks AUTOIT[sup] I'm lovin' it![/sup]
Zedna Posted June 25, 2008 Author Posted June 25, 2008 Updated first post. 2008-06-25 - big thanks to ProgAndy for ideas,improvements! - added _ResourceGetAsImage(), _ResourceGetAsBitmap() - added optional $DLL parameter to all functions - for loading resources from external EXE,DLL files - fixed previous limitation in _ResourceSaveToFile() - now supports also RT_BITMAP type - new examples in resource_test.au3 Resources UDF ResourcesEx UDF AutoIt Forum Search
badzox Posted July 3, 2008 Posted July 3, 2008 Hi everybody, i need some help.. I´ try to view an animated Gif in an compiled script. I tried this Code. CODE#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, test.gif, rcdata, TEST, 0 ;#AutoIt3Wrapper_Run_After=upx.exe --best "%out% #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include "resources.au3" #include <IE.au3> Local $gui, $sFile, $pic1, $oIE, $GUIActiveX $gui = GUICreate("Test", 425, 188, 235, 218) $pic1 = GUICtrlCreatePic("",0,0,48,48) ;Local $sFile = "c:\temp\test.gif" $oIE = ObjCreate("Shell.Explorer.2") $GUIActiveX = GUICtrlCreateObj($oIE, 344, 8, 48, 48) $oIE.navigate("about:blank") While _IEPropertyGet($oIE, "busy") Sleep(100) WEnd $oIE.document.body.background = $sFile $oIE.document.body.scroll = "no" GUISetState(@SW_SHOW) msgbox (0,"Test","before") _ResourceSetImageToCtrl($pic1, "TEST") ;<-- This works, but only as static gif msgbox (0,"Test","after") _ResourceSetImageToCtrl($oIE.document.body.background, "TEST") ; This doesn´t work <- Why ?? What' wrong? While 1 If GUIGetMsg() = -3 Then Exit WEnd What is wrong ?? I searched for a solution, perhaps i´m blind.. Hopefully you folks can help.
Zedna Posted July 3, 2008 Author Posted July 3, 2008 Hi everybody,i need some help.. I´ try to view an animated Gif in an compiled script. I tried this Code. CODE#Region ;**** Directives created by AutoIt3Wrapper_GUI ****#AutoIt3Wrapper_UseUpx=n#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, test.gif, rcdata, TEST, 0;#AutoIt3Wrapper_Run_After=upx.exe --best "%out%#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****#include "resources.au3"#include <IE.au3>Local $gui, $sFile, $pic1, $oIE, $GUIActiveX$gui = GUICreate("Test", 425, 188, 235, 218)$pic1 = GUICtrlCreatePic("",0,0,48,48);Local $sFile = "c:\temp\test.gif"$oIE = ObjCreate("Shell.Explorer.2")$GUIActiveX = GUICtrlCreateObj($oIE, 344, 8, 48, 48)$oIE.navigate("about:blank")While _IEPropertyGet($oIE, "busy") Sleep(100)WEnd $oIE.document.body.background = $sFile $oIE.document.body.scroll = "no"GUISetState(@SW_SHOW)msgbox (0,"Test","before")_ResourceSetImageToCtrl($pic1, "TEST") ;<-- This works, but only as static gifmsgbox (0,"Test","after")_ResourceSetImageToCtrl($oIE.document.body.background, "TEST") ; This doesn´t work <- Why ?? What' wrong?While 1 If GUIGetMsg() = -3 Then ExitWEndWhat is wrong ?? I searched for a solution, perhaps i´m blind.. Hopefully you folks can help.You can't use it this way. $oIE.document.body.background expects path to file on disk Resources UDF ResourcesEx UDF AutoIt Forum Search
badzox Posted July 3, 2008 Posted July 3, 2008 Hi Zedna, thx for reply. How can i solve this ?? As i wrote before I want to display an embedded animated gif.. Can you give an example ?
Zedna Posted July 3, 2008 Author Posted July 3, 2008 Hi Zedna,thx for reply. How can i solve this ?? As i wrote before I want to display an embedded animated gif.. Can you give an example ?I don't know how to do it directly without temporary file.So use FileInstall() or my _ResourceSaveToFile().You will have only one EXE with embeded GIF and at runtime it will create temporary file on disk and will use it. Finally you can delete this temporary file. Resources UDF ResourcesEx UDF AutoIt Forum Search
badzox Posted July 3, 2008 Posted July 3, 2008 ok, i thought i would be possible with your UDF. i will use FileInstall. Perhaps this could be a nice addon for further version of your udf.
Zedna Posted July 3, 2008 Author Posted July 3, 2008 ok, i thought i would be possible with your UDF. i will use FileInstall. Perhaps this could be a nice addon for further version of your udf. See my first post! I tested my resource_test_ie.au3 - example script for using HTML resources with embeded IE COM object (without using UDF) It works fine also with animated GIF images but only with $oIE.navigate("res://" & @AutoItExe & "/test_gif_1") This is not working: $oIE.document.body.background = "res://" & @AutoItExe & "/test_gif_1" Resources UDF ResourcesEx UDF AutoIt Forum Search
Mattraks Posted July 6, 2008 Posted July 6, 2008 For some reason this doesn't work for me. Its being really retarded and nothing is happening. I'm using #AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, login.jpg, rcdata, LOGIN, 0oÝ÷ Ø Ý":`ȧ¶¢W^®íë®*mjwl¢+zÁÚrG«{ÒÊ!j÷+ºÚ"µÍÌÍÓÙÚ[ÔXÈHÕRPÝÜX]TXÊ ][ÝÉ][ÝËLL BÔÛÝÙTÙ][XYÙUÐÝ ÌÍÓÙÚ[ÔXË ][ÝÓÑÒS][ÝÊ And yea. Nothing shows up on the GUI i made.
Zedna Posted July 6, 2008 Author Posted July 6, 2008 (edited) For some reason this doesn't work for me. Its being really retarded and nothing is happening. I'm usingAnd yea. Nothing shows up on the GUI i made.Try to compile/run my original examples first. Also post whole related code.Are you using #AutoIt3Wrapper_useupx=n?Also check by reshacker tool output compiled EXE file if your LOGIN JPEG resource is inside EXE.EDIT:Also try to put ResHacker.exe into AutoIt3Wrapper directory or into some directory which is in "Windows search path". Edited July 6, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
quagmire1973 Posted July 7, 2008 Posted July 7, 2008 Hey there. I'm trying to use this to embed an image into a command button. I think I have an understanding of how it works with exe/bmp files for their own controls, but how do I set the loaded resources to display on a command button? When I compile it, I end up with a giant button (as I should) but no image associated with it. Here's the sample code I have that I tried based on your sample. This is just a generic test sample to try and see how it all works. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, image1.bmp, bitmap, TEST_BMP_1, 0 #AutoIt3Wrapper_Run_After=upx.exe --best --compress-resources|0 "%out%" #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include "resources.au3" #include <GUIConstants.au3> $gui = GUICreate("Data from resources example",820,400) $pic1 = GUICtrlCreatebutton("",0,0,400,300,$BS_BITMAP) GUISetState(@SW_SHOW) ; set BMP image to picture control from resource bitmap _ResourceSetImageToCtrl($pic1, "TEST_BMP_1", $BS_BITMAP) while 1 WEnd Any help is appreciated.
Zedna Posted July 7, 2008 Author Posted July 7, 2008 Hey there.I'm trying to use this to embed an image into a command button. I think I have an understanding of how it works with exe/bmp files for their own controls, but how do I set the loaded resources to display on a command button? When I compile it, I end up with a giant button (as I should) but no image associated with it.Here's the sample code I have that I tried based on your sample. This is just a generic test sample to try and see how it all works.Any help is appreciated.Read carefully whole my first post!!!There is mentioned it works only with static controls (no buttons).This is limitation of Windows STM_SETIMAGE message used for setting image to control. Resources UDF ResourcesEx UDF AutoIt Forum Search
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