Jump to content

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

Compile_AHK II - for those who compile!


  • Please log in to reply
467 replies to this topic
ladiko
  • Members
  • 290 posts
  • Last active: Jan 16 2012 11:46 PM
  • Joined: 13 Jul 2006
hmm? invasive? nooo you are not invasive :-)
sometimes my phrases are a little bit offensive, that's my style, sorry for that. maybe in the future i'm going to add this, but not in the next 4 - 8 weeks, cause its not a function that adds further usefulness to compile_ahk. it only saves 400kb.

i've uploaded a new version without a new changelog, see the changes in my last post. in normal situations it is not necessary to download this version again.

chadross
  • Members
  • 13 posts
  • Last active: Aug 14 2011 12:00 AM
  • Joined: 30 Apr 2008
ladiko,

would it be possible to have the script check A_ScriptDir for the Defaults INI if it is not found at A_AppData . "\Compile_AHK\Defaults.ini" ?

Perhaps changing to something like this (Line 206):
; ; --------------------------------------------------------------------------------
; INI File
; --------------------------------------------------------------------------------
DEFAULTS_LOCAL_INI := A_ScriptDir . "\Defaults.ini"
If FileExist(INI_FILE) {
	_READ_INI(INI_FILE)
} Else If FileExist(DEFAULTS_INI) {
	_READ_INI(DEFAULTS_INI)
} Else If FileExist(DEFAULTS_LOCAL_INI) {
	_READ_INI(DEFAULTS_LOCAL_INI)
}
AHK and Compile_AHK have made scripting at work so much easier for me. I can now move between multiple computers and not worry whether or not AHK has been installed.

Thanks for your help. :D

ladiko
  • Members
  • 290 posts
  • Last active: Jan 16 2012 11:46 PM
  • Joined: 13 Jul 2006
Update from 2008-05-31+ New: defaults.ini can be saved in Compile_AHK's folder
+ Changed: More compact GUI
+ Changed: ini-files are read in following order / priority:[*:3qnqzss5]script folder
[*:3qnqzss5]AppData folder
[*:3qnqzss5]Compile_AHK.exe folder[/list]Download Compile_AHK

chadross
  • Members
  • 13 posts
  • Last active: Aug 14 2011 12:00 AM
  • Joined: 30 Apr 2008
Thanks ladiko, you rock...

NACarter
  • Guests
  • Last active:
  • Joined: --
Hi ladiko,

Is your latest exe file corrupt? I keep getting an error message saying the exe is corrupt, and it would appear to be a lot smaller than your previous versions.

Nick

Rhys
  • Members
  • 761 posts
  • Last active: Aug 09 2013 04:53 PM
  • Joined: 17 Apr 2007
I'm not sure when this started happening, but UPX compression doesn't seem to be happening when I compile with this any more.
Edit: It's being compressed, but not at the right level... See my exciting console session:

G:\AutoHotkey\Compiler>upx -9 checktime_jen.exe
        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
upx: checktime_jen.exe: AlreadyPackedException: already packed by UPX

Packed 1 file: 0 ok, 1 error.

G:\AutoHotkey\Compiler>upx -d checktime_jen.exe
        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
    615115 <-    408267   66.37%    win32/pe     checktime_jen.exe

Unpacked 1 file.

G:\AutoHotkey\Compiler>upx -9 checktime_jen.exe
  
        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
    615115 ->    258763   42.07%    win32/pe     checktime_jen.exe

Packed 1 file.

Edit2: This decmpressed and recompressed exe says:
EXE corrupted

Edit3: I tried on a decompressed exe and it says the same:
EXE corrupted

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Re: Edit2 and Edit3
Since UPX is used on the stub executable before the actual script is appended, you can't decompress a compiled script without corrupting it. The actual script is compressed, encoded and appended to the executable using a closed-source (afaik) library provided by Jonathan Bennett.

Rhys
  • Members
  • 761 posts
  • Last active: Aug 09 2013 04:53 PM
  • Joined: 17 Apr 2007
Thanks for the info, Lexikos!

Has anyone else seen larger than expected compiled programs with the latest version of Compile_AHK_II? Just a few days ago it was working for me.

Edit: Reinstalling AHK fixed the issue - Root cause unknown!

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

+ New: If present, the folder Lib + AutoHotkey.exe will be copied too (function untested)

I just tested it (I don't compile often); AutoHotkey.exe is copied, but to the wrong directory. To support function libraries, AutoHotkey.exe and the Lib folder must be in %A_AppData%\AutoHotkey, not %A_AppData%\AutoHotkey\Compiler.

darklight_tr
  • Members
  • 31 posts
  • Last active: Feb 11 2014 04:32 AM
  • Joined: 29 May 2008

Update from 2008-04-31
Update from 2008-04-26
Update from 2008-04-25
Update from 2008-05-06


I'm curious, but should the releases after 2008-05-06 be in May, not April? That is, if you don't have a time machine. :D

Anyways, this is an awesome script!

  • Guests
  • Last active:
  • Joined: --
Quite usefull tool, thanks!

joey335
  • Guests
  • Last active:
  • Joined: --
Is there a way you can have a no UPX option. I don't like my a/v detecting it.

ScottMattes
  • Members
  • 195 posts
  • Last active: Feb 16 2015 01:43 AM
  • Joined: 21 May 2007

Does this compiler have an option, or is any work being done towards an option, to create a menu item for the compiled version of a script that will display the contents?

maybe i'm a little bit retarded, but i dont get the point of what you want :(
you want a hotkey or system tray context menu item that shows the current compiled script's source code? hmm my script doesnt compile anything. it uses the default compiler ahk2exe.exe and is limited to it's ahk-related functions. my script only gives access to ahk2exe.exe's command line options and some resource editing. maybe i could add the related script file as a resource to the compiled script, but how to show it ... hmm?!? refer to <!-- m -->http://www.autohotke...hp?p=147202<!-- m -->


I doubt that you are retarded.

What I would like in a compiler is for it to scan my .ahk and create "a hotkey or system tray context menu item, in the compiled version, that shows the current compiled script's" defined hotkeys and auto expands (with the comments that are on that line). That way anyone that uses the .exe version of my code can right click on the tray icon and select Contents and see a list of the key and a short comment about what it does.

Here is the code that I cobbled together for my .ahk to use

; from ideas and code found on AutoHotKey.com
;(and specifically MikeG contribution in http://www.autohotkey.com/forum/viewtopic.php?t=215)
; with some mods of my own - [email protected]


; purpose: to automate showing what keys, etc, are defined for use
; this script will read the ahk that includes it and display what keys
; and auto replace strings are defined in it. It also includes a menu
; item in the tray popup menu, called Contents, for the calling ahk


; how to use: put the line '#include path/name' in every .ahk file

; dbl clicking on the tray icon will display a list of defined hotkeys
 
#Persistent  ; Keep the script running until the user exits it.

; add an entry to the running script's tray popup menu
Menu, tray, add  ; Creates a separator line.
Menu, tray, add, Contents, key_list ; Creates a new menu item.
Menu, tray, default, Contents
;return

;****************************************************************
; Extract a list of hotkeys and their descriptions from this script
;****************************************************************
key_list:
  SetBatchLines,-1
  AutoTrim,off

  key_count = 0
  key_list=

  Loop,Read,%A_ScriptFullPath%
  {
    Line=%A_LoopReadLine%
   
    Key=

    ; exclude lines that begin with ';' 
    first_char:= substr( line, 1, 1 )
    if first_char <> `;
    {
      IfInString,Line,`:`: ; look for :: in line, this is a key assignment
      {
        StringSplit,Key,Line,`:

        key_count += 1

        ; normally we use key1
        key = %key1%
        key_length:=strlen(key)

        ; but if key1 is null, use key2
        if key_length = 0
        {
          StringReplace,Key,Key2,*,%a_space%%key3% ; force autoreplace lines to the top later
        }
        else
        {
          ; change the special characters to human friendly terms
          StringReplace,Key,Key1,#,Win-,all
          StringReplace,Key,Key,!,Alt-,all
          StringReplace,Key,Key,^,Ctrl-,all
          StringReplace,Key,Key,+,Shift-,all
          StringReplace,Key,Key,~,Native+,all
          StringReplace,Key,Key,*,Wild+,all
          StringReplace,Key,Key,<,Left%a_space%,all
          StringReplace,Key,Key,>,Right%a_space%,all
          StringReplace,Key,Key,`;,,all
        }

        if strlen(key) > max_len
        {
        max_len:=strlen(key)
        }

        keys%key_count%:=key

        ; if there is a comment on the line display it, else the command will show
        StringSplit,Comment,Line,`;
        StringTrimLeft,Comment,Comment%Comment0%,0
        comments%key_count%:=comment
      } ; IfInString,Line,`:`:

    } ; if substr( line, 1, 1 ) <> ';'
    
  } ; Loop,Read,%A_ScriptFullPath%

  max_len +=1

  ; go through and format for display
  cnt = 0
  loop %key_count%
  {
    a_key:=keys%a_index%

    ; force the the length of the longest key
    a_key=%a_key%                                                  !
    stringleft,a_key,a_key,%max_len%

    a_comment:=comments%a_index%

    key_list=%key_list%%a_Key%`t%a_comment%`n
  } ; loop %key_count%

  ; sort the variable for output
  sort, key_list

  ; show the user what we found, but only for 5 minutes
  MsgBox,0,Hotkeys list,%key_list%, 300

Return 




ScottMattes
  • Members
  • 195 posts
  • Last active: Feb 16 2015 01:43 AM
  • Joined: 21 May 2007
Here is a working example (2008-09-17 I now base the gui size on the available screen size, 2008-09-16 I fixed some things, and even tried the results):

; ExtractDefinedHotKeys.ahk
;
; Scott Mattes
; 2008-07-28 
; 
; To create code that you put into your AHK scripts to show what hotkeys and auto-expands are in the .ahk
; especially useful if you compile your AHK scripts
; These lines are to be included in your script before it is compiled. 

; Run this script and paste the contents of the clipboard into your script
;
; The code for isolating and converting for display is from MikeG
; from ideas and code found on AutoHotKey.com
; (and specifically MikeG's contribution found in http://www.autohotkey.com/forum/viewtopic.php?t=215)
;
; Modifications:
; 2008-09-17 Scott Mattes, - base gui size on available screen size
; 2008-09-16 Scott Mattes, - added check for, and msgbox about, no entries found
;                          - change Key_List: to Key_list()
;                          - added Key_List: to call Key_list()
;                          - elaborated in comments


  FileSelectFile, SelectedFile, 3, , Select the .ahk file to prepare, AutoHotKey files (*.ahk)

  if SelectedFile =
  {
      MsgBox, The user didn't select anything.
      return
  }

  key_count = 0

  Loop,Read,%SelectedFile%
  {
    Line=%A_LoopReadLine%
   
    Key=

    ; exclude lines that begin with ';' 
    first_char:= substr( line, 1, 1 )
    if first_char <> `;
    {
      IfInString, Line, `:`: ; look for :: in line, this is a key assignment
      {
        StringSplit,Key,Line,`:

        key_count += 1

        ; normally we use key1
        key = %key1%
        key_length:=strlen(key)

        ; but if key1 is null, use key2
        if key_length = 0
        {
          StringReplace,Key,Key2,*,%a_space%%key3% ; force autoreplace lines to the top later
        }
        else
        {
          ; change the special characters to human friendly terms
          StringReplace,Key,Key1,#,Win-,all
          StringReplace,Key,Key,!,Alt-,all
          StringReplace,Key,Key,^,Ctrl-,all
          StringReplace,Key,Key,+,Shift-,all
          StringReplace,Key,Key,~,Native+,all
          StringReplace,Key,Key,*,Wild+,all
          StringReplace,Key,Key,<,Left%a_space%,all
          StringReplace,Key,Key,>,Right%a_space%,all
          StringReplace,Key,Key,`;,,all
        } ; if key_length = 0

        keys%key_count%:=key

        ; if there is a comment on the line display it, else the command will show
        StringSplit,Comment,Line,`;
        StringTrimLeft,Comment,Comment%Comment0%,0
        comments%key_count%:=comment
      } ; IfInString,Line,`:`:

    } ; if first_char <> ';'
    
  } ; Loop,Read,%SelectedFile%

  ifequal, key_count, 0
  {
    msgbox, There were no hotstrings, autoreplace or hotkeys found!
    output_lines = ; free memory
    return
  } ; ifequal, key_count, 0
  
  ; go through and format for display
  loop %key_count%
  {
    a_key:=keys%a_index%
    a_comment:=comments%a_index%
    display_list=%display_list%  list_list=`%list_list`%%a_key%`t%a_comment% |`r`n

  } ; loop %key_count%

  
  ; now build the lines needed
  FormatTime, CurrentDateTime,, yyyy-MM-dd  HH:mm:ss

  output_lines = %output_lines%`; MOVE THESE LINES TO THE AUTO-EXECUTE SECTION OF YOUR SCRIPT`r`n
  output_lines = %output_lines%`r`n
  output_lines = %output_lines%`; add an entry to the running script's tray popup menu`r`n
  output_lines = %output_lines%  Menu, tray, add `; Creates a separator line.`r`n
  output_lines = %output_lines%  Menu, tray, add, Contents, key_list `; Creates a new menu item to call the display code.`r`n
  output_lines = %output_lines%  Menu, tray, default, Contents`r`n
  output_lines = %output_lines%`r`n
  output_lines = %output_lines%  key_list() `; display contents at startup of script`r`n
  output_lines = %output_lines%`r`n
  
  output_lines = %output_lines%`; MOVE THESE LINES TO THE *END* OF THE AUTO-EXECUTE SECTION OF YOUR SCRIPT`r`n
  output_lines = %output_lines%key_list:`r`n
  output_lines = %output_lines%  key_list()`r`n
  output_lines = %output_lines%return`r`n
  output_lines = %output_lines%`r`n  
  output_lines = %output_lines%`; PUT THESE LINES AT THE BOTTOM OF YOUR SCRIPT
  output_lines = %output_lines%`; Generated by ExtractDefinedHotKeys.ahk`r`n
  output_lines = %output_lines%`; Author: Scott Mattes`r`n
  output_lines = %output_lines%`r`n
  output_lines = %output_lines%`; Generated on: %CurrentDateTime%`r`n  
  output_lines = %output_lines%`r`n
  output_lines = %output_lines%`; From ideas and code found on AutoHotKey.com`r`n
  output_lines = %output_lines%`;(specifically MikeG's contribution http://www.autohotkey.com/forum/viewtopic.php?t=215)`r`n  
  output_lines = %output_lines%`r`n
  output_lines = %output_lines%`; Purpose: to automate showing what keys, etc, are defined for use`r`n  
  output_lines = %output_lines%`r`n
  output_lines = %output_lines%`; Double clicking on the tray icon will display a list of defined hotkeys`r`n
  output_lines = %output_lines%`r`n
  output_lines = %output_lines%`; Add an entry to the running script's tray popup menu`r`n
  output_lines = %output_lines%  Menu, tray, add  `; Creates a separator line.`r`n
  output_lines = %output_lines%  Menu, tray, add, Contents, key_list `; Creates a new menu item.`r`n
  output_lines = %output_lines%  Menu, tray, default, Contents`r`n  
  output_lines = %output_lines%`r`n
  output_lines = %output_lines%`;****************************************************************`r`n
  output_lines = %output_lines%`; Display the list of hotkeys, hotstrings and autoreplace and`r`n
  output_lines = %output_lines%`; their descriptions from this script`r`n
  output_lines = %output_lines%`;****************************************************************`r`n
  output_lines = %output_lines%key_list()`r`n
  output_lines = %output_lines%{`r`n
  output_lines = %output_lines%  SetBatchLines,-1`r`n
  output_lines = %output_lines%  AutoTrim,off`r`n
  output_lines = %output_lines%`r`n  
  output_lines = %output_lines%  key_count = %key_count%`r`n  
  output_lines = %output_lines%`r`n  
  output_lines = %output_lines%  list_list= `; reset for multiple calls`r`n
  output_lines = %output_lines%`r`n
  output_lines = %output_lines%  %display_list%`r`n
  output_lines = %output_lines%`r`n
  output_lines = %output_lines%`; sort the variable for output, use | vice CRLF as delimiter`r`n
  output_lines = %output_lines%  sort, output_lines, D|`r`n
  output_lines = %output_lines%`r`n
  output_lines = %output_lines%`; calculate the size of the ListBox, gui and position of the button`r`n
  output_lines = %output_lines%  list_height := key_count * 17`r`n
  output_lines = %output_lines%  gui_height := list_height + 40 + 30 + 10`r`n
  output_lines = %output_lines%`r`n
  output_lines = %output_lines%  sysget, ScreenWorkArea, MonitorWorkArea, 1`r`n
  output_lines = %output_lines%`r`n
  output_lines = %output_lines%  ifgreater, gui_height, `%ScreenWorkAreaBottom`%`r`n
  output_lines = %output_lines%  {`r`n
  output_lines = %output_lines%    gui_height := ScreenWorkAreaBottom - 40 - 30 - 10`r`n
  output_lines = %output_lines%    list_height := gui_height - 40 - 30 - 10`r`n
  output_lines = %output_lines%  }`r`n
  output_lines = %output_lines%`r`n
  output_lines = %output_lines%  button_y := list_height + 30`r`n
  output_lines = %output_lines%`r`n
  output_lines = %output_lines%`; show the results in a simple ListBox`r`n
;  output_lines = %output_lines%  Gui, Add, Button, Default x250 y750 w100 h30 , &Close`r`n
  output_lines = %output_lines%  Gui, Add, Button, Default x250 y`%button_y`% w100 h30 , &Close`r`n
;  output_lines = %output_lines%  Gui, Add, ListBox, t50 x16 y19 w570 h700, `%list_list`%`r`n
  output_lines = %output_lines%  Gui, Add, ListBox, t50 x16 y19 w570 h`%list_height`%, `%list_list`%`r`n
;  output_lines = %output_lines%  Gui, Show, w600 h800 center, AutoHotKey defined keys and substitutions`r`n
  output_lines = %output_lines%  Gui, Show, w600 h`%gui_height`% center, AutoHotKey defined keys and substitutions`r`n
  output_lines = %output_lines%}`r`n
  output_lines = %output_lines%`r`n
  output_lines = %output_lines%ButtonClose:`r`n
  output_lines = %output_lines%  gui, cancel`r`n
  output_lines = %output_lines%Return `r`n
  output_lines = %output_lines%`r`n
  output_lines = %output_lines%`; Generated by ExtractDefinedHotKeys.ahk`r`n
  
  msgbox, These are the lines that will be displayed (they will also be put on the clipboard):`noutput_lines=`n%output_lines%

  clipboard=%output_lines%
return

Run this and then paste the clipboard contents into the top of your .ahk file. Run your .ahk and the first thing it does is to display all defined hotkeys and auto-expanding text. After that, double clicking the icon will again display the list.

  • Guests
  • Last active:
  • Joined: --
please update it,is not working with latest autohotkey (1.0.47.6)


thanks