Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Include virtually any file in a script (exe/zip/dll/etc....)


  • Please log in to reply
49 replies to this topic
Rseding91
  • Members
  • 703 posts
  • Last active: Apr 02 2016 05:05 AM
  • Joined: 07 Jun 2010

I have always wanted a way to pack files into a script for portability but I have never been able to find one.

That came to this:

Store virtually any file in a .ahk script (or compiled .exe)
Download: Here
Current version: 2.6
Compatible with: AHK Basic, AHK L ANSI, AHK L Unicode (X86/X64)


File types i've tested and know work: .zip, .exe, .txt, .ahk, ...anything?

The .ahk size of the file is rougly 1.33x the normal filesize(s). The compiled .exe (without compression) is rougly 1-1.05x the included filesize(s).

If you find any bugs or have anything to suggest please feel free to post.




How to use!:
1. Download and save the .ahk to a directory of your choosing.
2. Run the script
3. Select a file you want to include with your script(s)
4. Enter a name for the function you call to recreate the file (valid function names only)
5. Wait for it to do its stuff
6. Answer the questions on how you want to save the script
7. Simply include the code via #include or pasting it into your script
8. Call the function with Extract_*name* and the path/name of the file you want it to save as and it will recreate the file



tidbit
  • Administrators
  • 2709 posts
  • Hates playing Janitor
  • Last active: Jan 15 2016 11:37 PM
  • Joined: 09 Mar 2008
great script!

few ideas:
[*:30n3qw03]for the function that 'extracts' the file, you should have it has Blah_extract(....).
[*:30n3qw03]Documentation and/or samples.
[*:30n3qw03]maybe have 3 options for _get(...):
[*:30n3qw03] size
[*:30n3qw03] name (file.ext)
[*:30n3qw03] path (everything else)[/list]

rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .


Rseding91
  • Members
  • 703 posts
  • Last active: Apr 02 2016 05:05 AM
  • Joined: 07 Jun 2010

great script!
few ideas:
[*:3s3eshhr]for the function that 'extracts' the file, you should have it has Blah_extract(....).
[*:3s3eshhr]Documentation and/or samples.
[*:3s3eshhr]maybe have 3 options for _get(...):
[*:3s3eshhr] size
[*:3s3eshhr] name (file.ext)
[*:3s3eshhr] path (everything else)[/list]


Good ideas :)

I've updated it and changed the following:

*Function_Name*_Get(...) now has the following options:
Size (Size in bytes of the source file)
Name (Name + extension of the source file "name.extension")
Extension (Extension of the source file if any - "extension")
Directory (Directory of the source file - "C:\my folder")

The created function is now created as *Function_Name*_Extract(...)


I will be making a few examples shortly after I eat supper :)

aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
I've got your script but I have not tried it yet, I first need to make a 1024x768 gui with some basic key-press functions on it for my MAME arcade cabinet... in the event of a crash on this machine, the GUI will maximize and present the user with options. I'm going to need the ability your script offers to include a portable WinRAR EXE file which is used to back up high-score files.
With this in mind, is it possible to include an actual folder with an EXE file in it? If it is, can these be extracted anywhere when the script is run?

Rseding91
  • Members
  • 703 posts
  • Last active: Apr 02 2016 05:05 AM
  • Joined: 07 Jun 2010
In its current state it can't include a folder. You could grab the files one at a time and have it extract them all into the same folder. Or, you could zip up the files and include the zip.

If it's a single exe you want to include you can do that without any problems.

You can tell the function to extract the files to any location you choose.

aaronbewza
  • Members
  • 466 posts
  • Last active: Feb 05 2013 08:40 AM
  • Joined: 20 Feb 2011
ahhh! So I can FileCreateDir an empty folder before the EXE unpacks from the script, and I can set the newly created dir as the destination for the EXE. So it's the same (basically) as FileInclude when compiling the script except it writes the files into the script sort of like an Image Recorder like PowerISO would write a virtual "disc image" to a hard drive. The hard drive being the script, and the disk image being the file(s) to be included in the script.
Pardon my reasoning skills lol it's the best way I know to understand new cool things :)
Is there maybe a function you could add to capitalize on 7zip or Winrar to compress the #$%$ out of all the included files together, so they are an archive which is smaller for the FileInclude operation? Then the unpack location could be set with the variables made when you included the files. That may make the resulting script noticeably smaller. You could have a checkbox for the user to optionally choose that option if they have Winrar or 7zip installed on their system.

philu
  • Members
  • 15 posts
  • Last active: Jan 21 2016 06:34 PM
  • Joined: 28 Aug 2012

hello,

 

I am deeply sorry for bumping this old thread, but I just had to tell you, that this is the most epic shit I have come across in these forums.

I love you.

 

Have a nice day



Rseding91
  • Members
  • 703 posts
  • Last active: Apr 02 2016 05:05 AM
  • Joined: 07 Jun 2010

hello,

 

I am deeply sorry for bumping this old thread, but I just had to tell you, that this is the most epic shit I have come across in these forums.

I love you.

 

Have a nice day

 

 

Thanks :) it's always nice to know someone's using the random stuff I write.



noname
  • Members
  • 650 posts
  • Last active:
  • Joined: 12 Nov 2011

Too bad i missed it 2 years ago! Amazing very well done!

 

Thanks Rseding91


winXP  and ahk unicode


poserpro
  • Members
  • 525 posts
  • Last active: Apr 28 2013 04:39 AM
  • Joined: 21 Oct 2010

Yes,

Big Kuto to Rseding91.  I too found this program cool and quite useful. In a ridiculous and illogic thought, I did multiple wrapping/layers as kind of protection. I can further again wrap the y.exe into an installer, or simply pack it in the final the final CD usable as Windows program product. The client or receiver runs the y.exe and get the x.exe, the main program. 

 

Thanks for your hard yet genius work wink.png

-p


Since Oct 11, 2010

Check my QRCode design if you wish: 

http://db.tt/CONU2zBY


Rigged
  • Members
  • 10 posts
  • Last active: Sep 17 2013 03:14 PM
  • Joined: 28 Nov 2012

I am missing something.  I have been trying for an hour to extract a file to my desktop.  I know that it says to is Extract_*name* to call the file up, but I can't figure out the code to send it to a specific directory.  I'm sure it's something minute that I am missing.



noname
  • Members
  • 650 posts
  • Last active:
  • Joined: 12 Nov 2011
destination=c:\temp\test.png

Extract_myimage(destination)

 


winXP  and ahk unicode


Rseding91
  • Members
  • 703 posts
  • Last active: Apr 02 2016 05:05 AM
  • Joined: 07 Jun 2010

Updated to 2.4

 

  • Cleaned up the main script - reduced the file size by 2.7%, and made it truly basic/ANSI/Unicode/32 bit/64 bit compatible

  • Cleaned up the output function - reduce the file size by 4.6% and reduce the number code lines (48 lines vs. 60 lines)



Rseding91
  • Members
  • 703 posts
  • Last active: Apr 02 2016 05:05 AM
  • Joined: 07 Jun 2010

Updated to 2.5

 

  • Cleaned up the main script again - reduce the file size by 10x and reduce the encode time by 50%

  • Cleaned up the output function again - reduced the file size and line count slightly - no performance difference over 2.4



Rijul Ahuja
  • Members
  • 763 posts
  • Last active: Nov 25 2013 10:16 AM
  • Joined: 14 Mar 2012

.....that this is the most epic shit I have come across in these forums.......

 

Exactly what I was thinking. Thank you Robert Eding!

 

EDIT : Further usage made me realise that all variables are static, and that can cause memory problems if I have many functions to extract the files. Removing static causes loss of functionality, any idea how to avoid the variables?

I currently use a temporary workaround. The extract functions empty the static variables once they are complete. This can be done as I use the functions only once in my script.


Abandon the forum. The community has decided in a democratic vote to leave this website because of inactive and perverse administration.

Very few of the contributing members remain here.