AutoHotkey Community

It is currently May 27th, 2012, 6:54 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: September 25th, 2011, 3:54 am 
Offline

Joined: July 15th, 2006, 6:07 pm
Posts: 254
I'm looking for an easy way to package up data with an compiled script. I have an on-line application that allows users to select content. I want to somehow "append" the download links to the end of a compiled ahk program. That program is offered to the user to download. When they execute it the program (somehow) goes to the end of itself and looks for the download links. I can easily do this with a text ahk file but my users don't have ahk on their machines so I'd like to do it with a complied script.
Thx.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 25th, 2011, 4:33 am 
Offline
User avatar

Joined: November 19th, 2010, 3:12 pm
Posts: 787
Location: At my computer
You may find this helpful:

http://www.autohotkey.com/forum/topic75 ... d041527778

_________________
"My dear Mr Gyrth, I am never more serious than when I am joking."
~Albert Campion

My personal site


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 25th, 2011, 4:43 am 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
-removed- (dmg beat me to the punch)

_________________
Autofire, AutoClick, Toggle, SpamWindow Control Tools
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 25th, 2011, 5:21 am 
Offline

Joined: July 15th, 2006, 6:07 pm
Posts: 254
I don't think this is what I'm looking for. I think that approach needs the data compiled with with the script. I can't (as far as I know) compile my script on my web server. What I'm trying to do is have a dynamic capability of appending stuff to the already compiled script. I've done the following simplistic test. Here is my script.
Code:
;compiled as test.exe
iniread,key,%A_ScriptFullPath%,section,Key
msgbox Key: %key%

After compiling it I simply appended.
Code:
[section]
Key = 42

to it.

Upon executing test.exe I get "EXE Corrupted" but I didn't expect it to be that easy.

Maybe there is a way to make a self extracting zip file or something on the server so I can package executable and data so at least they are delivered in one file.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 25th, 2011, 11:46 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
wakewatcher wrote:
Upon executing test.exe I get "EXE Corrupted" but I didn't expect it to be that easy.
AutoHotkey Basic does not allow scripts to be modified after they are compiled. AutoHotkey_L v1.1.01+ does.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2011, 5:07 pm 
Offline

Joined: July 15th, 2006, 6:07 pm
Posts: 254
Thanks. I've been (probably unnecessarily) hesitant to try AHK_L as I've got lots of old code and understood (perhaps mistakenly) that some old stuff might not work with it and that (again maybe mistakenly) that downloading AHK_L overwrites AHK so I haven't played with it yet. But should I do so I assume it wouldn't be as simple as I described above.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 26th, 2011, 5:25 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
unless you're doing something crazy, AHK_L will just run your scripts.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 30th, 2011, 2:50 am 
Offline

Joined: July 15th, 2006, 6:07 pm
Posts: 254
Lexikos wrote:
wakewatcher wrote:
Upon executing test.exe I get "EXE Corrupted" but I didn't expect it to be that easy.
AutoHotkey Basic does not allow scripts to be modified after they are compiled. AutoHotkey_L v1.1.01+ does.


OK. I got AHK_L installed and was able to append a text file to the end of the executable as you said. I verified this with opening the executable with a hex editor. However the program could not find the text. This was my simple test:
Code:
fileread,mapfile, *c %A_ScriptDir%
stringgetpos,pos,mapfile,[/header],R1
msgbox %pos%
ExitApp
The result is of the msgbox is -1. Further light and knowledge is evidently needed. :?


Last edited by wakewatcher on September 30th, 2011, 7:56 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 30th, 2011, 3:45 am 
Offline

Joined: June 4th, 2010, 9:04 pm
Posts: 1347
Location: california
personally if it were me i'd make two separate files. the link file would have a fixed name that the script would know before hand so it could load it on demand. Then put the compiled ahk script and the link file in a self extracting zip file that sets up a known directory where the link file can be found. Something like that is easy to maintain and change simply by downloading a different link file as needed but using the same name. Alternatively you could set up an ini settings file that contains the links that the program can access as well. If the script knows the ini file name it should be no problem to find and load it once the files are unzipped.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 30th, 2011, 8:00 am 
Offline

Joined: July 15th, 2006, 6:07 pm
Posts: 254
That's basically the method I'm already using and of course it works fine. However I'd like to do it with a single file so there is no messing around with unzipping or creating folders to put it in etc. The idea is I dynamically create the list and then copy it to the end of a copy of the executable and let them have it but apparently apparently stringgetpos even with the *c option in the fileread command must run into a binary zero before getting to my data.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 3rd, 2011, 7:13 pm 
Offline

Joined: July 15th, 2006, 6:07 pm
Posts: 254
Any tips on using something like File.RawRead() to do this?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 4th, 2011, 10:30 pm 
Offline

Joined: July 15th, 2006, 6:07 pm
Posts: 254
Found it! http://www.autohotkey.com/forum/topic76 ... le+rawread

Thanks, Thanh00 and CodeKiller.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 4th, 2011, 10:45 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
FYI, you can't FileRead a directory - maybe you meant %A_ScriptFullPath% instead of %A_ScriptDir%. FileRead *c reads the data as binary, so if you're using the Unicode version of AutoHotkey_L, you won't be able to use string commands with the data unless it was encoded in UTF-16 (unlikely). A workaround for that could be mapfile := StrGet(&mapfile, "CP0"), which converts ANSI text to the current format. However, as you noted with StringGetPos, it will stop at the first binary zero; instead of &mapfile you would need to use &mapfile + offset_of_text.

Rather than FileRead or File.RawRead(), you should probably seek to the beginning of the data with File.Seek() and then read the text with File.Read().

Also FYI, you can't write to an EXE file while it is running.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 4th, 2011, 11:04 pm 
Offline

Joined: July 15th, 2006, 6:07 pm
Posts: 254
oops. You are right it was A_ScriptName not A_ScriptDir. This is what I using and (so far) it works.
Code:
fileread,mapfile, *c %A_ScriptName%
Loop, % VarSetCapacity( mapfile )
{
   byte := NumGet( mapfile, A_Index - 1, "Char" )
   Map .= 31 < byte && byte < 127 ? Chr(byte) : ""
   Map .= byte = 10 or byte = 13 or byte = 20 ? Chr(byte) : ""         
}

stringgetpos,pos,map,[Header],r1
stringtrimleft,map,map,pos
msgbox *%map%*
exitapp
I think I'm using the ANSII version of your program. Thanks for the additional tips. If I run into problems I will surely use them.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 6th, 2011, 6:42 pm 
Offline

Joined: July 15th, 2006, 6:07 pm
Posts: 254
This is working great for me. I was wondering if there is a way to reduce the size of the executable. The minimum size ahk_L.exe seems to be about 3 times larger than the minimum size ahk.exe. (However I still prefer this over my previous zipped application of the ahk.exe and data file even though it's larger but thought I'd ask.)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: migz99, sjc1000 and 67 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group