Jump to content

Include files in your EXE and scripts! V2.0 now up!


Szhlopp
 Share

Recommended Posts

Version 2.0 is now up!

Checks if the given resource name is already entered.

No longer requires "$" at the beginning of the name.

More error checking.

Older version has the example:

DataFiler.zip

New version has the file-writer itself.

DataFiler_V2.0.zip

Prompts you with the name of the resource file.

Creates an 'Au3' in your script directory with the function to re-save them.

If you name resource file 1 "$Mypic", you can then recall it in your main script by using: _WriteMypictodir($Dir)

#include <#######\DataFiler_file.au3>
; Change the Directory!!

_writetextdoc1todir(@ScriptDir & '\Textfromexe.txt')
_writepic1todir(@ScriptDir & '\Zico.ico')

The example will write a text file and an 825KB .ico to the script directory. Try it out!

Compile the above script into an EXE and try calling the functions. Any data you have in the DataFiler_file.au3 will be included in the EXE!

Thanks for trying it! Let me know how it works!

Edited by Szhlopp
Link to comment
Share on other sites

Hi,

Didn't I understand very well, can it explain better? :P

Erm...

If you need to include images, text files, INI's or whatever else with your script/exe. You can use this to do so.

It creates the function with all the data in it. All you have to do is call the function to write the file to the disk.

A good is example is Skinning. I used this app to put my header image and buttons in my Au3. If the files don't exist it creates the JPG's in the script directory so it can run right=)

Download the zip and run the example. You'll get it=)

Link to comment
Share on other sites

Sounds like a complex "FileInstall()" function to me. But it works, so I say that it is a success!

Very nice example. :P

Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
Link to comment
Share on other sites

Sounds like a complex "FileInstall()" function to me. But it works, so I say that it is a success!

Very nice example. :P

Thanks!

It is sort of like fileinstall. But you can use macro's and variables to set the install location=)

50 downloads in one night and one reply? Does anyone else have some advice/comments? Any bugs?

Link to comment
Share on other sites

öhhh... For FileInstall-location You can use macros and variables too, just SOURCE can't use variables.

and i have 2 bugs.

1) The new New Name can't have spaces or umlauts

2) If the file already exists, you just append the data to the file :P

3) don't force the user to add the $ for the Variable :P

( some time ago I made a similar thing )

Edited by ProgAndy

*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

öhhh... For FileInstall-location You can use macros and variables too, just SOURCE can't use variables.

and i have 2 bugs.

1) The new New Name can't have spaces or umlauts

2) If the file already exists, you just append the data to the file :P

3) don't force the user to add the $ for the Variable :P

( some time ago I made a similar thing )

1) Intentional =P

2) I'll fix that. Make it check first.

3) Also fixable=)

I'll fix them very soon and upload the new version=)

Link to comment
Share on other sites

i dont understand this.. can you maybe tell me why i keep getting this error when i try to run your example?

C:\Users\Ray\Desktop\DataFiler\DataFiler_file.au3(8796,1) : ERROR: syntax error

Func

^

C:\Users\Ray\Desktop\DataFiler\EXE_include.au3 - 1 error(s), 0 warning(s)

#include <\DataFiler_file.au3>

_writetextdoc1todir(@ScriptDir & '\Textfromexe.txt')

_writepic1todir(@ScriptDir & '\Zico.ico')

nvm im a retard..

but i dont understand how i add this to my script

edit: well i learned how to use it :P and i made it easy for everyone else to use now :P

enjoy all...

p.s. Szhlopp im sorry if i did anything wroung i was just trying to help everyone/myself

edit:

i keep getting a corrupted jpg file when i do this... anyone know why?

DataFiler.exe

Edited by Golbez
Link to comment
Share on other sites

NP Golbez, My basement was flooded so I couldn't get on here for a few days. I've posted the new version though already=)

V2.0 is now up! Take a look!

Any feedback is great!

Thanks,

Szhlopp

Edited by Szhlopp
Link to comment
Share on other sites

what changed in the new version?

Look at the first post=)

I've tried PNG's, GIF's, JPG's ect ect and never got any of the files corrupted. Download my latest version and try JPG's in it. It should work fine

Link to comment
Share on other sites

It is sort of like fileinstall. But you can use macro's and variables to set the install location=)

As ProgAndy said, you can use macros and variables in the destination in the FileInstall function, you just can't use them for the source... so how is this different? Edited by c0deWorm

My UDFs: ExitCodes

Link to comment
Share on other sites

@Szlopp

I see you are a Halo player. By a strange twist of fate, so am I.

[ontopic]

I thought I remembered someone doing somthing like this except you could use the images from inside the exe. No extracting required. May just be my memory playing tricks.

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Link to comment
Share on other sites

As ProgAndy said, you can use macros and variables in the destination in the FileInstall function, you just can't use them for the source... so how is this different?

"The FileInstall function is designed to include files into a compiled AutoIt script."

"The source path of the file to compile. This must be a literal string; it cannot be a variable."

This allows you to easily control where you're putting files. It works in a plain NON compiled script (Which as we all know is important here to the non EXE users). It was my understanding that file install could NOT use variables. Maybe I was wrong, I will check later.

I made this after reading the "FileInstall" function, it sounded limited. If fileInstall was fixed/improved this will be useless to the extent of compiled EXE's. As I stated above. In a non-compiled .au3, you can't transfer a program with the data in the file. Because filestall puts the data in the EXE not the AU3.

@Szlopp

I see you are a Halo player. By a strange twist of fate, so am I.

Hehe... You're MLG=)

Link to comment
Share on other sites

It works as promised, well done!!

This script could save me a lot of coding time.

Some suggestions:

  • You can use the $NameOfRes.au3 as the output file, instead of a fixed "DataFiler_file.au3" file. In this way you can add a bunch of files at one time and avoid checking duplicated files.
  • "Func _Write_" & ...$NameOfRes... would be easier for reading than "Func _Write" & ..$NameOfRes..
Link to comment
Share on other sites

It works as promised, well done!!

This script could save me a lot of coding time.

Some suggestions:

  • You can use the $NameOfRes.au3 as the output file, instead of a fixed "DataFiler_file.au3" file. In this way you can add a bunch of files at one time and avoid checking duplicated files.
  • "Func _Write_" & ...$NameOfRes... would be easier for reading than "Func _Write" & ..$NameOfRes..

Thanks! I'll take both of those into consideration.

Just out of curiosity, what is gained by having a different a name for the output file? I'm not knocking the idea, just not sure how it helps=)

Link to comment
Share on other sites

"The source path of the file to compile. This must be a literal string; it cannot be a variable."

You CAN use variables for the target, or what would be the point? You can't use a variable for the source because it's meant for compiled exe's, which means it has to know the exact location of the file at build time. You can put that file anywhere you want. See the next line in the help file, below the one you posted.

The destination path of the file with trailing backslash if only the directory is used. This can be a variable.

(DataFiler) works in a plain NON compiled script (Which as we all know is important here to the non EXE users).

Okay, I can see the value in that - If you prefer to run your scripts using the Autoit3.exe script.au3 method instead of compiling, then this would be useful so you can encode files into the source. I suspect many AutoIt users just compile exe's, if only for performance, but also to hide the source from other company employees users who know enough to be dangerous. Your code is only really useful if you never compile your scripts, but still want the FileInstall functionality without having the file being installed available outside of it.

There was discussion on the forums at some point about including files into your exe and being able to access them directly in memory, but I never finished that topic all the way through. I will search for and revisit it again at some point, as I would love to be able to use images and such in my exe's without FileInstall'ing them to a temp folder. The vast majority of my scripts run silent and GUI-less, though, so it hasn't been a priority.

Edit:

Compile the above script into an EXE and try calling the functions. Any data you have in the DataFiler_file.au3 will be included in the EXE!

After scrolling back up to your OP, I noticed the line above. As previously stated, FileInstall does the exact same thing for compiled exe's. Your script is useful when you want FileInstall functionality without compiling, so this line is irrelevant. Edited by c0deWorm

My UDFs: ExitCodes

Link to comment
Share on other sites

@ c0deWorm

Not sure what it is you have against me. Use fileinstall if you like it better. :P

Okay, I can see the value in that - If you prefer to run your scripts using the Autoit3.exe script.au3 method instead of compiling, then this would be useful so you can encode files into the source. I suspect many AutoIt users just compile exe's, if only for performance, but also to hide the source from other company employees users who know enough to be dangerous. Your code is only really useful if you never compile your scripts, but still want the FileInstall functionality without having the file being installed available outside of it.

I havn't been here as long as you have, but to me it seems like most people dont want to run an EXE. Autoit 'CAN' be very dangerous to your computer.

I actually am interested in the memory stream stuff too. If you find out how to do something like that let me know. Would be an awesome addition=)

Link to comment
Share on other sites

Just out of curiosity, what is gained by having a different a name for the output file? I'm not knocking the idea, just not sure how it helps=)

My mistake, after a second try, I found that the script does append new attachments to the output file.

I think you could still use the FileOpenDialog to retrieve multiple files at one time, and use the filenames as $$NameOfRes in a loop, instead of input them one by one.

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