List all open and visible window (Alt+Tab) in windwos 10 Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: List all open and visible window (Alt+Tab) in windwos 10

04 Jul 2018, 08:44

sobuj53 wrote:Love this community never came back empty handed.
GEV wrote:Try also
if !(style & 0xC00000) ; if the window doesn't have a title bar
Likewise.. I recently faced the same issue and for simplicity just dropped any window with no caption text or "Menu Start", but the style method is more reliably. :thumbup:
sobuj53
Posts: 55
Joined: 19 Mar 2015, 16:08

Re: List all open and visible window (Alt+Tab) in windwos 10

04 Jul 2018, 08:50

I must say both GEV and Nextron's solution works flawlessly but as Nextron's one is more reliable that's why I marked his method as accepted solution for future user reference. I want to thank again both of you for taking interest in to this.
sobuj53
Posts: 55
Joined: 19 Mar 2015, 16:08

Re: List all open and visible window (Alt+Tab) in windwos 10

04 Jul 2018, 09:18

Nextron wrote:You're probably using a 32-bit AHK on a 64-bit Windows? Then some redirection occurs, which might cause issues: https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
Instead of manually adding exceptions to a default icon, wouldn't it be more reliable to use a Try/Catch:

Code: Select all

$F1::
Menu, Windows, Add
Menu, Windows, deleteAll
WinGet windows, List
Loop %windows%
{
	id := windows%A_Index%
	WinGetTitle title, ahk_id %id%
	If (title = "")
		continue
	WinGetClass class, ahk_id %id%	
	If (class = "ApplicationFrameWindow") 
	{
		WinGetText, text, ahk_id %id%
		If (text = "")
			continue
	} 
	WinGet, style, style, ahk_id %id%
	if !(style & 0xC00000) ; if the window doesn't have a title bar
	{
		; If title not contains ...  ; add exceptions
			continue
	}
	WinGet, Path, ProcessPath, ahk_id %id%
	Menu, Windows, Add, %title%, Activate_Window
	Try 
		Menu, Windows, Icon, %title%, %Path%,, 0
	Catch 
		Menu, Windows, Icon, %title%, %A_WinDir%\System32\SHELL32.dll, 3, 0
}
Menu, Windows, Show
return

Activate_Window:
	SetTitleMatchMode, 3
	WinActivate, %A_ThisMenuItem%
return
Found a glitch! I notice Microsoft apps (Edge, Store, Settings, etc) is not listed when they are actually running and minimized in task bar but if they are not minimized then it is listed by this script!
GEV
Posts: 1002
Joined: 25 Feb 2014, 00:50

Re: List all open and visible window (Alt+Tab) in windwos 10  Topic is solved

04 Jul 2018, 10:48

Tested on both Build 17134.137 and Build 17692.1004:

Code: Select all

$F1::
Menu, Windows, Add
Menu, Windows, deleteAll
WinGet windows, List
Loop %windows%
{
	id := windows%A_Index%
	WinGetTitle title, ahk_id %id%
	If (title = "")
		continue
	WinGetClass class, ahk_id %id%	
	If (class = "ApplicationFrameWindow") 
	{
		WinGetText, text, ahk_id %id%		
		If (text = "")
		{
			WinGet, style, style, ahk_id %id%
			If !(style = "0xB4CF0000")	 ; the window isn't minimized
				continue
		}
	}
	WinGet, style, style, ahk_id %id%
	if !(style & 0xC00000) ; if the window doesn't have a title bar
	{
		; If title not contains ...  ; add exceptions
			continue
	}
	WinGet, Path, ProcessPath, ahk_id %id%
	Menu, Windows, Add, %title%, Activate_Window
	Try 
		Menu, Windows, Icon, %title%, %Path%,, 0
	Catch 
		Menu, Windows, Icon, %title%, %A_WinDir%\System32\SHELL32.dll, 3, 0
}
Menu, Windows, Show
return

Activate_Window:
	SetTitleMatchMode, 3
	WinGetClass, Class, %A_ThisMenuItem%
	If (Class="Windows.UI.Core.CoreWindow") ; the minimized window has another class 
		WinActivate, %A_ThisMenuItem% ahk_class ApplicationFrameWindow
	else
		WinActivate, %A_ThisMenuItem%
return
sobuj53
Posts: 55
Joined: 19 Mar 2015, 16:08

Re: List all open and visible window (Alt+Tab) in windwos 10

04 Jul 2018, 11:21

GEV wrote:Tested on both Build 17134.137 and Build 17692.1004:

Code: Select all

$F1::
Menu, Windows, Add
Menu, Windows, deleteAll
WinGet windows, List
Loop %windows%
{
	id := windows%A_Index%
	WinGetTitle title, ahk_id %id%
	If (title = "")
		continue
	WinGetClass class, ahk_id %id%	
	If (class = "ApplicationFrameWindow") 
	{
		WinGetText, text, ahk_id %id%		
		If (text = "")
		{
			WinGet, style, style, ahk_id %id%
			If !(style = "0xB4CF0000")	 ; the window isn't minimized
				continue
		}
	}
	WinGet, style, style, ahk_id %id%
	if !(style & 0xC00000) ; if the window doesn't have a title bar
	{
		; If title not contains ...  ; add exceptions
			continue
	}
	WinGet, Path, ProcessPath, ahk_id %id%
	Menu, Windows, Add, %title%, Activate_Window
	Try 
		Menu, Windows, Icon, %title%, %Path%,, 0
	Catch 
		Menu, Windows, Icon, %title%, %A_WinDir%\System32\SHELL32.dll, 3, 0
}
Menu, Windows, Show
return

Activate_Window:
	SetTitleMatchMode, 3
	WinGetClass, Class, %A_ThisMenuItem%
	If (Class="Windows.UI.Core.CoreWindow") ; the minimized window has another class 
		WinActivate, %A_ThisMenuItem% ahk_class ApplicationFrameWindow
	else
		WinActivate, %A_ThisMenuItem%
return
You did it again! Thank you very very much. :D
blueocean
Posts: 2
Joined: 26 May 2020, 09:55

Re: List all open and visible window (Alt+Tab) in windwos 10

26 May 2020, 10:11

This is a great script!

Can you please-please suggest some code to filter the apps list by typing?

Now the focus only goes to a menu item based on the first character.

The idea is to have a "filter" input box, type something there and filter the list.

Example: If I type "activities" then only the items that have "activities" in their title should show, which makes it faster to select an item, press enter and switch there.

Thanks a lot!!!
sobuj53
Posts: 55
Joined: 19 Mar 2015, 16:08

Re: List all open and visible window (Alt+Tab) in windwos 10

27 May 2020, 00:56

I understand this is not what you want but I've created a somewhat similar script, where a dropdown with list of open window are shown.

Code: Select all

;Ctrl+Shfit+D to activate
^+D::
DetectHiddenWindows, Off
; This will be the GUI name
WindArray := {}
SysGet, OutputVar, MonitorCount
WinName = Bring Open Window On Top
WinGet, OpenWindow, List 


	If !WinExist(WinName)
		 {
			Gui,+AlwaysOnTop
			Gui, Font, s11, Arial
			Gui, Add, DropDownList, gShowToolTip x7 y9 w260 vWindowMove,Pick a Window||
			Gui, Add, Button, x282 y8 w50 h28 gPosChoice, Open
		 }
	Else
		 {
			Gui, Destroy
			Gui,+AlwaysOnTop
			Gui, Font, s11, Arial	
			Gui, Add, DropDownList, gShowToolTip x7 y9 w260 vWindowMove,Pick a Window||
			Gui, Add, Button, x282 y8 w50 h28 gPosChoice, Open
		 }
	
	Loop, %OpenWindow% 
	{ 
		
		id := OpenWindow%A_Index%
		WinGetTitle Title, ahk_id %id%
		WinGet, style, style, ahk_id %id%
		WinGet, ClsID, ID, ahk_id %id%
		
		If !(style & 0xC00000) or (title = "")
			continue
		WinGetClass class, ahk_id %id%	
		If (class = "ApplicationFrameWindow") 
		{
			WinGetText, text, ahk_id %id%		
			If (text = "")
			{
				WinGet, style, style, ahk_id %id%
				If !(style = "0xB4CF0000")	 ; the window isn't minimized
					continue
			}
		}

		GuiControl,,WindowMove, %Title%
		WindArray.Insert(Title, ClsID)
	   

	} 

Gui, Show,  h45 w345, %WinName%
hwnd:=WinExist(WinName)
Return

ShowToolTip:
Gui,Submit,NoHide
;remove any previous tooltip
GoSub RemoveToolTip

if (InStr(WindowMove, "Pick a Window", true) = 0 and WindowMove!="")
{

	ControlGetPos,x,y,w,h,ComboBox1,ahk_id %hwnd%

	ToolTip %WindowMove%,x,y+h,10

	SetTimer,RemoveToolTip,-3000
}
Return


PosChoice:
Gui, Submit, NoHide
if (InStr(WindowMove, "Pick a Window", true) = 0 and WindowMove!="")
{
	;return Associative array value
	IDValue:= WindArray[WindowMove]

	if WinExist("ahk_id " IDValue)
	{
		WinActivate, Ahk_ID %IDValue%
		;MoveIt(IDValue)
		GoSub ^+D ; Recall it again to refresh status
	}
	else
	{	
		
		GoSub ^+D ; Recall it again to refresh status

	}
	GoSub RemoveToolTip
}
Return

RemoveToolTip:
	ToolTip,,,,10
Return

GuiClose:
	Gui, Destroy
Return
Image

hope this will give you an idea :D
Now you just need to find a way to create a dropdown list with search option.
blueocean
Posts: 2
Joined: 26 May 2020, 09:55

Re: List all open and visible window (Alt+Tab) in windwos 10

09 Jun 2020, 02:59

Thank you, how is this different to the other script that also shows all opened windows?

Correct me if I did not get it right.

The idea here is to have something like Google's "vimium-c" extension but in Windows (for loaded windows):
2020-06-09_10-56-53.jpg
2020-06-09_10-56-53.jpg (53.87 KiB) Viewed 747 times
This would be powerful if it had:

1. Search (with fuzzy logic maybe)
2. Close window (using "del" on the selected the menu item), this would help clear opened windows easily

Thanks!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, Google [Bot], Peiya, ShatterCoder and 301 guests