Jump to content
Sign in to follow this  
Kiti

Including file in .exe

Recommended Posts

Kiti

Hi!

I want to include a picture in my compiled script. I read Zedna's resources UDF, but I just don't get it.

Here is my script:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <resources.au3>

Opt("GUIOnEventMode", 1)


$Form1 = GUICreate("Determinarea distantei focale a unei lentile", 422, 298)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")

$input1 = GUICtrlCreateInput("", 80, 32, 41, 21)

$input2 = GUICtrlCreateInput("", 80, 72, 41, 21)

$input3 = GUICtrlCreateInput("", 80, 112, 41, 21)

$input4 = GUICtrlCreateInput("", 80, 152, 41, 21)

$Button1 = GUICtrlCreateButton("Calculeaza!", 48, 224, 99, 33, 0)
GUICtrlSetOnEvent($Button1, "Button1Click")
$Label1 = GUICtrlCreateLabel("n1 =", 40, 32, 25, 17)

$Label2 = GUICtrlCreateLabel("n2 =", 40, 72, 25, 17)

$Label3 = GUICtrlCreateLabel("R1 =", 40, 112, 27, 17)

$Label4 = GUICtrlCreateLabel("R2 =", 40, 152, 27, 17)

$Label5 = GUICtrlCreateLabel("f=", 224, 224, 24, 36)
GUICtrlSetFont($Label5, 20, 400, 0, "MS Sans Serif")

$Label6 = GUICtrlCreateLabel("m", 128, 112, 12, 17)

$Label7 = GUICtrlCreateLabel("m", 128, 152, 12, 17)


$Label9 = GUICtrlCreateLabel("", 248, 224, 150, 36)
GUICtrlSetFont($Label9, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor($Label9, 0x000000)

$Label10 = GUICtrlCreateLabel("", 218, 254, 150, 36)
GUICtrlSetFont($Label10, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor($Label10, 0x000000)


GUICtrlCreatePic("C:\Users\Kiti\Desktop\o3.bmp", 164, 20, 230, 194); ----------------------------------look here!


GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Button1Click()

    $n1 = GUICtrlRead($input1)

    $n2 = GUICtrlRead($input2)

    $r1 = GUICtrlRead($input3)

    $r2 = GUICtrlRead($input4)

    $f = 1 / ((($n1 / $n2) - 1) * ((1 / $r1) - (1 / $r2)))

    If $n1 = $n2 Then
        MsgBox(64, "Eroare", "n1 si n2 trebuie sa aiba valori diferite!")
    ElseIf $r1 = $r2 Then
        MsgBox(64, "Eroare", "R1 si R2 trebuie sa aiba valori diferite!")
    Else
        GUICtrlSetData($Label9, MyFunc($f, 2) & " D")
    EndIf
    If $r1 <> $r2 And $n1 > $n2 Then

        GUICtrlSetData($Label10, "-lentila convergenta")
    Else
        GUICtrlSetData($Label10, "-lentila divergenta")
    EndIf

EndFunc   ;==>Button1Click

Func MyFunc($NUM, $DIGIT)
    If IsInt($NUM) Then
        Return $NUM
    Else
        $LEN = StringLen(String($NUM))
        $POINT = StringInStr(String($NUM), ".")
        Return StringLeft(String($NUM), $POINT + $DIGIT)
    EndIf
EndFunc   ;==>MyFunc



Func Form1Close()
    Exit 0
EndFunc   ;==>Form1Close

And my picture is this one: o3.bmp

Please edit my script in order to get that picture inside the .exe after I compile the script!

Thank you!

Share this post


Link to post
Share on other sites
Melba23

Kiti,

If you use the full SciTE4AutoIt3 package, add the following lines to the start of your script (you will of course need to change the ResHacker and upx paths to your own):

#AutoIt3Wrapper_UseUpx=n

#AutoIt3Wrapper_Run_After=M:\Program\ResHacker\ResHacker.exe -add %out%, %out%, C:\Users\Kiti\Desktop\o3.bmp, BITMAP, PIC, 0

#AutoIt3Wrapper_Run_After=M:\Program\UPX\upx.exe --best "%out%"

If you do not use the SciTE4AutoIt3 package (and why not - you are missing a lot!) then run ResHacker yourself and add the image to the compiled .exe without using upx beforehand.

Then in your script use these lines (or something pretty close to them):

$pic1 = GUICtrlCreatePic("", 164, 20, 230, 194)

_ResourceSetImageToCtrl($pic1, "PIC", $RT_BITMAP)

Do not forget to include the Resources.au3 file. ;-)

And to offer thanks to Zedna for his hard work.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Kiti

Hmm... it's not working ^_^

#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_After=C:\Users\Kiti\Desktop\ResHack\ResHacker.exe -add %out%, %out%, C:\Users\Kiti\Desktop\o3.bmp, BITMAP, PIC, 0
#AutoIt3Wrapper_Run_After=C:\Users\Kiti\Desktop\upx303w\upx303w\upx.exe --best "%out%"


#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <resources.au3>

Opt("GUIOnEventMode", 1)


$Form1 = GUICreate("Determinarea distantei focale a unei lentile", 422, 298)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")

$input1 = GUICtrlCreateInput("", 80, 32, 41, 21)

$input2 = GUICtrlCreateInput("", 80, 72, 41, 21)

$input3 = GUICtrlCreateInput("", 80, 112, 41, 21)

$input4 = GUICtrlCreateInput("", 80, 152, 41, 21)

$Button1 = GUICtrlCreateButton("Calculeaza!", 48, 224, 99, 33, 0)
GUICtrlSetOnEvent($Button1, "Button1Click")
$Label1 = GUICtrlCreateLabel("n1 =", 40, 32, 25, 17)

$Label2 = GUICtrlCreateLabel("n2 =", 40, 72, 25, 17)

$Label3 = GUICtrlCreateLabel("R1 =", 40, 112, 27, 17)

$Label4 = GUICtrlCreateLabel("R2 =", 40, 152, 27, 17)

$Label5 = GUICtrlCreateLabel("f=", 224, 224, 24, 36)
GUICtrlSetFont($Label5, 20, 400, 0, "MS Sans Serif")

$Label6 = GUICtrlCreateLabel("m", 128, 112, 12, 17)

$Label7 = GUICtrlCreateLabel("m", 128, 152, 12, 17)


$Label9 = GUICtrlCreateLabel("", 248, 224, 150, 36)
GUICtrlSetFont($Label9, 20, 800, 0, "MS Sans Serif")
GUICtrlSetColor($Label9, 0x000000)

$Label10 = GUICtrlCreateLabel("", 218, 254, 150, 36)
GUICtrlSetFont($Label10, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor($Label10, 0x000000)

$pic1 = GUICtrlCreatePic("", 164, 20, 230, 194)
_ResourceSetImageToCtrl($pic1, "PIC", $RT_BITMAP)


GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Button1Click()

    $n1 = GUICtrlRead($input1)

    $n2 = GUICtrlRead($input2)

    $r1 = GUICtrlRead($input3)

    $r2 = GUICtrlRead($input4)

    $f = 1 / ((($n1 / $n2) - 1) * ((1 / $r1) - (1 / $r2)))

    If $n1 = $n2 Then
        MsgBox(64, "Eroare", "n1 si n2 trebuie sa aiba valori diferite!")
    ElseIf $r1 = $r2 Then
        MsgBox(64, "Eroare", "R1 si R2 trebuie sa aiba valori diferite!")
    Else
        GUICtrlSetData($Label9, MyFunc($f, 2) & " D")
    EndIf
    If $r1 <> $r2 And $n1 > $n2 Then

        GUICtrlSetData($Label10, "-lentila convergenta")
    Else
        GUICtrlSetData($Label10, "-lentila divergenta")
    EndIf

EndFunc   ;==>Button1Click

Func MyFunc($NUM, $DIGIT)
    If IsInt($NUM) Then
        Return $NUM
    Else
        $LEN = StringLen(String($NUM))
        $POINT = StringInStr(String($NUM), ".")
        Return StringLeft(String($NUM), $POINT + $DIGIT)
    EndIf
EndFunc   ;==>MyFunc



Func Form1Close()
    Exit 0
EndFunc   ;==>Form1Close

I just compiled the script, but the image is not there.

Share this post


Link to post
Share on other sites
Kiti

>"D:\Aplicatii\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper_Gui.exe" /in "C:\Users\Kiti\Desktop\DDFL.au3"

+>21:54:58 Starting AutoIt3Wrapper GUI v.1.10.1.14

-> No changes made..

+>21:55:01 Starting AutoIt3Wrapper v.1.10.1.14 Environment(Language:0409 Keyboard:00020409 OS:WIN_VISTA/Service Pack 1 CPU:X86 ANSI)

>Running AU3Check (1.54.14.0) from:D:\Aplicatii\AutoIt3

+>21:55:01 AU3Check ended.rc:0

>Running:(3.3.0.0)^_^:\Aplicatii\AutoIt3\aut2exe\aut2exe.exe /in "C:\Users\Kiti\Desktop\DDFL.au3" /out "C:\Users\Kiti\Desktop\DDFL.exe" /comp 2 /nopack /Bin C:\Users\Kiti\AppData\Local\Temp\AutoItSC.bin

+>21:55:01 Aut2exe.exe ended.rc:0

+>21:55:01 Created program:C:\Users\Kiti\Desktop\DDFL.exe

->Warning: This is an Unicode compiled script and will not run on Win9x/ME.

>Running:C:\Users\Kiti\Desktop\ResHack\ResHacker.exe -add C:\Users\Kiti\Desktop\DDFL.exe, C:\Users\Kiti\Desktop\DDFL.exe, C:\Users\Kiti\Desktop\o3.bmp, BITMAP, PIC, 0

>C:\Users\Kiti\Desktop\ResHack\ResHacker.exe -add C:\Users\Kiti\Desktop\DDFL.exe, C:\Users\Kiti\Desktop\DDFL.exe, C:\Users\Kiti\Desktop\o3.bmp, BITMAP, PIC, 0 Ended rc:0

>Running:C:\Users\Kiti\Desktop\upx303w\upx303w\upx.exe --best "C:\Users\Kiti\Desktop\DDFL.exe"

Ultimate Packer for eXecutables

Copyright © 1996 - 2008

UPX 3.03w Markus Oberhumer, Laszlo Molnar & John Reiser Apr 27th 2008

File size Ratio Format Name

-------------------- ------ ----------- -----------

701267 -> 378195 53.93% win32/pe DDFL.exe

Packed 1 file.

>C:\Users\Kiti\Desktop\upx303w\upx303w\upx.exe --best "C:\Users\Kiti\Desktop\DDFL.exe" Ended rc:0

+>21:55:03 AutoIt3Wrapper Finished

>Exit code: 0 Time: 4.675

Share this post


Link to post
Share on other sites
Kiti

[22 apr. 2009, 21:55:02]

C:\Users\Kiti\Desktop\ResHack\ResHacker.exe -add C:\Users\Kiti\Desktop\DDFL.exe, C:\Users\Kiti\Desktop\DDFL.exe, C:\Users\Kiti\Desktop\o3.bmp, BITMAP, PIC, 0

Added: BITMAP,PIC,0

Commands completed

And still, there is no picture when I run the compiled version

Share this post


Link to post
Share on other sites
Melba23

Kiti,

I have just compiled your script and it worked perfectly - the bitmap was included and displayed without problem.

Can you see the PIC resource within your .exe if you use Reshacker on the file?

M23

Edited: Finger trouble!

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Kiti

Kiti,

I have just compiled your script and it worked perfectly - the bitmap was included and displayed without problem.

Can you see the PIC resource within your .exe if you use Reshacker on the file?

M23

Edited: Finger trouble!

Then just upload the .exe and I'll get the problem solved, maybe there is something wrong with my computer.

I *think* I can see the pic in there, it's a folder tree : Bitmap > Pic > 0. The "0" has a flower icon next to it and when I press it I get a message saying "The file has a non standard resource layout... it has probably been compressed with an "EXE Compressor". "

Edited by Kiti

Share this post


Link to post
Share on other sites
Melba23

Kiti,

There is something wrong with your bitmap file. Using my bitmap I have no problem, but yours gives me the "non standard resource layout" comment in ResHacker when the file is not compressed - and does not display. Have you done anything to the bitmap to render it non-standard? Try using a normal bitmap and see if the code works correctly.

M23

Edit: There is a problem with your bitmap - it is nowhere near standard. Resaving it as a standard bitmap makes it 367x254 and it displays perfectly, both in ResHacker and when you run the file. You need to open and resave the file into a standard format - and adjust the size of your GUI!

M23

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Kiti
Melba23

Kiti,

Words fail me............

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Melba23

Jos,

Only because the words I wanted to use would have caused you to ban me! ;-)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Kiti
Melba23

Kiti,

Do not worry - no-one died!

Seriously, you cannot change file extensions like that - bmps and jpgs are very different beasts!

Good luck with your coding!

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  

×