Python-UIAutomation-for-Windows icon indicating copy to clipboard operation
Python-UIAutomation-for-Windows copied to clipboard

开启多个相同窗口实例,无法准确控制其中的一个

Open shihunyewu opened this issue 6 years ago • 2 comments
trafficstars

我在程序中开启了多个相同程序的进程,但是在尝试控制的时候,总是随机选择一个进程,就是很迷。虽然有 foundIndex 参数,但是用了之后,还是不好使。。请问这个怎么解决呢?

shihunyewu avatar Aug 26 '19 02:08 shihunyewu

通过control.ProcessId区分

yinkaisheng avatar Aug 26 '19 07:08 yinkaisheng

subprocess.Popen('Notepad 新建文本文档 - 副本.txt') window1 = uiautomation.WindowControl(searchDepth=1, ClassName='Notepad') print(window1.ProcessId) subprocess.Popen('Notepad 新建文本文档.txt') window2 = uiautomation.WindowControl(searchDepth=1, ClassName='Notepad') print(window2.ProcessId)

@yinkaisheng 大佬,打开两个不同的TXT文件,打印出来的ProcessID是一样的呢

Harry2010410 avatar May 15 '20 06:05 Harry2010410