Jump to content
Sign in to follow this  
Zedna

Resources UDF

Recommended Posts

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 :)


My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game :)My website

Share this post


Link to post
Share on other sites

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\

Share this post


Link to post
Share on other sites

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 :D

; 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 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

Share this post


Link to post
Share on other sites

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)
EndFunc

Or, 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

Share this post


Link to post
Share on other sites

@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]

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

You can't use it this way.

$oIE.document.body.background expects path to file on disk 

Share this post


Link to post
Share on other sites

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 ?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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"

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

For some reason this doesn't work for me. Its being really retarded and nothing is happening. I'm using

And 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 by Zedna

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...