Sign in to follow this  
Followers 0
7ops

gui image

14 posts in this topic

Hi,

I havn't ever tried autoIt or any other programming language but somehow i managed to make a decent looking gui :whistle: and i was wondering, since i have an image on the gui that has to be from a seperate file, is there a way to make it into just 1 file?

thanks in advance

Share this post


Link to post
Share on other sites



do you mean when you compile the program?

Share this post


Link to post
Share on other sites

yeah

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi,

I havn't ever tried autoIt or any other programming language but somehow i managed to make a decent looking gui :whistle: and i was wondering, since i have an image on the gui that has to be from a seperate file, is there a way to make it into just 1 file?

thanks in advance

I don't think you can completely add the picture into your program. What I did is make a folder somewhere and then have a shortcut. I'm pretty sure that even if you make you program into an .exe (compile it) it still needs to have the pictures in the same folder...

Piano_Man

Edited by Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

Lookup FileInstall in the help file.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

ive made the program and everything with the image, its just the image is in a seperate file, in a jpeg, i ment can you make it so its actually inside it x.x

Share this post


Link to post
Share on other sites

If you use FileInstall and compile your script it will all be in one file.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

If you use FileInstall and compile your script it will all be in one file.

Ok, I'm trying to do the same thing here. The objective is simply to to

dispaly a picture in the GUI and compile to a file named experimental.exe

such that the picture file is included in the experimental.exe file so it

can be run on any computer. My questions are posed in the commented

code. --pete--

#include <GuiConstants.au3>

; Create the GUI, no problems here.
GuiCreate("Electronic Greeting Card", 650, 550)
;GuiSetIcon(@SystemDir & "\mspaint.exe", 0)

; Attempting to intall/include the picture file into the program file
; such that it can be compiled and run all in a single experimental.exe file.
FileInstall("d:\1public\Happy_Bd_Pete_2006.jpg", "D:\DatAutoIT\experimental.au3")

; Insert the Pictue file to the GUI

;Hmmm, this method below does not work. Just get a blank picture box.
GuiCtrlCreatePic("Happy_Bd_Pete_2006.jpg",10,10, 630,530)

; This method below works on the local PC but not when compiled
; to a file named experimental.exe and run on another PC, so I don't 
; think I'm referencing the installed file correctly. 
; How do I reference the pic file after it's been installed using FileInstall above???
GuiCtrlCreatePic("d:\1public\Happy_Bd_Pete_2006.jpg",10,10, 630,530)

;Displays HAPPY BIRTHDAY but how do I change the font size???
GuiCtrlCreateLabel("HAPPY BIRTHDAY", 250, 1, 100, 15)


; GUI MESSAGE LOOP
GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Share this post


Link to post
Share on other sites

Replace:

FileInstall("d:\1public\Happy_Bd_Pete_2006.jpg", "D:\DatAutoIT\experimental.au3")oÝ÷ Ùh­«­¢+Øí9Ѽ¹µÑ¡¥±½ÉÉÐÑ¡Ðå½Ôɽ¥¹Ñ¼±°)¥±%¹Íѱ° ÅÕ½ÐíèÀäÈìÅÁÕ±¥ÀäÈí!ÁÁå} }AÑ|ÈÀÀع©ÁÅÕ½Ðì°MÉ¥ÁѥȵÀìÌäìÀäÈí!ÁÁå}    }AÑ|ÈÀÀع©ÁÌäì


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

FileInstall ( "source", "dest" [, flag] )

For some reason FileInstall doesn't seem to be the easiest function for some to understand.

When you are making your script and you test it uncompiled, the file will only be copied,

meaning that "source" will be copied to the file specified in "dest". However, don't think so

much about this as it's only useful for testing.

When you're compiling you're script however, the file specified in "source" is being copied

into your script. You can now just forget about the "source"-file and you can copy your

compiled script to any other computer without problems.

So, when you run your script on another computer, and when the script comes to the

FileInstall line, the file inside your script is copied out of the script and to "dest".

That's it :whistle:

Share this post


Link to post
Share on other sites

Thanks guys!

I used your info to solve my problem and below is for anyone

else who desires to use Fileinstall To Embed Other Files To

Compiled *.EXE File.

How to use FileInstall to embed picture or sound files into

the compiled *.exe file for distribution to other computers.

I'm an intermediate level VB6 programmer and expert with

VBA, but I'm a beginner with AutoIT. I found that AutoIT's

FileInstall command is not clearly explained in the HELP

system. Much research and experimentation was required to

figure out how it works. This message is intended to

solve that problem and help others with using FileInstall.

Per many posts on the AutoIT Forum related to FileInstall,

it seems that people often need to include some image or sound

files in the compiled *.exe file that will be run on other

computers. The code below shows how to do it with comments

that explain the process. ---pete---

;==================================================================
; Desc: This script is an electronic greting card. It simply displays 
; a picture and plays some music in the background for 25 seconds.
; The user closes the window to quit.
;
#include <GuiConstants.au3>

; Define variables of the picture and sound files to be 
; included/embedded into the compiled Greeting_card.exe file.
$pic1 = "Happy_Bd_Pete_2006.jpg"
$snd1 = "Song_Instrumental_25s.wav"

; Create the GUI.
GuiCreate("Electronic Greeting Card", 650, 550)


; Include/embed the PICTURE file into the program file such that 
; it can be compiled and run from within Greeting_Card.exe file.
; Source must not be a variable.
; Using @WorkingDir so that it works on any PC.
; Passing: Source, Destination, Flag (1 = overwrite any previous file)
FileInstall("d:\1public\Happy_Bd_Pete_2006.jpg", _
             @WorkingDir & "\" & $pic1, 1)


; Insert the Pictue file to the GUI for viewing.
GuiCtrlCreatePic($pic1, 10, 10, 630, 530)


; Include/embed the SOUND file into the program file such that
; it can be compiled and run from within Greeting_Card.exe file.
; Source must not be a variable.
; Using @WorkingDir so that it works on any PC.
; Passing: Source, Destination, Flag (1 = overwrite any previous file)
FileInstall("f:\s\wav\Song_Instrumental_25s.wav", _
             @WorkingDir & "\" & $snd1, 1)


;Play the sound file.
Soundplay(@WorkingDir & "\" & $snd1)


; Displays HAPPY BIRTHDAY text above the picture,
; but how do I change the font size???  Not sure if it's possible.
GuiCtrlCreateLabel("HAPPY BIRTHDAY", 250, 1, 100, 15)


; Display the GUI until user closes it.
GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd


; Ok, to further explain how FileInstall works, 
; When you compile the script, FileInstall embeds the file(s) into
; the *.exe file, similar to how files are embedded into *.ZIP files.
;
; Upon running the *.exe file, FileInstall extracts the embedded file(s)
; and writes the file(s) to the hard drive. The script program then 
; accesses the file(s) from the hard drive. The file(s) remain on the 
; hard drive even after the script program is terminated. Therefore, 
; it is desirable; to add some code to delete the file(s) upon 
; closing the script program.

; Delete the Picture & Sound files that were written to
; the hard drive by the FileInstall command.

; Command to play non-existant sound file to release the $snd1 file,
; otherwise the FileDelete for $snd1 will not delete the file.
SoundPlay("bogus.wav")
FileDelete(@WorkingDir & "\" & $snd1)

FileDelete(@WorkingDir & "\" & $pic1)

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

Share this post


Link to post
Share on other sites

; Displays HAPPY BIRTHDAY text above the picture,
; but how do I change the font size???  Not sure if it's possible.
GuiCtrlCreateLabel("HAPPY BIRTHDAY", 250, 1, 100, 15)
PeteF,

Replace the above code with the following to change your font size:

GuiCtrlCreateLabel("HAPPY BIRTHDAY", 250, 1, 300, 25)
GUICtrlSetFont(-1, 20)

taurus905

P.S. I can't remember having too much trouble using FileInstall as it's explained in the help file. But I believe it is always good to have things explained in various ways to fit different audiences. :whistle:


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Share this post


Link to post
Share on other sites

P.S. I can't remember having too much trouble using FileInstall as it's explained in the help file. But I believe it is always good to have things explained in various ways to fit different audiences. :whistle:

Thanks for the help!

Yeah, I agree it always helps to have things explained in deferent ways

and by different people. I gathered info from a variety of posts and

combined it all into one post. Seems like a common issue where people

need to include files and can't figure out how FileInstall works.

BTW: Do you think I discovered a bug with SoundPlay where it keeps

a lock on the file and won't let me FileDelete the last file it played?

---pete---

Share this post


Link to post
Share on other sites

BTW: Do you think I discovered a bug with SoundPlay where it keeps

a lock on the file and won't let me FileDelete the last file it played?

---pete---

PeteF,

I did not look at the sound aspect of your script. If you think it is a bug, I suggest starting another thread in the support forum with a subtitle of 'possible bug' along with an example.

taurus905


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

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  
Followers 0