I am using the following code to activate windows via the taskbar:
def activateTaskbarWindow(index): # this starts counting at 1
index=int(index) # ensure integer not string
# there are exactly twice as many windows for some reason
bc=[taskbar.RunningApplications.GetButtonRect(i) for i inrange(numTrayApps)]
r = bc[2*(index-1)+1] # get rectangle of desired window
# activate foreground window with a click
As you can see, I'm using the mouse to click on the taskbar with the
Is there an alternative method that does not use the mouse?
Thanks in advance.
The taskbar module is really experimental - and I think this is one of the first questions about it :)
tb.RunningApplication.Button(i).Click() - doesn't use ClickInput()
RunningApplications is a toolbar control - and I don't understand toolbar controls very well either.
If you print the "Texts()" for tb.RunningApplications - you can see that there are two texts for each button. Clicking one of them highlights the button but doesn't necessarily make the application pop to the front (though it could be because I am using cmd line rather than a script.
There may be some Notification message I need to send to the Toolbar (or it's parent) to make it more like a real click.
thanks for your reply.
Is there a more direct way to get the handle for an application on the taskbar?
I'm trying to sort, restore, and close these applications.
It might be much easier to just get the top level windows and then ignore the two special ones with classes "Progman" and "Shell_TrayWnd".
from pywinauto.findwindows import find_windows
from pywinauto.handleprops import classname
# get the handles and filter out the pseudo top level windows
all_top_level = [hwnd in find_windows() if classname(hwnd) not in ("Progman","Shell_TrayWnd")]
# Convert these handles to HwndWrappers (if you want to do this - up to you :) )
from pywinauto.controls.HwndWrapper import HwndWrapper
wrapped_handles = [HwndWrapper(hwnd) for hwnd in all_top_level]
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.