- specify an action that creates the InputBox, such as search or shutdown;
- trigger the action in another script with args for the action type and string.
Code: Select all
; Menu.ahk (with pseudocode)
Google := Func("InputBox").Bind("g")
Menu, MyMenu, Add, Google, % Google
Menu, MyMenu, Show
InputBox(Action) {
if "g" {
Title := "Search Google"
Prompt := "Enter a query:"
} else if "s" {
Title := "Shutdown"
Prompt := "Enter a timecode:"
}
InputBox, % OutputVar, % Title, % Prompt
Run, Action.ahk % Action OutputVar
}
; Action.ahk (with pseudocode)
if InStr(A_Args.1, "g" or "d") {
OpenURL(A_Args.1, A_Args.2)
ExitApp
} else if InStr(A_Args.1, "s") {
Shutdown(A_Args.2)
ExitApp
}
OpenURL(Engine, Query) {
g := "https://www.google.com/search?q="
d := "https://duckduckgo.com/?q="
Run, % WebBrowser Engine Query
}
Shutdown() {
; Split timecode into h, m
Run, shutdown.exe /H%h% /M%m%
}