From 933b8c6238794e9ed7c1ff92edbc985f0899a562 Mon Sep 17 00:00:00 2001 From: Elliot DeNolf Date: Tue, 8 Nov 2016 23:32:03 -0700 Subject: [PATCH] Support custom ini path as command-line parameter --- WindowPadX.ahk | 59 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/WindowPadX.ahk b/WindowPadX.ahk index 48749ee..f12acbc 100644 --- a/WindowPadX.ahk +++ b/WindowPadX.ahk @@ -59,21 +59,33 @@ Version := "1.2.2" if 0 > 0 { ; Command-line mode: interpret each arg as a pseudo-command. + ; or pass in custom .ini path ; Suspend all hotkeys which may be created by WindowPadXInit. Suspend On - ; Load options and Gather exclusions. - gosub WindowPadXInit + ; Execute command line(s). Each args should be in one of these formats: ; ; , ; ", " ; In this case the initial comma is optional. Loop %0% - wp_ExecLine(%A_Index%) + { + param := %A_Index% + if InStr(param, ".ini") + { + WindowPadX_Init(param) + } + Else + { + gosub WindowPadXInit + wp_ExecLine(param) + } + } ExitApp } OnExit, TrayExit +; Load options and Gather exclusions. WindowPadXInit: ; If this script is #included in another script, this section may not be ; auto-executed. In that case, the following should be called manually: @@ -86,6 +98,8 @@ WindowPadX_Init(IniPath="") ; ; Init icons and tray menu. ; + wp_SetupTray() + if A_IsCompiled ; Load icons from my custom WindowPadX.exe. { ; Default icon is 32x32, so doesn't look good in the tray. @@ -460,6 +474,45 @@ hp_ExecuteHotkeyWithParams: return } +; +; Tray Menu +; +; + +wp_SetupTray() +{ + if A_IsCompiled ; Load icons from my custom WindowPadX.exe. + { + ; Default icon is 32x32, so doesn't look good in the tray. + Menu, Tray, Icon, %A_ScriptFullPath%, 2 + } + else if (A_LineFile = A_ScriptFullPath) + { ; Set the tray icon, but only if not included in some other script. + wp_SetTrayIcon(true) + ; Use OnMessage to catch "Suspend Hotkeys" or "Pause Script" + ; so the "disabled" icon can be used. + OnMessage(0x111, "WM_COMMAND") + } + + Menu, Tray, NoStandard + Menu, Tray, MainWindow + Menu, Tray, Add, &Debug, TrayDebug + ifExist, %A_ScriptDir%\WindowPadX.html + { + Menu, Tray, Add, &Help, TrayHelp + Menu, Tray, Add + } + Menu, Tray, Add, &Reload, TrayReload + if !A_IsCompiled + { + Menu, Tray, Add, &Edit Source, TrayEdit + } + Menu, Tray, Add, Edit &Configuration, TrayEditConfig + Menu, Tray, Add + Menu, Tray, Add, &Suspend, TraySuspend + Menu, Tray, Add, E&xit, TrayExit + Menu, Tray, Default, &Debug +} ; ; Tray Icon Override: