Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Requires AutoHotkey v2.0
- #NoTrayIcon
- #SingleInstance Force
- DetectHiddenWindows true
- main()
- main() {
- if (A_Args.Length = 0) {
- MsgBox "Use at least an application path a argument.", "Error!", 0x1010
- ExitApp 1
- }
- mode := wd := ""
- loop 2 {
- if (RegExMatch(A_Args[1], "i)/(mode\d)", &match)) {
- A_Args.RemoveAt(1)
- mode := match[1]
- }
- if (A_Args[1] = "/wd") {
- A_Args.RemoveAt(1)
- wd := A_Args.RemoveAt(1)
- }
- }
- if (!FileExist(A_Args[1])) {
- MsgBox "Target not found.", "Error!", 0x1010
- ExitApp 1
- }
- target := A_Args.RemoveAt(1)
- loop files target, "F"
- target := A_LoopFileFullPath
- if (!mode)
- mode := "mode1"
- if (!wd)
- SplitPath target, , &wd
- cmd := target
- for , arg in A_Args
- cmd .= " " Quote_Shell(arg)
- Run cmd, wd, "Hide", &pid
- if (WinWait("ahk_pid" pid,, 1)) {
- %mode%()
- WinShow
- }
- ExitApp 0
- }
- mode1() => WinMinimize()
- mode2() => PostMessage(0x0112, 0xF020)
- Quote_Shell(String) => String ~= '[ %\^&<>\|"\*\?]' ? '"' String '"' : String
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement