如何使用pywinauto 0.5.4在两个应用程序之间切换 [英] how to switch between two application using pywinauto 0.5.4

查看:441
本文介绍了如何使用pywinauto 0.5.4在两个应用程序之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图自动化一项任务,即从记事本中逐行复制每一行并将其粘贴到应用程序中,然后单击一个按钮,然后将输出复制到第三个记事本文件中.
我正在使用pywinauto 0.5.4的python用于这种自动化操作,而我在如何在不同的应用程序之间进行切换方面没有任何帮助

I am trying to automate a task of copying every single line one by one from Notepad and pasting it the application and then clicking at a button and then copying the output to a third notepad file.
I am using pywinauto 0.5.4 of python for this automation and I am not getting any help on how to switch between different application

from pywinauto import application

app = application.Application()
app = application.Application()
app.start("Notepad.exe")
app.start("C:\Program Files (x86)\eSpeak\eSpeakedit.exe")

我正在使用此代码来启动两个应用程序.如何随意在这两个应用程序之间切换?

I am using this code for starting two apps. How to switch between these two application at will?

推荐答案

此代码应能解决问题:

from pywinauto import application

app = application.Application()
app2 = application.Application()
app.start("Notepad.exe")
app2.start(r"C:\Program Files (x86)\eSpeak\eSpeakedit.exe")

# switch to Notepad
app.UntitledNotepad.SetFocus()
# select and copy next line (this is not the only way, just for example)
app.UntitledNotepad.Edit.TypeKeys('{DOWN}{HOME}+{END}^c')

 # switch to your app
app2.SpeakEditWindowTitle.SetFocus()
# paste somewhere

这篇关于如何使用pywinauto 0.5.4在两个应用程序之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆