Last active
October 1, 2024 18:33
-
-
Save chmouel/83309f1f36a38b61fb177e8d9e8dd0df to your computer and use it in GitHub Desktop.
Focus or open msedge or windowsterminal on win+w or win+j
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires AutoHotkey v2.0 | |
global previousWindow := "" | |
; Define a function to focus or open | |
FocusOrOpen(exe, runit) { | |
global previousWindow | |
edgeWindow := "ahk_exe " . exe | |
; Check if Microsoft Edge is already open | |
if WinExist(edgeWindow) { | |
if (WinActive(edgeWindow)) { | |
if previousWindow { | |
WinActivate(previousWindow) | |
previousWindow := "" | |
} | |
} else { | |
previousWindow := WinExist("A") | |
WinActivate(edgeWindow) | |
} | |
} else { | |
previousWindow := WinActive() | |
Run(runit) | |
WinWaitActive(edgeWindow) | |
} | |
} | |
#w::FocusOrOpen("msedge.exe", "msedge.exe") | |
#j::FocusOrOpen("WindowsTerminal.exe", "wt.exe") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment