-
Let's say I have multiple Windows Terminal app windows running so I would like to cycle between them when I press WinT. This is what I have so far def windows_terminal() -> None:
windows_terminal_title = "ahk_exe WindowsTerminal.exe"
if not ahk.win_exists(windows_terminal_title):
exe_path = shutil.which("wt.exe")
if exe_path is not None:
subprocess.run(exe_path)
ahk.win_wait_active(windows_terminal_title)
# the following line will then activate the window it finds,
# but I wanted it to cycle in case there are multiple windows that
# satisfy the criteria
ahk.win_activate(windows_terminal_title) |
Beta Was this translation helpful? Give feedback.
Answered by
trajano
Jun 28, 2024
Replies: 1 comment 2 replies
-
Maybe you would do something like this: def windows_terminal() -> None:
windows_terminal_title = "ahk_exe WindowsTerminal.exe"
terminal_windows = ahk.find_windows(title=windows_terminal_title )
if not terminal_windows:
exe_path = shutil.which("wt.exe")
if exe_path is not None:
subprocess.run(exe_path)
terminal = ahk.win_wait(windows_terminal_title, timeout=3)
terminal_windows = [terminal]
terminal_windows.sort(key=lambda win: win.pid)
for index, window in enumerate(terminal_windows):
if window.is_active():
next_window = terminal_windows[index - len(terminal_windows) + 1]
break
else:
next_window = terminal_windows[0]
next_window.activate() |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I took your idea but I found out the hard way that
ahk_exe WindowsTerminal.exe
only returns one window even if I detach the tabs