How to loop through Chrome windows while excluding VS Code editor Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
balkinishu
Posts: 18
Joined: 17 Nov 2017, 11:13

How to loop through Chrome windows while excluding VS Code editor

22 Apr 2021, 18:40

Both Chrome and VS Code share ahk_class Chrome_WidgetWin_1. I'd like to loop through my chrome windows without having VS Code windows in the rotation. How do I modify the below script to do that? I know that VS Code has ProcessName Code.exe which is different than all the chrome instances which have chrome.exe; but how do I prevent a VS code window from activating if it's the next window in the loop.

Code: Select all


	#g::
	{  
		WinGetClass, ActiveClass, A
		WinGet, n_instances, List, ahk_class %ActiveClass%
		if (n_instances > 1)
				WinActivateBottom, ahk_class %ActiveClass%,,Tabs Outliner,
		return
		
		;  WinGet, p_name, ProcessName , ahk_class %ActiveClass%
	}
	



balkinishu
Posts: 18
Joined: 17 Nov 2017, 11:13

Re: How to loop through Chrome windows while excluding VS Code editor

22 Apr 2021, 20:32

Thanks for guiding me to the right documentation section Mikeyww. Much appreciated.

For posterity, here's the revised code.

Code: Select all


#capslock:: F_activate_next_instance()  ; <sys> rotate through different instances of the active program

F_activate_next_instance(){
	WinGetClass, ActiveClass, A
	WinGet,      p_name,      ProcessName , ahk_class %ActiveClass%
	WinGet,      n_instances, List,         ahk_class %ActiveClass%
	if (n_instances > 1)
		WinActivateBottom, ahk_class %ActiveClass% ahk_exe %p_name%,,Tabs Outliner,
	return	
}

Last edited by balkinishu on 23 Apr 2021, 01:03, edited 4 times in total.
User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: How to loop through Chrome windows while excluding VS Code editor

22 Apr 2021, 21:02

If you want to activate the Chrome window on the bottom, the following script alone may also work.

Code: Select all

#g::WinActivateBottom, ahk_exe chrome.exe,, Tabs Outliner
This might not be an ideal hotkey choice (seems to activate a widgets menu).
balkinishu
Posts: 18
Joined: 17 Nov 2017, 11:13

Re: How to loop through Chrome windows while excluding VS Code editor

22 Apr 2021, 23:11

It's actually pretty easy to disable the Microsoft game bar from the Windows 10 settings menu to free up the #g key combo. While you're at it, I would also suggest disabling windows narrator and the magnifying widget as well.

https://www.windowscentral.com/how-disable-and-remove-game-bar-windows-10-creators-update

Thanks for the code suggestion, I actually want to keep my revised script the way it is so it applies to any active program. I had problems with some other programs as well as chrome. I just thought my problem would be clearer if I presented it as a specific Chrome problem.

I am sorta curious about how I would go about cycling in the other direction, but it's not something that's annoying me enough to expend effort on right now.
balkinishu
Posts: 18
Joined: 17 Nov 2017, 11:13

Re: How to loop through Chrome windows while excluding VS Code editor

24 Apr 2021, 23:14

Code: Select all

!capslock:: activate_last_instance()

activate_last_instance(){
	WinGetClass, ActiveClass, A
	WinGet,      p_name,      ProcessName , ahk_class %ActiveClass%
	WinGet,      n_instances, List,         ahk_class %ActiveClass%
	
	if (n_instances > 1)
		WinSet, Bottom,, A
	WinActivate, ahk_class %ActiveClass% ahk_exe %p_name%,,Tabs Outliner,
	return	

}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Nerafius, RandomBoy and 186 guests