Jump to content

Resources UDF


Zedna
 Share

Recommended Posts

@Zedna,

i will use the original .. and make an exclusion in my script for windows 2000 machines .. it's not a necessary addon

I used an old version of the resources.au3 that's why i did not notice it before..

in your old version you called the _GDIPlus_Startup() in a function not a the start of the script

Emiel

Edited by Emiel Wieldraaijer

Best regards,Emiel Wieldraaijer

Link to comment
Share on other sites

hey i m creating a program which is supposed to be totally portable i.e. it should just be an exe nothing else

but this program needs an ini file as well which contains some important data which i want to embed as an resource

so while the program is runnin the needs to read & write the ini the store it inside the exe as a resource

so please try to give me some code snipplet to apply this concept

Link to comment
Share on other sites

hey i m creating a program which is supposed to be totally portable i.e. it should just be an exe nothing else

but this program needs an ini file as well which contains some important data which i want to embed as an resource

so while the program is runnin the needs to read & write the ini the store it inside the exe as a resource

so please try to give me some code snipplet to apply this concept

This is not simple.

Look at BeginUpdateResource,UpdateResource,EndUpdateResource API functions

Example of use is in: "C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\autoit3wrapper.au3" 

Notes:

- If you store values in INI stored inside resources then you can't use native IniRead/IniWrite functions.

- I'm not sure if you can update resources of current running EXE file (update EXE of current running process)

Edited by Zedna
Link to comment
Share on other sites

Look at BeginUpdateResource,UpdateResource,EndUpdateResource API functions

Example of use is in: "C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\autoit3wrapper.au3" 

is there any other way to achieve the same goal

i.e.

can i use fileinstall and then update the file and then again

store it inside the exe

and by the way my SciTE folder does not contain any directory name AutoIt3Wrapper

Link to comment
Share on other sites

This is not simple.

Look at BeginUpdateResource,UpdateResource,EndUpdateResource API functions

Example of use is in: "C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\autoit3wrapper.au3" 

Notes:

- If you store values in INI stored inside resources then you can't use native IniRead/IniWrite functions.

- I'm not sure if you can update resources of current running EXE file (update EXE of current running process)

I believe that the last sentence here explains it all.

When calling function "EndUpdateResource" what it does is it deletes the module (exe or dll) and writes another one with acummulated changes that are stored in temporary file by function "UpdateResource" after successful "BeginUpdateResource". Writing access cannot be gained if module is loaded, and if you are running it, it's loaded for sure.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

is there any other way to achieve the same goal

i.e.

can i use fileinstall and then update the file and then again

store it inside the exe

Yes.

- prepare default INI file

- include it in resources as RT_RCDATA (see my resource examples)

- at runtime save it to TEMP with my _ResourceSaveToFile()

- read/write to INI file in TEMP

- update resource by INI file from TEMP (UpdateResource API)

Notes:

- I'm not sure if you can update resources of current running EXE file (update EXE of current running process)

and by the way my SciTE folder does not contain any directory name AutoIt3Wrapper

Download latest Scite4AutoIt3 from here:

http://www.autoitscript.com/autoit3/scite/downloads.shtml

Edited by Zedna
Link to comment
Share on other sites

Hi Zedna,

When i use the following

#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, changelog.txt, rcdata, TEST_TXT_1, 0

#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, credits.txt, rcdata, TEST_TXT_2, 0

$Changelog = _ResourceGetAsStringW("TEST_TXT_1")

$Credits = _ResourceGetAsStringW("TEST_TXT_2")

The $credits is appended to the $changelog when used in GuiCtrlCreateEdit

Did i made a mistake ?

Thanx

Best regards,

Emiel

Best regards,Emiel Wieldraaijer

Link to comment
Share on other sites

Hi Zedna,

When i use the following

#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, changelog.txt, rcdata, TEST_TXT_1, 0

#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, credits.txt, rcdata, TEST_TXT_2, 0

$Changelog = _ResourceGetAsStringW("TEST_TXT_1")

$Credits = _ResourceGetAsStringW("TEST_TXT_2")

The $credits is appended to the $changelog when used in GuiCtrlCreateEdit

Did i made a mistake ?

Thanx

Best regards,

Emiel

Try this:

$Changelog = _ResourceGetAsStringW("TEST_TXT_1")
MsgBox(0,'Changelog',$Changelog)

$Credits = _ResourceGetAsStringW("TEST_TXT_2")
MsgBox(0,'Credits',$Credits)

Also post code yiou use for GuiCtrlCreateEdit

Edited by Zedna
Link to comment
Share on other sites

Hi Zedna,

i've attached a rar file with ... everything

i think the problem has some thing to do with large attachments

AutoIt version 3.2.12.2

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=TestResources.exe
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Add_Constants=n
#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, file1.txt, rcdata, TEST_TXT_1, 0
#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, file2.txt, rcdata, TEST_TXT_2, 0
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Tidy_Stop_onerror=n
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/striponly

#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion 
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include "Resources.au3"

$file1 = _ResourceGetAsStringW("TEST_TXT_1")
MsgBox(0, 'file1', $file1)

$file2 = _ResourceGetAsStringW("TEST_TXT_2")
MsgBox(0, 'file2', $file2)

Func _Readfile()
    $GUI = GUICreate("file1", 500, 300, -1, -1, $WS_SIZEBOX + $WS_SYSMENU + $WS_MAXIMIZEBOX) ; Resizeable
    GUISetIcon(@ScriptName)
    
    $Edit = GUICtrlCreateEdit("", 10, 10, 480, 205, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL, $ES_MULTILINE))
    GUICtrlSetLimit($Edit, FileGetSize($file1))
    GUICtrlSetData($Edit, $file1)

    GUICtrlSetResizing($Edit, $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT + $GUI_DOCKLEFT + $GUI_DOCKTOP)
    $OK = GUICtrlCreateButton("OK", 403, 230, 80, 20, BitOR($GUI_SS_DEFAULT_BUTTON, $BS_DEFPUSHBUTTON))
    GUICtrlSetResizing($OK, $GUI_DOCKBOTTOM + $GUI_DOCKSIZE + $GUI_DOCKRIGHT)
    GUISetState(@SW_SHOW, $GUI)
    
    While 2
        $Msg = GUIGetMsg()
        If $Msg = $GUI_EVENT_CLOSE Or $Msg = $OK Then
            ExitLoop
        EndIf
    WEnd
    GUIDelete($GUI)
EndFunc   ;==>_Readfile

_Readfile()

resources.rar

Best regards,Emiel Wieldraaijer

Link to comment
Share on other sites

Hi Zedna,

i've attached a rar file with ... everything

i think the problem has some thing to do with large attachments

AutoIt version 3.2.12.2

Yes. Seems to be realy problem.

I did some quick tests but no fix for now.

I will do some more tests and post results.

Edited by Zedna
Link to comment
Share on other sites

Hi!

How can I include a dll (BASS.dll) and a XM audio file (flx.xm)

I tried it by adding this:

#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, flx.xm, rcdata, FLX_XM, 0
#AutoIt3Wrapper_run_after=ResHacker.exe -add %out%, %out%, BASS.dll, rcdata, BASS_LIB, 0

#include "resources.au3"

;music to load
$file = "flx.xm"
_ResourceGet($file, "FLX_XM")

;Open Bass.DLL.  Required for all function calls.
$bass_dll = DllOpen("BASS.dll")
_ResourceGet($bass_dll, "BASS_LIB")

I tried to include a image, that did work. Including the dll and xm file doesnt.

Any pointers?

Thank you in advance,

FLX

Edited by flxfxp
Link to comment
Share on other sites

Hi!

How can I include a dll (BASS.dll) and a XM audio file (flx.xm)

I tried it by adding this:

I tried to include a image, that did work. Including the dll and xm file doesnt.

Any pointers?

Thank you in advance,

FLX

You can't load DLL directly from resources.

You must save it to disk first.

You can't play music other than WAV directly from resources.

You must save it to disk first.

Edited by Zedna
Link to comment
Share on other sites

Allright. But it can be contained within the exe right? I just can't directly use them from resources.

How do I save them to disk and delete them afterwards? Would you happen to have a example?

Your help is much appreciated.

Thank you in advance,

FLX

Link to comment
Share on other sites

Allright. But it can be contained within the exe right? I just can't directly use them from resources.

How do I save them to disk and delete them afterwards? Would you happen to have a example?

Your help is much appreciated.

Thank you in advance,

FLX

Use _ResourceSaveToFile() or FileInstall()

Example is in first post of this topic.

Link to comment
Share on other sites

  • 2 weeks later...

@Zedna,

i found a little problem

when adding an image.gif and use it as a background

The image is displayed perfect .. but when you minimize the GUI and maximize the GUI again..

#Region#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, image.gif, RCDATA, BACKGROUND, 0
#EndRegion

#include <GUIConstantsEx.au3>
#include <resources.au3>


$GUI1 = GUICreate("GUI", 560, 340)
_BG ()
GUISetState()

While 1
    $msg = GUIGetMsg()
    select
        Case $msg = 0
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
Wend

Func _BG ()
    ;$BGPIC = GUICtrlCreatePic("image.gif", 392, 155, 200, 165)
    $BGPic = GUICtrlCreatePic("", 392, 150, 200, 165)
    _ResourceSetImageToCtrl($BGPic, "BACKGROUND")
    GUICtrlSetState($BGPic, $GUI_DISABLE)
EndFunc

post-17051-1229378775_thumb.gif

Best regards,Emiel Wieldraaijer

Link to comment
Share on other sites

@Zedna,

i found a little problem

when adding an image.gif and use it as a background

The image is displayed perfect .. but when you minimize the GUI and maximize the GUI again..

I tested your example and it works fine, just use:

#Region
#AutoIt3Wrapper_UseUpx=n

instead of

#Region#AutoIt3Wrapper_UseUpx=n

EDIT:

OH! you are right! Restore after minimizing repaints image in some streched size

I don't know how to fix this because I use STM_SETIMAGE message which do all the job for me,

the rest of painting job does the AutoIt itself.

EDIT2:

I discovered source of problem:

STM_SETIMAGE assigns image to control in it's original size, but restore from minimized state is done in stretched way.

Note: GUICtrlCreatePic() without resources do all this in streched way

So quick fix for you is to use picture control's size the same as size of GIF image.

Edited by Zedna
Link to comment
Share on other sites

Or you use a label control... the pictures resizes itself until you set a new size with GUICtrlSetPos :)

*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

Link to comment
Share on other sites

@Zedna,

The first error with #region is a copy paste error

I will try EDIT2

EDIT

Using the real size of the image solves the problem .. thanks

@ProgAndy

Could you provide an example .. i don't fully understand wat you mean

Thanks to you both

Best regards,

Emiel

Edited by Emiel Wieldraaijer

Best regards,Emiel Wieldraaijer

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