AutoHotkey Community

It is currently May 26th, 2012, 12:39 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Choose your own binary
PostPosted: June 5th, 2005, 12:11 am 
Offline

Joined: May 16th, 2005, 8:07 am
Posts: 42
Location: Dallas, TX, USA
It'd be really handy to make it so that we can put several binaries in the Compiler directory, and specify in the script which one to compile to EXE with.

For example,
#Binary neat_script.bin

That'd reference neat_script.bin in the Compiler directory, instead of the default AutoHotkeySC.bin.

I know there are plans to do something more complex than this, but this would be a great addition in the meantime. Its usefulness would last even when the more advanced features were added, because I've already ResHacked my own Binary file and I'd like to keep using it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 5th, 2005, 1:42 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
It would be a nice-to-have feature. Although it doesn't seem too hard to implement, the reason it seems low priority is:

1) Fewer than 1% of users would likely benefit from it.
2) The benefit to those 1% is not large because they could write a script to automate something like this (using FileMove for example).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 5th, 2005, 5:45 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2542
Here's a rough script (not fully tested) that might be handy. Place this script in your .../AutoHotkey/Compiler/ directory. Place your altered .bin files in the /binfiles/ directory that gets created when the script is run for the first time. Feel free to tweak it ;) .

Code:
; Generated using SmartGUI Creator 3.4
IfNotExist, %A_ScriptDir%\AutoHotkeySC.bin
{
  MsgBox, Please copy this script to your .../AutoHotkey/Compiler/ directory and run the script again
  ExitApp
}
Gui, Add, GroupBox, x6 y20 w570 h90, Required Parameters
Gui, Add, Text, x16 y50 w90 h20, &Source (script file)
Gui, Add, Edit, x136 y45 w315 h23 vSource, ; Source Edit1           
Gui, Add, Button, x458 y45 w53 h23 gBsource, &Browse
Gui, Add, Text, x16 y79 w99 h13, &Destination (.exe file)
Gui, Add, Edit, x136 y75 w315 h23 vDest, ; Destination Edit2           
Gui, Add, Button, x458 y75 w53 h23 gBdest, B&rowse
Gui, Add, GroupBox, x6 y120 w570 h180, Optional Parameters
Gui, Add, Text, x16 y184 w102 h13, Custom Icon (.ico file)
Gui, Add, Edit, x137 y180 w315 h23 vIcon,  ; Icon Edit3           
Gui, Add, Button, x460 y180 w53 h23 gIcon, Br&owse
Gui, Add, Button, x518 y180 w53 h23 gDefIcon, D&efault
Gui, Add, Text, x16 y225 w57 h13, &Passphrase
Gui, Add, Edit, x137 y220 w315 h23 +Password vPass1, ; Pass1 Edit4           
Gui, Add, Text, x17 y249 w114 h13, &Verify passphrase
Gui, Add, Edit, x137 y246 w315 h23 +Password vPass2, ; Pass2 Edit5         
Gui, Add, Button, x460 y232 w53 h23 gDefPass, Def&ault
Gui, Add, Text, x25 y271 w467 h16, Note: If a passphrase is specfied`, you will need it if you wish to "decompile" a script.
Gui, Add, Button, x264 y314 w75 h28 gConvert, > &Convert <
Gui, Add, Text, x16 y155 w102 h13, Custom .bin file
Gui, Add, Edit, x136 y150 w315 h23 vBinFile, %A_ScriptDir%\binfiles\AutoHotkeySC.bin  ; Edit6
Gui, Add, Button, x459 y150 w53 h23 gBbin, Bro&wse
Gui, Add, Button, x518 y150 w53 h23 gDefBin, Defa&ult
IfNotExist, %A_ScriptDir%\binfiles
{
  FileCreateDir, %A_ScriptDir%\binfiles
  FileCopy, %A_ScriptDir%\AutoHotkeySC.bin, %A_ScriptDir%\binfiles\AutoHotkeySC.bin
}
IniRead, OutputVar, %A_ScriptDir%\a2egui.ini, AHK, Version
If OutputVar <> %A_AhkVersion%
{
IniWrite, %A_AhkVersion%, %A_ScriptDir%\a2egui.ini, AHK, Version
FileCopy, %A_ScriptDir%\AutoHotkeySC.bin, %A_ScriptDir%\binfiles\AutoHotkeySC.bin, 1
}
Gui, Show, h356 w586, AHK2EXE Gui - c1
Return

Bsource:
GuiControl, Text, Edit1, % Browse1("3", "*.ahk"," ")
Return

Bdest:
GuiControl, Text, Edit2, % Browse1("S3", "*.exe"," ")
Return

Bbin:
IfNotExist, %A_ScriptDir%\binfiles
{
  FileCreateDir, %A_ScriptDir%\binfiles
  FileCopy, %A_ScriptDir%\AutoHotkeySC.bin, %A_ScriptDir%\binfiles\AutoHotkeySC.bin
}
GuiControl, Text, Edit6, % Browse1("3", "*.bin", A_ScriptDir "\binfiles")
Return

Icon:
Icon := Browse1("3", "*.ico", A_ScriptDir)
If Icon
  GuiControl, Text, Edit3, %Icon%
Return

DefBin:
GuiControl, Text, Edit6, %A_ScriptDir%\binfiles\AutoHotkeySC.bin
Return

DefIcon:
GuiControl, Text, Edit3,
Return

DefPass:
GuiControl, Text, Edit4,
GuiControl, Text, Edit5,
Return

Convert:
Gui, Submit, NoHide
If BinFile =
  BinFile = %A_ScriptDir%\binfiles\AutoHotkeySC.bin
FileCopy, %BinFile%, %A_ScriptDir%\AutoHotkeySC.bin, 1
IfNotExist, %source%
{
  MsgBox, Please specify a valid source file
  Exit
}
source := "/in " SFN(source)
If dest =
{
  MsgBox, Please select destination
  Exit
}
IfExist, %dest%
  MsgBox, 4, , File Exists. Overwrite?
    IfMsgBox, No
      Return
dest := "/out " SFN(dest)
If Icon
  Icon := "/icon " SFN(Icon)
If Pass1
  If Pass1 = %Pass2%
    Pass1 = /pass %Pass1%
  else
  {
    MsgBox, Password verification failed
    Exit
  }
RunWait, %A_ScriptDir%\ahk2exe.exe %source% %dest% %icon% %Pass1%
FileCopy, %A_ScriptDir%\binfiles\AutoHotkeySC.bin, %A_ScriptDir%\AutoHotkeySC.bin, 1
MsgBox, Compile complete
Return


Browse1(options, filter, path="")
{
FileSelectFile, OutputVar, %options%, %path%,, %filter%
if OutputVar
  Return, %OutputVar%
Return


SFN(fname)
{
  Loop, %fname%
  {
    if A_LoopFileShortPath <>
      fname = %A_LoopFileShortPath%
  }
  Return, %fname%
}

GuiClose:
ExitApp

; Ahk2Exe.exe /in infile.ahk [/out outfile.exe] [/icon iconfile.ico] [/pass password]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 5th, 2005, 6:51 am 
Offline

Joined: May 16th, 2005, 8:07 am
Posts: 42
Location: Dallas, TX, USA
Interesting -- thank you!

I only wanted the feature in the first place because it seems silly to compile programs with all these extra icons -- so it should be something where if I want to compile a special set of icons into the EXE, all I need to do is say so in the script. But it's all good. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 5th, 2005, 5:55 pm 
Offline

Joined: November 16th, 2004, 6:38 am
Posts: 153
Location: New York
Though I've scripted the juggling of different ResHacked AutoHotkeySC.bin files, the problem you eventually run into is upgrading to new (and of course always exciting) versions of AHK. Since both the compiler executable and the .bin file change with each version, you pretty much have to keep a private copy of both with each project (and only re-hack a new version of the .bin file when you need to use a new AHK feature in an old project).

Jacques.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 5th, 2005, 6:29 pm 
Offline

Joined: May 16th, 2005, 8:07 am
Posts: 42
Location: Dallas, TX, USA
Ohhhhhh crap. The bin file changes? >_<


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 5th, 2005, 7:08 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2542
ComradeF wrote:
Ohhhhhh crap. The bin file changes? >_<
:lol: Yep. That's why I added the .ini file to compare versions on startup in the script I posted.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 29 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