我是sikuli的新手,有没有办法找到Microsoft Outlook是否已经打开?如果打开它作为活动窗口,则打开Outlook。
下面是我试过的代码,有时候Maximize()会正常工作。否则即使它已经存在,也会打开Outlook
OutlookOpen()
def OutlookOpen():
if exists("1424161703182.png"):
Maximize()
else:
openO()
def Maximize():
switchApp("Microsoft Outlook")
wait(1)
type(" ", KEY_ALT)
type("x")
print("Maximized")
def openO():
OpenApp(r'C:\Program Files (x86)\Microsoft Office\Office14\outlook.exe')
wait(2)
print("opened")
答案 0 :(得分:1)
你能做的就是看看前景是否存在(抓住一些独特的东西,图片最容易)。如果不存在则查看最小化条上是否存在outlook(图片大多不同,而sikuli是敏感的)。
例如:
Image_TB_Open = ("image1")
Image_TB_Minimized = ("image2")
class ThunderBird():
def __init__(self):
self.TBird()
def TBird(self):
if exists(Image_TB_Open):
print('ThunderBird is open!')
elif exists(Image_TB_Minimized):
print('ThunderBird is open but minimized!')
else:
print('ThunderBird is closed!')
# Run class
ThunderBird()
编辑:
# vcProgram = Program name.
def programActive(self, vcProgram):
self.vcProgram = vcProgram
searchResult = App.focus(vcProgram)
if (vcProgram in str(searchResult)):
return 'True'
else:
return 'False'
要使用此定义,我使用:
fActive = self.programActive('Firefox')
如果fActive
为True
,则该程序已经打开。