Compiler_Path= .autohotkeysc_ce.bin Editor_Path=default.exe Gui, Add, Tab, x10 y10 w480 h250 Choose1, Compile Gui, Tab, 1 Gui, Add, GroupBox, x20 y40 w460 h50 , Select the AHK file to be Compiled Gui, Add, Edit, x35 y60 w340 h20 vAHK_Path, %AHK_path% Gui, Add, Button, x385 y60 h20 gFind_AHK, Browse Gui, Add, GroupBox, x20 y100 w460 h50 , Select the AHK file after Compiled (.exe) Gui, Add, Edit, x35 y120 w340 h20 vEditor_Path, %Editor_Path% Gui, Add, Button, x385 y120 h20 gChoose_Editor, Browse Gui, Add, GroupBox, x20 y160 w460 h50 , Select the Compiler File (.bin) Gui, Add, Edit, x35 y180 w340 h20 vCompiler_Path, %Compiler_Path% Gui, Add, Button, x385 y180 h20 gChoose_Compiler, Browse Gui, Tab Gui, Add, Button, x100 y270 h20 Default gInstall, Compiling... Gui, Add, Button, x300 y270 h20 gCancel, Cancel Gui, Show, x250 y200 h300 w500 Center, 月饼的恩赐ScriptSetting %Script_Version% Return GuiClose: GuiEscape: Cancel: ExitApp Find_AHK: Gui +OwnDialogs FileSelectFile, AHK_Path, 3, , Find AHK File, AHK File(*.ahk) If AHK_Path GuiControl,,AHK_Path, %AHK_Path% Return Choose_Editor: Gui +OwnDialogs FileSelectFile, Editor_Path, 3, , Setting Target Compile File, Exe File(*.exe) If Editor_Path GuiControl,,Editor_Path, %Editor_Path% Return Choose_Compiler: Gui +OwnDialogs FileSelectFile, Compiler_Path, 3, , Choose CECompiler, Compiler(*.bin) If Compiler_Path GuiControl,,Compiler_Path, %Compiler_Path% Return install: ;This is the name and the path to the script which should be used to create the ahk-exe Quelle = %AHK_Path% ;This is the name and the path to the exe which should be created Ziel = %Editor_Path% ;This is the name and the path to the autohotkeyse_CE.bin-file. ahkcebin = %Compiler_Path% ;Copy bin to Destination FileCopy, %ahkcebin% , %Ziel%, 1 if errorlevel > 0 { MsgBox, File could not be copied. Errorlevel: %errorlevel% return } ;TEST TEST TEST ;File is unicode. If the file has an odd number the appended script is not aligned. So add a byte ;Perhaps this is not needed. FileGetSize, OutputVar, %Ziel% ;MsgBox, Filesize before: %OutputVar% evenodd := Mod(OutputVar, 2) if evenodd = 1 { FileAppend, %a_tab%, %Ziel% } FileGetSize, OutputVar, %Ziel% ;MsgBox, Filesize after: %OutputVar% VarSetCapacity(Var, 10, 0) ;Read the whole script. erlev := BinRead(Quelle, Var, 0, 0) ;the text", x) ;MsgBox, x: %x% BinWrite(Ziel, x, 0, -2) ;The first two characters are the "unicode" markers. These must be replaces with something harmless i.e space NumPut(32, Var, 0, "Char") NumPut(0, Var, 1, "Char") ;MsgBox, Binwrite output: %erlev% - %Counter% - %ErrorLevel% - %OutputVar% ;Append the script to the exe BinWrite(Ziel, Var, erlev, -2) return ;Transform Text to unicode. Slightly adjusted code from the ahk-forum. clipSetUnicode(cu_AnsiText, ByRef cu_WideText) ; copy ansi string to clipboard in unicode mode { StringLen,L,cu_AnsiText L:=(L+1)*2 varSetCapacity(cu_WideText,L,0) varSetCapacity(cu_UTFtext,L,0) ; ANSI to UTF-16. CP_ACP=0 if dllCall("MultiByteToWideChar",uint,0, uint,0, str,cu_AnsiText , uint,-1, str,cu_WideText, uint,L/2) dllCall("WideCharToMultiByte",uint,65001, uint,0, str,cu_WideText , uint,-1, str,cu_UTFtext, uint,L/2, uint,0, uint,0) ; Convert UTF-16 to UTF-8. CP_UTF8=65001 transform,clipboard,unicode,%cu_UTFtext% } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BinWrite ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; - Open binary file ; - (Over)Write n bytes (n = 0: all) ; - From offset (offset file[offset + 0..n-1], rest of file unchanged ; Return #bytes actually written ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BinWrite(file, ByRef data, n=0, offset=0) { ; Open file for WRITE (0x40..), OPEN_ALWAYS (4): creates only if it does not exists h := DllCall("CreateFile","str",file,"Uint",0x40000000,"Uint",0,"UInt",0,"UInt",4,"Uint",0,"UInt",0) IfEqual h,-1, SetEnv, ErrorLevel, -1 IfNotEqual ErrorLevel,0,Return,0 ; couldn't create the file m = 0 ; seek to offset IfLess offset,0, SetEnv,m,2 r := DllCall("SetFilePointerEx","Uint",h,"Int64",offset,"UInt *",p,"Int",m) IfEqual r,0, SetEnv, ErrorLevel, -3 IfNotEqual ErrorLevel,0, { t = %ErrorLevel% ; save ErrorLevel to be returned DllCall("CloseHandle", "Uint", h) ErrorLevel = %t% ; return seek error Return 0 } m := VarSetCapacity(data) ; get the capacity ( >= used length ) If (n m) n := m result := DllCall("WriteFile","UInt",h,"Str",data,"UInt",n,"UInt *",Written,"UInt",0) if (!result or Written m) n := m Granted := VarSetCapacity(data, n, 0) IfLess Granted,%n%, { ErrorLevel = Mem=%Granted% Return 0 } result := DllCall("ReadFile","UInt",h,"Str",data,"UInt",n,"UInt *",Read,"UInt",0) if (!result or Read