Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Alt-Tab replacement related- getting only alt-tab windows


  • Please log in to reply
8 replies to this topic
evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
I've looked over several of the Alt-Tab replacement scripts in the forum and was having a go at my own, but I noticed one rather large flaw in these is that they include all "windows", not just those that appear in the normal windows alt-tab list.

e.g. Winamp is listed when it shouldn't be, and not only once, but twice for me because of its main window and playlist. PSPad and Avant Browser have similar problems. In total I have 10 proper Alt-Tab windows but 14 listed by Alt-Tab replacement scripts and my own (basically they all use: winget, wind, List,,,Program Manager)

So, is there a way of somehow excluding those windows which aren't helpful for Alt-Tab? (it's nothing to do with invisible windows). It would be possible to make a really nice Alt-Tab replacement to fulfil my needs with AutoHotkey without this issue.

Serenity
  • Members
  • 1271 posts
  • Last active:
  • Joined: 07 Nov 2004
keyboardfreak wrote a script to switch windows, and this issue came up. You might want to look at the source for a workaround.. link
"Anything worth doing is worth doing slowly." - Mae West
Posted Image

shimanov
  • Members
  • 610 posts
  • Last active: Jul 18 2006 08:35 PM
  • Joined: 25 Sep 2005
The windows listed in the Task Switcher window seem to correlate with those on the Taskbar. The following information may be relevant.

Managing Taskbar Buttons

The Shell creates a button on the taskbar whenever an application creates a window that isn't owned. To ensure that the window button is placed on the taskbar, create an unowned window with the WS_EX_APPWINDOW extended style. To prevent the window button from being placed on the taskbar, create the unowned window with the WS_EX_TOOLWINDOW extended style. As an alternative, you can create a hidden window and make this hidden window the owner of your visible window.


Try WinGet with the ExStyle parameter.

WS_EX_APPWINDOW = 0x40000
WS_EX_TOOLWINDOW = 0x80

Also, GetParent to determine if the window is owned.

evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
Serenity: I looked over keyboardfreak's script some more (it was one I had been looking at anyhow) and noticed the use of a filter list for excluding windows. I could probably implement something like this to get rid of the extra items, but it's far from ideal.


shimanov: I'll try looking into that. I think you're right that it's only programs listed on the taskbar that appear in Alt-Tab.

shimanov
  • Members
  • 610 posts
  • Last active: Jul 18 2006 08:35 PM
  • Joined: 25 Sep 2005

I think you're right that it's only programs listed on the taskbar that appear in Alt-Tab.


In fact, they should be exactly the same.

To switch between running programs

Click a program's button on the taskbar.

Notes

If you cannot see the taskbar... You can also switch to the last open program or document by pressing ALT+TAB



evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005

Try WinGet with the ExStyle parameter.

WS_EX_APPWINDOW = 0x40000
WS_EX_TOOLWINDOW = 0x80

Also, GetParent to determine if the window is owned.


Regarding ExStyle, so far I've not managed to spot a reliable pattern for which windows are and aren't displayed - 0x00000100 (WS_EX_WINDOWEDGE) is also common, and then there are other combinations/variations (not sure of the terminology).

I tried having a look at GetParent, but to be honest I think it's a little beyond my AHK skills at the moment :oops:

evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
I've come across a site which seems to indicate that this is along the right kind of lines and goes into reasonable detail on the route to filter unwanted windows, but the GetParent stuff eludes me still :wink:

http://www.thescarms...asic/alttab.asp

shimanov
  • Members
  • 610 posts
  • Last active: Jul 18 2006 08:35 PM
  • Joined: 25 Sep 2005

GetParent stuff eludes me still :wink:


Just a matter of time and practice.

It seems that there is a one-to-one correlation with respect to the number of windows in the taskbar and the Alt+Tab task switcher (ATTS). Unfortunately, there is some discrepancy between the "title" information displayed on the buttons of the taskbar and the information field of ATTS. From what I can tell, the "title" information present in ATTS is taken from the last active (highest z-order) window associated for a particular process, unless that process has more than one window which meets the taskbar criteria. But I have not discovered a reliable method to determine from which window ATTS retrieves its "title" information. In fact, Microsoft's own PowerToy replacement for ATTS displays "title" information that directly matches that of the taskbar and not the standard ATTS -- fun.

Try the following and you decide:

DetectHiddenWindows, Off

WS_EX_APPWINDOW = 0x40000
WS_EX_TOOLWINDOW = 0x80

GW_OWNER = 4

WinGet, list, List

text=
loop, %list%
{
	wid := list%A_Index%
	
	WinGet, es, ExStyle, ahk_id %wid%
	
	if ( ( ! DllCall( "GetWindow", "uint", wid, "uint", GW_OWNER ) and ! ( es & WS_EX_TOOLWINDOW ) ) 
			or ( es & WS_EX_APPWINDOW ) )
	{
		WinGetClass, class, ahk_id %wid% 
		WinGetTitle, title, ahk_id %wid%
		
		text = %text%`n[%wid%, %class%] %title%
	}
}

MsgBox, %text%
return


evl
  • Members
  • 1237 posts
  • Last active: Oct 20 2010 11:41 AM
  • Joined: 24 Aug 2005
shimanov, that's a really elegant solution! Thanks! I'm starting to get my head around those dll calls now I think :)