Jump to content


Photo

Auto-Compile scripts at start


  • Please log in to reply
2 replies to this topic

#1 toralf

toralf
  • Fellows
  • 3948 posts

Posted 30 January 2006 - 01:15 PM

I need to compile a lot of my small scripts. Since I need to specify some comand line options for the compiler, I used a second script in the past to store and pass these parameters to the compiler. This was not very elegant, since I had to adjust the second script if the scripts file name changed and these compile scripts doubled the number of files in my folders.

So I came up with this small auto-compile code.
It will compile your script at start.

After I have tested my scripts and it is time to create a compiled version I add this code to the beginning of the script. This way I can edit the script for small changes and get the compiled version quickly, while everything is in a single file.
If not A_IsCompiled
  {
    ;find compiler
    SplitPath, A_AhkPath ,, OutDir, , , 
    Compiler = %OutDir%\Compiler\Ahk2Exe.exe
    IfNotExist %Compiler%
      {
        MsgBox, 16, Compiling, Compiler couldn't be found at:`n%Compiler%
        ExitApp
      }
    
    ;get script name
    SplitPath, A_ScriptName , , , , OutNameNoExt
    
    ;compile script
    RunWait, %Compiler% /in "%OutNameNoExt%.ahk" /out "%OutNameNoExt%.exe" /pass 123, %A_ScriptDir%, Hide
    
    ;give feedback
    MsgBox,64,Done with compiling,Compiled:`n%OutNameNoExt%.ahk -> %OutNameNoExt%.exe
    ExitApp
  }


#2 Guests

  • Guests

Posted 30 January 2006 - 04:50 PM

Nice one! You might want to add
[...]/icon "%OutNameNoExt%.ico"[...]


#3 toralf

toralf
  • Fellows
  • 3948 posts

Posted 30 January 2006 - 05:13 PM

I generally don't have icons for my scripts, thus I leave this up to the user to add this option for the compiler.