Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- xRun(target, title := "", mode := 11, sendKey := false)
- {
- if wID := WinExist(title)
- {
- wID := "ahk_id " wID
- WinGet, wStyle, Style
- if (wStyle = 0x06CF0000) ; isTray
- {
- WinGetClass, wClass
- WinShow, % "ahk_class " wClass
- }
- else if (wStyle = 0x94000102) ; isMinimized
- {
- PostMessage, 0x112, 0xF120,,, % wID ; 0x112 = WM_SYSCOMMAND, 0xF120 = SC_RESTORE
- }
- WinActivate
- return
- }
- if (RegExMatch(target, "^\\\w"))
- {
- target := A_ScriptDrive target
- }
- if (WinExist("ahk_exe " target) && sendKey)
- {
- Send, % sendKey
- return
- }
- modeLen := StrLen(mode)
- if (!modeLen)
- {
- m1 := 1
- , m2 := 1
- }
- else if (modeLen = 1)
- {
- m1 := mode
- , m2 := 1
- }
- else
- {
- RegExMatch(mode, "(.)(.)", m) ; for the lolz
- }
- if (m1 = 2)
- {
- target := "*RunAs " target
- }
- else if (m1 = 3)
- {
- target := "path\to\PowerRun.exe """ target """"
- }
- switch m2
- {
- case 0: mode := "Hide"
- case 1: mode := "" ; Normal
- case 2: mode := "Min"
- case 3: mode := "Max"
- }
- Run, % target,, % mode " UseErrorLevel", pid
- WinWait, % "ahk_pid " pid,, 3
- WinActivate, % "ahk_pid " pid
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement