- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
致力于 Python 驱动的自动化工具。
假设有一个正在运行的应用程序池:
APPS_POOL = ['Chrome', 'SomeApp', 'Foo']
脚本在循环中运行(每秒),需要在它们之间随机切换:
# Init App object
app = application.Application()
# Select random app from the pull of apps
random_app = random.choice(APPS_POOL)
app.connect(title_re=".*%s" % random_app)
print 'Select "%s"' % random_app
# Access app's window object
app_dialog = app.window_(title_re=".*%s.*" % random_app)
if app_dialog.Exists():
app_dialog.SetFocus()
第一次它工作正常,但每隔一次 - 窗口不会被带到前台。有什么想法吗?
编辑:脚本是从 Win7 CMD 运行的。一旦焦点设置到其他窗口,系统是否可能以某种方式“阻止”CMD 设置焦点?
最佳答案
我认为 SetFocus
有点问题。至少在我的机器上出现错误:error: (87, 'AttachThreadInput', 'The parameter is incorrect.')
。所以也许你可以玩最小化/恢复。请注意,这种方法也不是防弹的。
import random
import time
from pywinauto import application
from pywinauto.findwindows import WindowAmbiguousError, WindowNotFoundError
APPS_POOL = ['Chrome', 'GVIM', 'Notepad', 'Calculator', 'SourceTree', 'Outlook']
# Select random app from the pull of apps
def show_rand_app():
# Init App object
app = application.Application()
random_app = random.choice(APPS_POOL)
try:
print 'Select "%s"' % random_app
app.connect(title_re=".*%s.*" % random_app)
# Access app's window object
app_dialog = app.top_window_()
app_dialog.Minimize()
app_dialog.Restore()
#app_dialog.SetFocus()
except(WindowNotFoundError):
print '"%s" not found' % random_app
pass
except(WindowAmbiguousError):
print 'There are too many "%s" windows found' % random_app
pass
for i in range(15):
show_rand_app()
time.sleep(0.3)
关于python - Pywinauto:无法将窗口带到前台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39794729/
我正在使用 pywinauto 进行自动化单击 DiffDaff 软件上的某个按钮。 我的意图是: 第一步:打开DiffDaff软件 第二步:点击“关于”按钮 from pywinauto.appli
非常直接的问题。 只想按一个键盘键。像输入一样,使用 pywin auto。我不想在任何应用程序窗口的上下文中按下它。 只是键盘键的原始按键,如 a 或 enter 或退格。 最佳答案 只需使用 #
几个月前,我编写了一个 Python GUI 应用程序来读取包含车辆数据的文件。然后它使用 sendkeys 模块在温室气体模型应用程序中输入数据。我已将代码转换为使用 pywinauto 并使用 p
我正在尝试使用 pywinauto 自动化 Visual Basic 应用程序,后端 =“win32”。除了从组合框中选择一项之外,我可以处理所有事情。这个特定的组合框取决于另一个组合框的选择 这是代
我是pywinauto新手,刚开始学习。我在本地 32 位 Windows 7 操作系统中安装了带有 pip 的 pywinauto。所以,我有这个示例代码可以在 chrome 浏览器中打开一个 UR
我正在使用 python 自动化工具 pywinauto 来将字符插入到其他应用程序文本框中。 我发现执行此操作的最佳方法是在复制要插入到剪贴板的文本并将焦点设置到其他应用程序窗口后调用 ctrl+v
全部, 我已经使用“pip install pywinauto”成功安装了 package:pywinauto,但总是失败,为什么?我是这样做的: pip 安装 pywinauto 然后在 windo
我是基于 Windows 桌面的测试自动化的新手,也是 Python 的新手,在花了很多时间之后,pywinauto 变成了使用 Python 进行基于 Windows 的应用程序测试的明显选择。 我
我想在窗口中找到子元素,但只能是某种类型/ 类(class)。 我使用该代码: def get_visible_buttons(window): children = window.Child
我有一个 Jenkins 管道,它在远程服务器中执行一个程序,该服务器使用 pywin 来操作应用程序以进行功能测试。 当我打开远程桌面时,我的应用程序运行良好,但是当我关闭远程桌面并从 Jenkin
我正在尝试使用 pywinauto 在每次更新类文件时自动启动和停止 TomCat。但是,当我尝试运行它时,它会给出以下警告: 用户警告:32 位应用程序应使用 32 位 Python 自动化(您使用
我正在使用 pywinauto 并且我想从其中一个属性中选择文本。但是,我不知道如何访问它。 import pywinauto pwa_app = pywinauto.application.Appl
我正在使用 pywinauto 将文件上传到网络服务器。我使用 Selenium 导航到页面并激活 Windows 资源管理器上传对话框,然后调用 pywinauto 来访问打开的窗口。我已经能够做到
我正在使用具有自定义堆栈面板的 WPF 应用程序,该面板基本上是一个列表。列表中的项目完全相同,因此我无法选择特定文本来唯一标识元素。其他一些值(例如时间)是动态的。 有没有办法让我获取返回的元素列表
我是 python 和 pywinauto 的新手,我需要在运行程序后使用 pywinauto 和 Chrome_widgetWin_1 在 Chrome 中启动演示 - Chrome 启动但只显示一
我正在尝试使用带有 pywinauto 框架的 python 来控制 Windows 媒体播放器。例如,我可以使用 app.WindowsMediaPlayer.MenuSelect("View->G
我尝试让远程桌面窗口保持事件状态,即避免屏幕保护程序和因不活动超时而关闭连接(我不允许配置远程桌面 session 的行为)。 使用 pywinauto 我只意识到连接到应用程序,但现在例如app.C
我正在尝试使用 pywinauto 远程控制有时在启动时显示警告窗口的 Windows 应用程序。 下面的代码标识了窗口,因为它没有菜单。 我想阅读弹出文本以查找短语“请联系您的系统管理员”。在那个弹
目前我正在使用 Pywinauto 和 Behave 来测试桌面应用程序,但我遇到了障碍。在我的自动化中,有一次我需要使用双击,目前我的工作方式是这样的: @step("User selects {r
我试图在 excel 文档中滚动(使用 pywinauto),但它似乎不起作用。 代码: app = Application(backend="uia").connect(process=8876)
我是一名优秀的程序员,十分优秀!