-
Notifications
You must be signed in to change notification settings - Fork 14
/
Switch-opened-windows-of-same-App.ahk
55 lines (42 loc) · 1.79 KB
/
Switch-opened-windows-of-same-App.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
; NOTE: This functionality is already included in "Open-Apps-and-Switch-opened-windows.ahk" script
; This AutoHotkey script allows switching between open Windows of the current active App or Chrome Website Shortcut
; For regular Windows Apps it checks the app Process and Class
; For Chrome Apps and Chrome Website Shortcuts it checks the window's title (Eg: New Document - Word )
/* ;
*****************************
***** UTILITY FUNCTIONS *****
*****************************
*/
; Extracts the application title from the window's full title
ExtractAppTitle(FullTitle) {
return SubStr(FullTitle, InStr(FullTitle, " ", false, -1) + 1)
}
; Switch a "Chrome App or Chrome Website Shortcut" open windows based on the same application title
HandleChromeWindowsWithSameTitle() {
WinGetTitle, FullTitle, A
AppTitle := ExtractAppTitle(FullTitle)
SetTitleMatchMode, 2
WinGet, windowsWithSameTitleList, List, %AppTitle%
WinActivate, % "ahk_id " windowsWithSameTitleList%windowsWithSameTitleList%
}
; Switch "App" open windows based on the same process and class
HandleWindowsWithSameProcessAndClass(activeProcessName) {
WinGetClass, activeClass, A
SetTitleMatchMode, 2
WinGet, windowsListWithSameProcessAndClass, List, ahk_exe %activeProcessName% ahk_class %activeClass%
WinActivate, % "ahk_id " windowsListWithSameProcessAndClass%windowsListWithSameProcessAndClass%
}
/* ;
***********************************
***** SHORTCUTS CONFIGURATION *****
***********************************
*/
; Alt + ` - hotkey to activate NEXT Window of same type of the current App or Chrome Website Shortcut
!`::
WinGet, activeProcessName, ProcessName, A
if (activeProcessName = "chrome.exe") {
HandleChromeWindowsWithSameTitle()
} else {
HandleWindowsWithSameProcessAndClass(activeProcessName)
}
Return