-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathauto_toggle.ahk
24 lines (20 loc) · 997 Bytes
/
auto_toggle.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#Requires AutoHotkey v2.0
# ref: https://superuser.com/questions/1604626/easy-way-to-switch-between-two-windows-of-the-same-app-in-windows-10
# Place this file in the Windows + R, type shell:startup
!`::
{
win_id := WinActive("A")
win_class := WinGetClass("A")
active_process_name := WinGetProcessName("A")
; We have to be extra careful about explorer.exe since that process is responsible for more than file explorer
if (active_process_name = "explorer.exe")
win_list := WinGetList("ahk_exe" active_process_name " ahk_class" win_class)
else
win_list := WinGetList("ahk_exe" active_process_name)
; Calculate index of next window. Since activating a window puts it at the top of the list, we have to take from the bottom.
next_window_i := win_list.Length
next_window_id := win_list[next_window_i]
; Activate the next window and send it to the top.
WinMoveTop("ahk_id" next_window_id)
WinActivate("ahk_id" next_window_id)
}