首页 > 其他分享 >autohotkey switching within applications

autohotkey switching within applications

时间:2023-01-05 22:13:53浏览次数:44  
标签:exe autohotkey ahk myGui within pid applications ppid glb

class QdirManager {
    ppid := -1
    ppath := ""
    __New(pathIn) {
        this.ppath := pathIn
    }
    __Delete() {
    }
    init() {
        Run(this.ppath, , , &ppidTmp)
        this.ppid := ppidTmp
        ; waiting window initialization
        Loop 20 {
            Sleep(50)
            if (WinExist("ahk_pid " this.ppid) > 0) {
                break
            }
        }
        WinActivate("ahk_pid " this.ppid)
    }
    bringFront() {
        ; ; MsgBox(WinExist("ahk_pid " this.ppid))
        ; if (WinExist("ahk_pid " this.ppid)) {
        ;     WinActivate("ahk_pid " this.ppid)
        ; }
        oList := WinGetList("ahk_exe" this.ppath, , ,)    ; ahk_id
        if (oList.Length >= 1) {
            this.ppid := WinGetPID("ahk_id " oList[1])
            WinActivate("ahk_pid " this.ppid)
        }
        else {
            this.init()
        }

        ; flash across
        myGui := Gui("+AlwaysOnTop -Caption +LastFound -SysMenu +ToolWindow -DPIScale +E0x20", "myGui")
        WinSetTransparent(100, myGui)
        myGui.BackColor := "EEAA99"
        myGui.Show("x0 y0 w" . A_ScreenWidth - 300 . " h" . A_ScreenHeight - 300)
        Sleep(100)
        myGui.Destroy()
    }
}

global glb_qdirManager1 := QdirManager("D:\tool\Q-Dir-AA\Q-Dir_x64.exe")
global glb_qdirManager2 := QdirManager("D:\tool\Q-Dir-AB\Q-Dir_x64.exe")
global glb_qdirManager3 := QdirManager("C:\Program Files (x86)\UltraExplorer\UltraExplorer.exe")
#q:: {
    glb_qdirManager1.bringFront()
}
#w:: {
    glb_qdirManager2.bringFront()
}
#e:: {
    glb_qdirManager3.bringFront()
}


win_No(pp) {
    ; pp := "D:\Program Files\Notepad++\notepad++.exe"
    winlist := WinGetList("ahk_exe " . pp)
    if (winlist.Length = 0) {
        Run(pp, , , &ppidTmp)
        ; waiting window initialization
        Loop 20 {
            Sleep(50)
            if (WinExist("ahk_pid " ppidTmp) > 0) {
                break
            }
        }
        WinActivate("ahk_pid " ppidTmp)
    }
    else {
        WinActivate("ahk_exe " . pp)
    }

    ; flash across
    myGui := Gui("+AlwaysOnTop -Caption +LastFound -SysMenu +ToolWindow -DPIScale +E0x20", "myGui")
    WinSetTransparent(100, myGui)
    myGui.BackColor := "EEAA99"
    myGui.Show("x0 y0 w" . A_ScreenWidth - 300 . " h" . A_ScreenHeight - 300)
    Sleep(100)
    myGui.Destroy()
}
#1:: win_No("C:\Program Files\Google\Chrome\Application\chrome.exe")
#2:: win_No("D:\Programs\Microsoft VS Code\Code.exe")
#3:: win_No("C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe")

; F4:: ExitApp 3333

标签:exe,autohotkey,ahk,myGui,within,pid,applications,ppid,glb
From: https://www.cnblogs.com/yusisc/p/17028953.html

相关文章