Advertisement
anonymous1184

https://redd.it/11pk7mv

Mar 13th, 2023
3,991
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Requires AutoHotkey v2.0
  2.  
  3. #NoTrayIcon
  4. #SingleInstance Force
  5. DetectHiddenWindows true
  6.  
  7. main()
  8.  
  9. main() {
  10.  
  11.     if (A_Args.Length = 0) {
  12.         MsgBox "Use at least an application path a argument.", "Error!", 0x1010
  13.         ExitApp 1
  14.     }
  15.  
  16.     mode := wd := ""
  17.     loop 2 {
  18.         if (RegExMatch(A_Args[1], "i)/(mode\d)", &match)) {
  19.             A_Args.RemoveAt(1)
  20.             mode := match[1]
  21.         }
  22.         if (A_Args[1] = "/wd") {
  23.             A_Args.RemoveAt(1)
  24.             wd := A_Args.RemoveAt(1)
  25.         }
  26.     }
  27.  
  28.     if (!FileExist(A_Args[1])) {
  29.         MsgBox "Target not found.", "Error!", 0x1010
  30.         ExitApp 1
  31.     }
  32.  
  33.     target := A_Args.RemoveAt(1)
  34.     loop files target, "F"
  35.         target := A_LoopFileFullPath
  36.  
  37.     if (!mode)
  38.         mode := "mode1"
  39.  
  40.     if (!wd)
  41.         SplitPath target, , &wd
  42.  
  43.     cmd := target
  44.     for , arg in A_Args
  45.         cmd .= " " Quote_Shell(arg)
  46.  
  47.     Run cmd, wd, "Hide", &pid
  48.     if (WinWait("ahk_pid" pid,, 1)) {
  49.         %mode%()
  50.         WinShow
  51.     }
  52.  
  53.     ExitApp 0
  54. }
  55.  
  56. mode1() => WinMinimize()
  57.  
  58. mode2() => PostMessage(0x0112, 0xF020)
  59.  
  60. Quote_Shell(String) => String ~= '[ %\^&<>\|"\*\?]' ? '"' String '"' : String
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement