Jump to content

Resources UDF


Zedna
 Share

Recommended Posts

resource_test_ie.au3:

#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, candleFlame.swf, 23, candle_swf_4, 0

test_1.html:

<html>
<body>
<FONT face="Verdana" size="2" color="#3366FF">Test <B>HTML</B> page with image.<br><br>
<object width="800" height="600">
<param name="movie" value="candle_swf_4">
</object>
<br>
<a href="test_html_2">test 2</a>
</body>
</html>
Link to comment
Share on other sites

test_1.html:

<html>
<body>
<FONT face="Verdana" size="2" color="#3366FF">Test <B>HTML</B> page with image.<br><br>
<object width="800" height="600">
<param name="movie" value="candle_swf_4">
</object>
<br>
<a href="test_html_2">test 2</a>
</body>
</html>
I tried several combinations and it looks like

<object width="800" height="600">

<param name="movie" value="candle_swf_4">

can't reference SWF directly from resources.

But I'm not sure about it. I just did combinations that I thougt can be possible without studying any IE/SWF object documentation.

So maybe somebody more clever can say some details about that.

Link to comment
Share on other sites

To make the Top GUI transparent, use just this:

http://www.autoitscript.com/forum/index.ph...indowattributes

#include "WinAPI_SetLayered.au3"
GUISetBkColor(0x121314)
_WinAPI_SetLayeredWindowAttributes($transparent_gui, 0x121314)

-> No image needed

//Edit: And yes, you have to call _GDIPlus_ImageDispose ;)

can u show where should i change in this script. i've read http://www.autoitscript.com/forum/index.ph...indowattributes and try but dont know where should i change if i use a script from lorden

#NoTrayIcon
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <GUIConstantsEx.au3>
#Include <GDIPlus.au3>; this is where the magic happens, people
;#include <GuiComboBox.au3>
#Include <File.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
;Opt("MustDeclareVars", 0)

Global Const $AC_SRC_ALPHA = 1
;Global Const $ULW_ALPHA = 2
Global $old_string = "", $runthis = ""
Global $launchDir = @DesktopDir

; Load PNG file as GDI bitmap
_GDIPlus_Startup()
$pngSrc = @ScriptDir & "\test.png"
$hImage = _GDIPlus_ImageLoadFromFile($pngSrc)

; Extract image width and height from PNG
$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)

; Create layered window
$GUI = GUICreate("lod3n launcher", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
SetBitmap($GUI, $hImage, 0)
; Register notification messages
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState()
WinSetOnTop($GUI, "", 1)
;fade in png background
For $i = 0 To 255 Step 1    ; The higher the Step the faster the fade in
    SetBitmap($GUI, $hImage, $i)
Next


; create child MDI gui window to hold controls
; this part could use some work - there is some flicker sometimes...
$controlGui = GUICreate("ControlGUI", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI)

; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and
; I think the way this works is the transparent window color is based on the image you set here:
GUICtrlCreatePic(@ScriptDir & "\grey.gif", 0, 0, $width, $height)
GUICtrlSetState(-1, $GUI_DISABLE)

; just a text label
GUICtrlCreateLabel("Test press escape to quit...", 100, 112, 240, 150)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0x808080)

GUISetState()

;Loop that keeps the GUI running until pressed ESC
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop

    EndSelect
WEnd
AdlibDisable()

GUIDelete($controlGui)
;fade out png background
For $i = 255 To 0 Step - 1      ; The higher the Step, the faster the fade out
    SetBitmap($GUI, $hImage, $i)
Next

; Release resources
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()

;===================================================================================================



; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
;===================================================================================================




Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc ;==>WM_NCHITTEST

;===================================================================================================



; SetBitMap
;===================================================================================================




Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc ;==>SetBitmap

; I don't like AutoIt's built in ShellExec. I'd rather do the DLL call myself.
Func _ShellExecute($sCmd, $sArg = "", $sFolder = "", $rState = @SW_SHOWNORMAL)
    $aRet = DllCall("shell32.dll", "long", "ShellExecute", _
            "hwnd", 0, _
            "string", "", _
            "string", $sCmd, _
            "string", $sArg, _
            "string", $sFolder, _
            "int", $rState)
    If @error Then Return 0

    $RetVal = $aRet[0]
    If $RetVal > 32 Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc ;==>_ShellExecute
Thanks
Link to comment
Share on other sites

heya, i updated my autoit from 3.2.10.0 to 3.2.12.1 today and when i compiled my script with an embed bitmap and ur udf, it doesnt show the bitmap anymore... someone knows a solution? didnt changed anything else except the update

edit: the example doesnt work aswell anymore

Edited by nuki
Link to comment
Share on other sites

heya, i updated my autoit from 3.2.10.0 to 3.2.12.1 today and when i compiled my script with an embed bitmap and ur udf, it doesnt show the bitmap anymore... someone knows a solution? didnt changed anything else except the update

edit: the example doesnt work aswell anymore

On my AutoIt 3.2.12.1 all works fine (without any changes after update from 3.2.10).

Check if reshacker.exe is in "C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\" and in script directory or Windows search PATH directory.

Also check if output EXE contains all desired resources (by reshacker.exe)

EDIT: Or you may use ABSOLUTE path in #AutoIt3Wrapper_run_after directive:

#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, image1.bmp, bitmap, TEST_BMP_1, 0

#AutoIt3Wrapper_run_after=c:\your_path\ResHacker.exe -add %out%, %out%, image1.bmp, bitmap, TEST_BMP_1, 0
Edited by Zedna
Link to comment
Share on other sites

On my AutoIt 3.2.12.1 all works fine (without any changes after update from 3.2.10).

Check if reshacker.exe is in "C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\" and in script directory or Windows search PATH directory.

Also check if output EXE contains all desired resources (by reshacker.exe)

EDIT: Or you may use ABSOLUTE path in #AutoIt3Wrapper_run_after directive:

#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, image1.bmp, bitmap, TEST_BMP_1, 0

#AutoIt3Wrapper_run_after=c:\your_path\ResHacker.exe -add %out%, %out%, image1.bmp, bitmap, TEST_BMP_1, 0
Works just fine for me too.

path should be placed inside quotation marks

Edited by trancexx
Link to comment
Share on other sites

thanks for the fast response, i tried ur thing but till today i was using this one:

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=colorscale.exe
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_File_Add=colorscale.bmp, bitmap, colorscale
#AutoIt3Wrapper_Run_After="c:\Programme\AutoIt3\Aut2Exe\upx.exe" --best "%out%"
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****

and it worked fine for me until today, urs doesnt change anything, i put the reshacker files in the script directory too and tried ur absolute path but nothing works ;)

sorry guys i was annoying :S found the solution thanks to trancexx....

#AutoIt3Wrapper_run_after="C:\Dokumente und Einstellungen\Marvin\Desktop\colorscale\ResHacker.exe" -add %out%, %out%, colorscale.bmp, bitmap, colorscale, 0

was finally working after i set the " " around the reshacker path =)

now i can finally go on ._. thanks alot really both of u =)

Edited by nuki
Link to comment
Share on other sites

#AutoIt3Wrapper_Res_File_Add=colorscale.bmp, bitmap, colorscale

This was source of problem. In old Scite4AutoIt3 (AutoIt3Wrapper) it worked fine

but in latest version it has bug. See my first post about that.

You must use:

#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, image1.bmp, bitmap, TEST_BMP_1, 0
Link to comment
Share on other sites

  • 2 weeks later...

can someone please show me a example of a way to extract resources from a file, BUT with the original resource names?

the extraction is not a real problem, but keeping the real name of teh resource, e.g resource is bitmap, and is called testimage.

that would extract to testimage.bmp...

i cant seem to get my brain wrapped around it :S

thanx in advance guys.

Damian666

and proud of it!!!
Link to comment
Share on other sites

can someone please show me a example of a way to extract resources from a file, BUT with the original resource names?

the extraction is not a real problem, but keeping the real name of teh resource, e.g resource is bitmap, and is called testimage.

that would extract to testimage.bmp...

i cant seem to get my brain wrapped around it :S

thanx in advance guys.

Damian666

If you are refering to function _ResourceSaveToFile() then destination file name is something that you choose of.

If you want something to be called testimage.bmp than call it. Resource name 'rules' are the same.

Link to comment
Share on other sites

yeah, i know... but i want it to extract the resources by the names in which they are stored in the dll itself.

so i dont have to check every file for the names.

Damian666

Look at EnumResourceNames API at MSDN

and search also this forum, for example here:

http://www.autoitscript.com/forum/index.ph...st&p=541666

Edited by Zedna
Link to comment
Share on other sites

  • 4 weeks later...

Is it possible to add icons? In one of Zedna's previous posts it mentions that Icons should be able to be called using GUICtrlSetImage, but I tried using the following:

#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, %scriptdir%\Iconname.ico, rcdata, IconName, 0

$GUI_LBLICON1 = GUICtrlCreateIcon('',-1, 10, 10, 32, 32)
_ResourceSetImageToCtrl($GUI_LBLICON1, IconName)

But unfortunately nothing happens, if I use the an image rather than an icon it works fine, for example:

#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, %scriptdir%\Iconname.jpg, rcdata, IconName, 0

$GUI_LBLICON1 = GUICtrlCreatePic('', 10, 10, 32, 32)
_ResourceSetImageToCtrl($GUI_LBLICON1, IconName)

But I'd prefer it if I could use just an icon rather than extracting the image from the icon each time, I assume that it is something that I've done incorrectly, or maybe I got the wrong end of the stick and it doesn't support icons in this manner. So I suppose the question is, is what I'm suggesting possible? and if yes is possible for an example with the correct syntax?

Cheers

Link to comment
Share on other sites

Is it possible to add icons? In one of Zedna's previous posts it mentions that Icons should be able to be called using GUICtrlSetImage, but I tried using the following:

For icons you don't need my resource UDF.

You can use:

#AutoIt3Wrapper_icon=main_app_icon.ico

#AutoIt3Wrapper_Res_Icon_Add=first_icon.ico

#AutoIt3Wrapper_Res_Icon_Add=second_icon.ico

Later for example:

TraySetIcon(@ScriptFullPath, -5)

TraySetIcon(@ScriptFullPath, -6)

Look at helpfile/example for AutoIt3Wrapper

Link to comment
Share on other sites

Hi Zedna

Thanks so much for the reply, never actually realise that AutoITWrapper had a help file so thanks for the pointer, works like a charm, not sure if I should ask here or create a new post, but do you know of any way of checking that a resource exists like icons, images etc.. within the compiled executable. So say for instance:

#AutoIt3Wrapper_icon=Primary.ico
#AutoIt3Wrapper_Res_Icon_Add=Secondary.ico

$GUI_LBLICON1 = GUICtrlCreateIcon(@ScriptFullPath, -5, 10, 10, 32, 32)

So if -5 didn't exist it would default to -1, the script I'm building is basically a Software Wrapper for installing products via SMS, I'm attempting to use a single Executable against multiple installers, of course the easiest method is to ensure that "Secondary.ico" but out of interest would like to know if this was possible.

Anyway thanks again for your help, much appreciated.

Cheers

Link to comment
Share on other sites

Very nice Zedna!

This is a lot better than FileInstall() which is outdated and in major need of an overhaul.

But there's an issue at hand.. I don't have AutoIt, or Scite4AutoIt installed on my machine, AutoIt it is located in C:\Portables\AutoIt and Scite4AutoIt is in C:\Portables\AutoIt\Scite4AutoIt. I copied reshacker.exe and upx.exe to the path C:\Portables\AutoIt\Scite4AutoIt\AutoIt3Wrapper and in C:\Windows

I use the directives

#AutoIt3Wrapper_run_after=Reshacker.exe -add %out%, %out%, %scriptdir%\Readme.txt, rcdata, README_TXT, 0
#AutoIt3Wrapper_Run_After=upx.exe" --best --compress-resources=1 "%out%"

and I get this..

'Reshacker.exe' is not recognized as an internal or external command,
operable program or batch file.

'upx.exe' is not recognized as an internal or external command,
operable program or batch file.

If I use full paths..

#AutoIt3Wrapper_run_after="C:\Portables\AutoIt\Scite4AutoIt\Scite4AutoIt\Reshacker.exe" -add %out%, %out%, %scriptdir%\Readme.txt, rcdata, README_TXT, 0
#AutoIt3Wrapper_Run_After="C:\Portables\AutoIt\Scite4AutoIt\Scite4AutoIt\upx.exe" --best --compress-resources=1 "%out%"

It works.. but If I use

%scitedir% = SciTE program directory

#AutoIt3Wrapper_run_after="%scitedir%\Reshacker.exe" -add %out%, %out%, %scriptdir%\Docs\Readme.txt, rcdata, README_TXT, 0
#AutoIt3Wrapper_Run_After="%scitedir%\upx.exe" --best --compress-resources=1 "%out%"

This also fails. :P

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...