Jump to content

Recommended Posts

Posted

I need help embedding bitmap images into a compiled script, so that my program is only one file, and not five (the script and 4 bitmaps). I am completely new to Autoit and this forum, so forgive me if I have not included enough detail, or posted wrong, or something...

Posted

Hi and welcome.

Please check the FileInstall() function in the help file. It does exactly what you need.

Broken link? PM me and I'll send you the file!

Posted

I already tried, with no success. :D

Could you give an example on how to use it? And if I do use it, what would I do for the image location? (GuiCtrlCreatePic("???",200,40,25,25))

Posted (edited)

The FileInstall function requires at least a temporary file during runtime.

If you want to completely skip the files part you'll have to use Zedna's resource UDF

Edited by monoceres

Broken link? PM me and I'll send you the file!

Posted

#include <GuiConstants.au3>

FileInstall('C:\FullPath_ToFile\smile.jpg', @ScriptDir)

Dim $hGUI = GUICreate('Test', 200, 200)
Dim $Pic = GUICtrlCreatePic(@ScriptDir & '\smile.jpg', 0, 0)

GUISetState()

Do
    Sleep(20)
Until GUIGetMsg() = $GUI_EVENT_CLOSE

GUIDelete()

Change the file path and name, read the help file it must be a literal string (no interpolation of @macro or variables). Compile and test.

Do I need the "Dim", or can I just use this:

GUICtrlCreatePic(@ScriptDir & '\smile.jpg', 0, 0)

Posted

you need the variables if you want to recall functions to that control.. but DIM not unless you have OPT('MustDeclareAllVars',1)

Posted

So than why does the below script not show an image:

#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <TabConstants.au3>
FileInstall('C:\image.bmp', @ScriptDir)
Dim $hGUI = GuiCreate("Test", 300, 300,Default,Default,-1,$WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOW)
sleep(50)
GuiCtrlCreateTab(2,2,297,397)
GuiCtrlCreateTabItem("Legend")
Dim $Pic = GuiCtrlCreatePic(@ScriptDir & '\image.bmp',20,20,220,280)
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd
Exit
Posted (edited)

put GUISETSTATE() beneath everything but above the While

EDIT here try this

#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <TabConstants.au3>
FileInstall('C:\image.bmp', @ScriptDir & '\Image.bmp')
Dim $hGUI = GuiCreate("Test", 300, 300,Default,Default,-1,$WS_EX_TOOLWINDOW)
sleep(50)
GuiCtrlCreateTab(2,2,297,397)
GuiCtrlCreateTabItem("Legend")
$Pic = GuiCtrlCreatePic(@ScriptDir & '\image.bmp',20,20,220,280)
GUISetState(@SW_SHOW)

While 1
$m=Guigetmsg()
if $m=$GUI_EVENT_CLOSE then exit
WEnd
Edited by CodyBarrett
Posted

yeah cause it looked like you werent even extracting the file... try having a file name in the dest.. like i posted

Posted

Forgive me...

It's actually like this:

FileInstall('C:\image.bmp', @ScriptDir & '\')
Thanks, that worked! But now I want to replace "@ScriptDir" to the temp folder (C:\Documents and Settings\(USERNAME)\Local Settings\Temp). Is there a variable to that location?
Posted

autoit helpfile>Autoit>Marco Reference

@TempDir

Posted

autoit helpfile>Autoit>Marco Reference

@TempDir

Thank you for all your help, but one last thing! Now how can I delete the .bmp files in the @TempDir when I exit my script?

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
×
×
  • Create New...