2017-04-17 4 views
0

저는 pywinauto를 사용하여 Windows에서 표준 카메라 앱을 자동화하려고합니다.pywinauto 동적 컨트롤이 있는지 확인하십시오.

나는 성공적으로 존재하는 컨트롤에 대한 클릭 수 등을 호출 할 수 있습니다,하지만 난 그게에있어 어떤 모드를 감지 할 필요가 있도록 비디오로 사진에서 전환 할 때 카메라 응용 프로그램은 동적으로 캡처 버튼을 전환합니다. 여기

from subprocess import Popen 
from pywinauto import Desktop 
from pywinauto.application import Application 

# ====== Take a Photo ======= 
# Need to get at the Camera app from desktop as there's multiple processes in the UI 
dlg = Desktop(backend="uia").Camera 
dlgWin = dlg.child_window(title="Camera", class_name="Windows.UI.Core.CoreWindow") 

# This fails: 
#existFlag = dlgWin.child_window(title="Take Photo", control_type="Button").Exists(timeout =2) 

# Take photo, this works if the control exists: 
buttonTakePhoto = dlgWin.child_window(title="Take Photo", control_type="Button") 
buttonTakePhoto.click() 

컨트롤의 사진 모드의 구조 :

enter image description here

및 비디오 모드 :

enter image description here

창의 하위 컨트롤이 있는지 어떻게 감지합니까? 필자가 본 모든 예제는 데스크톱의 자식으로 창을 가져온 이후로 가지고 있지 않은 응용 프로그램 인스턴스를 사용합니다.

답변

1

결코 마음은, 나는이 시도 맹세하지만, 작동 :

buttonTakePhoto.exists()를

+1

기본 제한 시간은 5 초이다. 따라서 timeout = 2는 2 초 후에도 존재하지 않으므로 작동하지 않을 수 있습니다. 하지만'.exists()'대신'buttonTakePhoto.wait ('visible', timeout = 5)'를 사용하는 것이 좋습니다. –

관련 문제