简体   繁体   中英

Get list of open windows in Python

I am writing an app in Python that must be able to send keys or text to another app. For example, if I have Firefox open, I should be able to send it an URL to open it.

I already have the SendKeys module, and I have read about the win32 module too, but I do not know if there is a way to filter out process without open windows.

Usually, for this sort of "GUI automation" pyWinAuto is a good way to go. We use it to allow automated testing of GUI applications, and it ought to let you "type" URLs into Firefox (not to mention finding its window) as well.

try using dragonfly . It has a whole lot of automation stuff built into it. You don't need the speech recognition part in order to use the automation stuff. For example:

from dragonfly import Window
Window.get_all_windows()

will return a list of all the windows.

you also want to look at the FocusWindow() and Keys() objects in dragonfly.

即使您需要将自动化用于应用程序将要执行的其他操作,使用webbrowser模块在用户的浏览器中打开URL也可能要容易webbrowser

I like PyAutoGUI. You can see their docs here . I've typed with it before

From the docs:

import pyautogui

pyautogui.typewrite('Hello world!', interval=0.25)  # type with quarter-second pause in between each key

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM