Navigation Menu

Skip to content

Commit

Permalink
Additions to '/silent'
Browse files Browse the repository at this point in the history
+ changed Completion message
  • Loading branch information
TAC109 committed Aug 27, 2021
1 parent ec997fb commit d99454a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
22 changes: 11 additions & 11 deletions Ahk2Exe.ahk
Expand Up @@ -109,7 +109,7 @@ Gui, Add, Button, xp296 yp w53 h23 gBrowseBin vBtnBinFile, Bro&wse
Gui, Add, Text, x17 yp32, Compress exe with
Gui, Add, DDL, % "xp130 yp-2 w75 AltSubmit gCompress vUseMPress Choose" UseMPRESS+1, (none)|MPRESS|UPX
Gui, Add, Text, xp150 yp2 vEmbRes, Embedded Resource ID
gui, Add, ComboBox, x444 yp-2 w112 vResourceID, %LastResource%
gui, Add, ComboBox,x444 yp-2 w112 vResourceID, %LastResource%
Gui, Add, Text, x17 yp40, Convert to executable
Gui, Add, Button, xp130 yp-4 w75 h23 Default gConvert vBtnConvert, > &Convert <
Gui, Add, Text, xp150 yp4 vSave, Save 'Options' as default
Expand Down Expand Up @@ -406,7 +406,7 @@ CmdArg_CP(p2) { ; for example: '/cp 1252' or '/cp UTF-8'

CmdArg_Silent(){
global
if p[1] = "verbose"
if (p[1] = "verbose")
{ SilentMode := 2
p.RemoveAt(1)
} else SilentMode := 1
Expand Down Expand Up @@ -561,7 +561,7 @@ ConvertCLI()
return

ConvertCLI()
{ local TempWD
{ local TempWD, ExeFileL
AhkFile := Util_GetFullPath(AhkFile)
if AhkFile =
Util_Error("Error: Source file not specified.", 0x33)
Expand Down Expand Up @@ -622,13 +622,13 @@ ConvertCLI()
DirExe.1 := ExeFile, DirBins.1 := BinFile

for k in DirBins
AhkCompile(AhkFile, DirExe[k], ResourceID, IcoFile, DirBins[k]
, UseMpress, DirCP[k] ? DirCP[k] : ScriptFileCP)
ExeFileL .= AhkCompile(AhkFile, DirExe[k], ResourceID, IcoFile, DirBins[k]
, UseMpress, DirCP[k] ? DirCP[k] : ScriptFileCP) "`n"

if !CLIMode
Util_Info("Conversion complete.")
Util_Info("Successfully compiled:`n" ExeFileL)
else
FileAppend, Successfully compiled: %ExeFile%`n, *
FileAppend,Successfully compiled:`n%ExeFileL%, *
}

LoadSettings:
Expand Down Expand Up @@ -724,7 +724,7 @@ Util_Status(s)

Util_Error(txt, exitcode, extra := "", extra1 := "")
{
global CLIMode, Error_ForceExit, ExeFileTmp, SilentMode
global CLIMode, Error_ForceExit, ExeFileTmp, SilentMode, AhkFile

if extra
txt .= "`n`nSpecifically:`n" extra
Expand Down Expand Up @@ -754,14 +754,14 @@ Util_Error(txt, exitcode, extra := "", extra1 := "")
}

if CLIMode && exitcode{
try FileAppend, Failed to compile: %ExeFile%`n, **
try FileAppend, Failed to compile: %AhkFile%`n, **
catch
FileAppend, Failed to compile: %ExeFile%`n, *
FileAppend, Failed to compile: %AhkFile%`n, *
}
Util_Status("Ready")

if exitcode
if Error_ForceExit || SilentMode
if (Error_ForceExit || SilentMode)
ExitApp, exitcode
else Exit, exitcode
Util_DisplayHourglass()
Expand Down
1 change: 1 addition & 0 deletions Compiler.ahk
Expand Up @@ -107,6 +107,7 @@ global StdLibDir := Util_GetFullPath(AhkPath "\..\Lib")
run "%ExeFileG%", %ExeFileG%\..
Util_HideHourglass()
Util_Status("")
return ExeFileG
}
; ---------------------------- End of AHKCompile -------------------------------

Expand Down
17 changes: 10 additions & 7 deletions Directives.ahk
Expand Up @@ -71,7 +71,7 @@ Directive_Let(state, txt*)
DerefIncludeVars[(wk.1 ~= "i)^U_" ? "" : "U_") wk.1] := wk.2
} }
Directive_Obey(state, name, txt, extra:=0)
{ global AhkPath, AhkSw
{ global AhkPath, AhkSw, SilentMode
IfExist %AhkPath%
{ if !(extra ~= "^[0-9]$")
Util_Error("Error: Wrongly formatted directive: (D3)", 0x64, state.Cmd)
Expand All @@ -81,7 +81,13 @@ Directive_Obey(state, name, txt, extra:=0)
Loop % extra
FileAppend % "`nFileOpen(""" wk A_Index
. """,""W"",""UTF-8"").Write(" name A_Index ")", %wk%, UTF-8
RunWait "%AhkPath%" %AhkSw% "%wk%",,Hide
if SilentMode
{ RunWait,"%comspec%" /c ""%AhkPath%" %AhkSw% /ErrorStdOut "%wk%" 2>"%wk%E"",, UseErrorLevel Hide ; Editor may flag, but it's valid syntax
if ErrorLevel
{ FileRead ErrorData, %wk%E
FileDelete %wk%?
Util_Error("Error: 'Obey' directive cannot be executed.",0x68,ErrorData)
} } else RunWait "%AhkPath%" %AhkSw% "%wk%",,Hide
Loop % extra + 1
{ FileRead result, % "*p65001 " wk (cnt := A_Index - 1)
DerefIncludeVars[(name~="i)^U_"?"":"U_") name (cnt ? cnt : "")] := result
Expand Down Expand Up @@ -231,23 +237,21 @@ Directive_AddResource(state, rsrc, resName := "")
if resName between 0 and 0xFFFF
nameType := "ptr"

if resType in 4,5,6,9,23,24 ; Deref text-type resources
if resType in 4,5,6,9,23,24 ; Deref text-type resources
{ FileRead fData, %resFile%
fData1 := DerefIncludePath(fData, DerefIncludeVars, 1)
VarSetCapacity(fData, fSize := StrPut(fData1, "utf-8") - 1)
StrPut(fData1, &fData, "utf-8")
}
else if SubStr(resExt,1,2) = "ah" && resType = 10
else if SubStr(resExt,1,2) = "ah" && resType = 10 ; Process AutoHotkey scripts
{ OldA_s := [], OldA_s.Push(DerefIncludeVars.A_ScriptFullPath)
OldA_s.Push(DerefIncludeVars.A_ScriptName)
OldA_s.Push(DerefIncludeVars.A_ScriptDir)
OldA_s.Push(DerefIncludeVars.A_LineFile)

SplitPath, resFile, ScriptName, ScriptDir
DerefIncludeVars.A_ScriptFullPath := resFile
DerefIncludeVars.A_ScriptName := ScriptName
DerefIncludeVars.A_ScriptDir := ScriptDir
DerefIncludeVars.A_LineFile := resFile
tempWD := new CTempWD(ScriptDir)

PreprocessScript(fData1 := "", resFile, Directives := [], PriorLines := [])
Expand All @@ -259,7 +263,6 @@ Directive_AddResource(state, rsrc, resName := "")
for k, v in ["PostExec", "PostExec0", "PostExec1", "PostExec2"]
state[v].Push(dirState[v]*) ; Pass any PostExec up chain

DerefIncludeVars.A_LineFile := OldA_s.Pop()
DerefIncludeVars.A_ScriptDir := OldA_s.Pop()
DerefIncludeVars.A_ScriptName := OldA_s.Pop()
DerefIncludeVars.A_ScriptFullPath := OldA_s.Pop()
Expand Down
1 change: 1 addition & 0 deletions ErrorCodes.md
Expand Up @@ -63,3 +63,4 @@ Possible Errors
- `(0x5)` Error: Resource language must be an integer between 0 and 0xFFFF.
- `(0x6)` Error: Impossible BMP file.
- `(0x7)` Error changing the version information.
- `(0x8)` Error: 'Obey' directive cannot be executed.
2 changes: 1 addition & 1 deletion ScriptParser.ahk
Expand Up @@ -157,7 +157,7 @@ PreprocessScript(ByRef ScriptText, AhkScript, Directives, PriorLines
StringReplace, tline, tline, %EscapeTmpD%, %EscapeCharChar%, All

Directives.Push("AddResource *10 " Trim(o1, """'"))
PriorLines.Push(Chr(127) A_LoopReadLine) ; Install flag & line
PriorLines.Push(Chr(127) A_LoopReadLine) ; 'Install' flag & line
ScriptText .= tline "`n"
}else if !contSection && RegExMatch(tline, "i)^#CommentFlag\s+(.+)$", o)
Options.comm := o1, ScriptText .= tline "`n"
Expand Down

0 comments on commit d99454a

Please sign in to comment.