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
Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

Kinda limits the cosmetic options when it comes to compiled scripts then huh. Guess I'll need to find a way to work around having images in the gui. ):

I take it this means you were using file paths, not actually referencing the resources? I suggest you take a look at one or both of the following posts by SKAN: Embed images in compiled AutoHotkey scripts and How to convert Image data (JPEG/PNG/GIF) to hBITMAP.

  • Guests
  • Last active:
  • Joined: --

Kinda limits the cosmetic options when it comes to compiled scripts then huh. Guess I'll need to find a way to work around having images in the gui. ):

I take it this means you were using file paths, not actually referencing the resources? I suggest you take a look at one or both of the following posts by SKAN: Embed images in compiled AutoHotkey scripts and How to convert Image data (JPEG/PNG/GIF) to hBITMAP.


A lot of hassle for a branding watermark, is all. Thanks anyway.

Guest2
  • Guests
  • Last active:
  • Joined: --

Quick Question.

What are the benefits using this complier over the standard supplied compiler ?

Is the source more secure ? Faster / Smaller etc ?

Thx

you can make it smaller,add icon,add version info ,or other which you maybe like

To add to the above, you can modify Manifest for Vista Administrator Exection Level (User Account Control) easily, instead of using the "standard" compiler, which you need to change the Manifest by using Reshacker manually. 8)


Thanks for taking the time to reply !

How about encrypting the source code ? to make it harder to decode ?

Thanks again.

pekkle
  • Members
  • 13 posts
  • Last active: Nov 07 2013 04:27 AM
  • Joined: 20 Jan 2009

Quick Question.

What are the benefits using this complier over the standard supplied compiler ?

Is the source more secure ? Faster / Smaller etc ?

Thx

you can make it smaller,add icon,add version info ,or other which you maybe like

To add to the above, you can modify Manifest for Vista Administrator Exection Level (User Account Control) easily, instead of using the "standard" compiler, which you need to change the Manifest by using Reshacker manually. 8)


Thanks for taking the time to reply !

How about encrypting the source code ? to make it harder to decode ?

Thanks again.

For encrypting the source, I find no great benefit for using this compiler. The standard one already have that field allowing you to input the password ("N/A" to disable decompiling). However, with this compiler, you could specify the password (and version no.) to use for compiling in the source code and no need to input again everytime.

mouser
  • Members
  • 9 posts
  • Last active: Jan 09 2010 08:39 PM
  • Joined: 03 Oct 2008
very cool. thank you for sharing!

Zaelia
  • Members
  • 754 posts
  • Last active: Jan 17 2015 02:38 AM
  • Joined: 31 Oct 2008
It's possible to include .wav file into WAVE group, and not RCData ?

For use PlaySound easly ?
<!-- m -->http://msdn.microsof...y/aa910369.aspx<!-- m -->

And to rename resource before compile ? not 1, 2, 3, ...

Zaelia
  • Members
  • 754 posts
  • Last active: Jan 17 2015 02:38 AM
  • Joined: 31 Oct 2008
at line 2402
		} Else If s_Resources_Ext = WAV
		{
			WAVE_I++
			WAVE_I += 0.0
			
			s_Target := "WaveX , Wav" . WAVE_I . "X ,"  ;X for debug

To use:
flags := (SND_ASYNC := 0x1) | (SND_RESOURCE := 0x40004) | (SND_NODEFAULT := 0x2)
hMod := DllCall("LoadLibrary", "str", "MyApp.exe")
DllCall( "winmm.dll\PlaySoundA", Str, "WAV01", UInt, hMod, UInt, flags ) ; don't use UPX
return

escape::
DllCall("FreeLibrary", "UInt", hMod)
exitapp


Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
I have a request for an option: "Compile as console application."

I think the uses are fairly obvious, but can elaborate if you need me to.

The following (somewhat rudimentary) script can be used (via Run if desired) to change the subsystem of the AutoHotkeySC.bin file before the script is compiled. Ideally it would be used to modify Compile_AHK's temporary copy of the bin file rather than the original. Using it directly on a compiled script exe invalidates its checksum and prevents the script from working.
; Args:
;   1   filename of bin/exe file to switch
;   2   subsystem, i.e. "C" (console) or "G" (gui).  if omitted, switches between the two.
ifNotExist %1%
    ExitApp -1
file = %1%
if 2 not in ,C,G
    ExitApp -1

; Define Win32 constants.
GENERIC_READ  := 0x80000000
GENERIC_WRITE := 0x40000000
OPEN_EXISTING := 0x3
IMAGE_DOS_SIGNATURE := 0x5A4D
IMAGE_NT_SIGNATURE := 0x4550
IMAGE_SIZEOF_FILE_HEADER := 20
IMAGE_SUBSYSTEM_WINDOWS_GUI := 2
IMAGE_SUBSYSTEM_WINDOWS_CUI := 3

; Open file for read/write.
hfile := DllCall("CreateFile", "str", file, "uint", GENERIC_READ|GENERIC_WRITE, "uint", 0, "uint", 0, "uint", OPEN_EXISTING, "uint", 0, "uint", 0)
if hfile = -1
    ErrorExit("CreateFile failed")

; Verify EXE signature.
e_magic := SeekNumRead(hfile, 0, "ushort")
if (e_magic != IMAGE_DOS_SIGNATURE)
    ErrorExit("Bad exe file: no DOS sig")

; Get offset of IMAGE_NT_HEADERS.
e_lfanew := SeekNumRead(hfile, 60, "int")

; Verify NT signature.
ntSignature := SeekNumRead(hfile, e_lfanew, "uint")
if (ntSignature != IMAGE_NT_SIGNATURE)
    ErrorExit("Bad exe file: no NT sig")

; Calculate offset of IMAGE_OPTIONAL_HEADER and its Subsystem field.
offset_optional_header := e_lfanew + 4 + IMAGE_SIZEOF_FILE_HEADER
offset_Subsystem := offset_optional_header + 68

; Read current subsystem.
Subsystem := SeekNumRead(hfile, offset_Subsystem, "UShort")
; Toggle subsystem (do this even if it will be overridden, to validate):
if (Subsystem = IMAGE_SUBSYSTEM_WINDOWS_GUI)
    Subsystem := IMAGE_SUBSYSTEM_WINDOWS_CUI
else if (Subsystem = IMAGE_SUBSYSTEM_WINDOWS_CUI)
    Subsystem := IMAGE_SUBSYSTEM_WINDOWS_GUI
else
    ErrorExit("Bad subsystem: " Subsystem)

; Allow override on command-line:
if 2 !=  ; i.e. it is C or G
    Subsystem := IMAGE_SUBSYSTEM_WINDOWS_%2%UI

; Write new subsystem.
SeekNumWrite(Subsystem, hfile, offset_Subsystem, "UShort")

DllCall("CloseHandle", "uint", hfile)

MsgBox Changed subsystem to %Subsystem%.


; SeekNumRead: Seek to absolute offset and read a number of the specified type.
SeekNumRead(hfile, offset, type) {
    Seek(hfile, offset)
    VarSetCapacity(v,8), bytesToRead := NumPut(0,v,0,type)-&v
    if !(DllCall("ReadFile", "uint", hfile, "uint", &v, "uint", bytesToRead, "uint*", bytesRead, "uint", 0) && bytesRead == bytesToRead)
        ErrorExit("Read failed")
    return NumGet(v,0,type)
}

; SeekNumWrite: Seek to absolute offset and write a number of the specified type.
SeekNumWrite(num, hfile, offset, type) {
    Seek(hfile, offset)
    VarSetCapacity(v,8), bytesToWrite := NumPut(num,v,0,type)-&v
    if !(DllCall("WriteFile", "uint", hfile, "uint", &v, "uint", bytesToWrite, "uint*", bytesWritten, "uint", 0) && bytesWritten == bytesToWrite)
        ErrorExit("Write failed")
}

Seek(hfile, offset) {
    static FILE_BEGIN := 0
    if DllCall("SetFilePointer", "uint", hfile, "int", offset, "uint", 0, "uint", FILE_BEGIN) = -1
        ErrorExit("Seek failed")
}

ErrorExit(msg) {
    MsgBox %msg%`n  ErrorLevel=%ErrorLevel% A_LastError=%A_LastError%
    global hfile
    if (hfile != "" && hfile != -1)
        DllCall("CloseHandle", "uint", hfile)
    ExitApp
}


a_h_k
  • Members
  • 685 posts
  • Last active: Sep 28 2015 12:32 AM
  • Joined: 02 Feb 2008
3 minor things...

1) Icons tab .. Select
Maybe should disable gui momentaritly (or at least the "Compile" button) until icon's image appears (else can get an error)

2) Have script loaded into Notepad++ (haven't edited) --> Compile with Options --> Get below message
---------------------------
Reload
---------------------------
C:\<path><filename>.ahk

This file has been modified by another program.
Do you want to reload it?
---------------------------
Yes No
---------------------------

3) The en-us tab should be "Resources" not "Ressources"

a_h_k
  • Members
  • 685 posts
  • Last active: Sep 28 2015 12:32 AM
  • Joined: 02 Feb 2008
Compiler tab .. Exe file .. C:\...\SCRIPT.exe (source is SCRIPT.ahk)
--> Manually changed to C:\...\MyScript.exe

Result...
MyScript.exe
SCRIPT.ahk.ini

Should the result be...
MyScript.exe
MyScript.ahk.ini

:?:

rue nli
  • Guests
  • Last active:
  • Joined: --
No, really not. It's the ini for compiling script.ahk and has nothing to do with MyScript.exe.

XYZ
  • Members
  • 224 posts
  • Last active: Apr 29 2010 01:48 PM
  • Joined: 20 Mar 2010
thx so much for this
editing the RC of an AHK executable makes it corrupt

but with this its all too easy and working

fischgeek
  • Moderators
  • 1074 posts
  • Last active: Jul 07 2015 06:27 PM
  • Joined: 20 Apr 2009
Not sure if anyone's answered this, but how was the scrolling feature in the credits accomplised!? That's awesome!

SoggyDog
  • Members
  • 803 posts
  • Last active: Mar 04 2013 06:27 AM
  • Joined: 02 May 2006

Not sure if anyone's answered this, but how was the scrolling feature in the credits accomplised!? That's awesome!

<!-- m -->http://www.autohotke...opic.php?t=6752<!-- m -->

random11
  • Members
  • 102 posts
  • Last active: May 27 2014 02:48 PM
  • Joined: 10 Dec 2008
ok so I dont really want to install anything as I have auto hotkey and all other programs for auto hotkey on my usb key, is there a way getting this without having to install something?