Page 1 of 1

Switch between open Windows of the same type and same App

Posted: 30 Apr 2019, 17:33
by JuanmaMenendez
This AutoHotkey script is to switch between open Windows of the same type and same App (.exe)


The hotkey is (Alt + ~)

The "type" checking is based on the App's Title convention that stipulates that the App name should be at the end of the Window title (Eg: New Document - Word )

It works well with regular Window Apps, Chrome Shortcuts and Chrome Apps

Code: Select all

/* ;
*****************************
***** UTILITY FUNCTIONS *****
*****************************
*/


ExtractAppTitle(FullTitle)
{	
	AppTitle := SubStr(FullTitle, InStr(FullTitle, " ", false, -1) + 1)
	Return AppTitle
}



/* ;
***********************************
***** SHORTCUTS CONFIGURATION *****
***********************************
*/


; Alt + ` -  Activate NEXT Window of same type (title checking) of the current APP
!`::
WinGet, ActiveProcess, ProcessName, A
WinGet, OpenWindowsAmount, Count, ahk_exe %ActiveProcess%

If OpenWindowsAmount = 1  ; If only one Window exist, do nothing
    Return
	
Else
	{
		WinGetTitle, FullTitle, A
		AppTitle := ExtractAppTitle(FullTitle)

		SetTitleMatchMode, 2		
		WinGet, WindowsWithSameTitleList, List, %AppTitle%
		
		If WindowsWithSameTitleList > 1 ; If several Window of same type (title checking) exist
		{
			WinActivate, % "ahk_id " WindowsWithSameTitleList%WindowsWithSameTitleList%	; Activate next Window	
		}
	}
Return

Note: The Source Code with the last actualization can be found here https://github.com/JuanmaMenendez/AutoHotkey-script-Open-Show-Apps/blob/master/AutoHotkey-script-Switch-Windows-same-App.ahk


*** Extra ***

Also, I have another script that could work well in tandem with this one because you will be able to Open, Restore or Minimize (if it is already opened) the desired Apps, using the shortcuts key (hotkeys) that you want to set. Examples:

F7:: OpenOrShowAppBasedOnExeName("C:\Windows\System32\SnippingTool.exe")

F8:: OpenOrShowAppBasedOnWindowTitle("Gmail", "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --app=https mail.google.com /mail/") Broken Link for safety


Feel free to check my repo and give me your thoughts ;)

https://github.com/JuanmaMenendez/AutoHotkey-script-Open-Show-Apps


Thanks

Re: Switch between open Windows of the same type and same App

Posted: 01 May 2019, 07:58
by zhotkey
Nice script! Suggestion for improvement, add this ability for switching Windows 10 Explorer windows.

Re: Switch between open Windows of the same type and same App

Posted: 01 May 2019, 09:52
by burque505
@JuanmaMenendez, thank you. This is very useful for me.
Regards,
burque505