2016-04-23 72 views
0

在開始新過程之前,我需要在AHK中找到等待程序完成的方法。等待先前的過程在開始新過程之前完成

基本上,我有一個腳本可以打開一個應用程序並輸入一些參數。應用程序然後花費未知的時間處理輸入數據。

不幸的是,在應用程序完成處理之前,ahk腳本結束,此時同一個ahk腳本再次運行,並且不工作/中斷以前的處理。

編輯:(Python中的.exe文件AHK被稱爲使用子調用)

是有辦法或任何方法,以幫助這個?

僅供參考,腳本:

#NoEnv 
CoordMode, Mouse, Window 
SendInput Mode Input 
#SingleInstance Force 
SetTitleMatchMode 2 
#WinActivateForce 
SetControlDelay 1 
SetWinDelay 0 
SetKeyDelay -1 
SetMouseDelay -1 
SetBatchLines -1 

if 0 < 2 ; The left side of a non-expression if-statement is always the name  of a variable. 
{ 
    MsgBox, This script requires 2 incoming parameters but it only received  %0%. 
    ExitApp 
} 
IfWinNotExist, ahk_exe photoscan.exe 
{ 
    Run, "C:\Program Files\Agisoft\PhotoScan Pro\photoscan.exe" 
} 
sleep, 200 
WinActivate, ahk_exe photoscan.exe 
sleep,5 
WinMaximize, ahk_exe photoscan.exe 
;Macro5: 
Click, 476, 438, 0 
SendInput {LControl Down} 
SendInput {r} 
Click, -56, 157, 0 
WinActivate, Run Python Script ahk_class QWidget 
sleep, 400 
SendInput {LControl Up} 
SendInput {LControl Down} 
SendInput {a} 
SendInput {LControl Up} 
sleep, 400 
SendInput {Backspace} 
SendInput %1% ; 1st argument is the photoScan API scriptimages folder  directory 
SendInput {Tab} 
SendInput {Tab} 
sleep, 400 
SendInput {LControl Down} 
SendInput {a} ; 2nd argument is additional args (in our case, the  projectName) 
SendInput {LControl Up} 
SendInput {Backspace} 
SendInput %2% ; 2nd argument is the images folder directory & name of output log, model and texture 
Sleep, 703 
SendInput {Enter} 
Click, 476, 438, 0 
Return 
+0

這是什麼語言?這當然不是Python。 –

+0

AutoHotKey(AHK)。但是它被Python中的子進程模塊調用。我將Python鏈接起來,因爲我不知道Python中是否可以使用和AHK一樣的東西 –

回答

0

您有:

IfWinNotExist, ahk_exe photoscan.exe 
{ 
    Run, "C:\Program Files\Agisoft\PhotoScan Pro\photoscan.exe" 
} 
sleep, 200 

這是設置爲開機/啓動應用程序,如果它沒有運行。然後睡覺,讓它加載十分之二秒(這可能太小)。

,而不只是一個「睡眠」,你必須「WinWait」或「WinWaitActive」,在這個環節發現: https://autohotkey.com/docs/commands/WinWaitActive.htm

喜歡這個樣本:

Run, "C:\Program Files\Agisoft\PhotoScan Pro\photoscan.exe" 
WinWaitActive, ahk_exe photoscan.exe, , 2 
if ErrorLevel 
{ 
    MsgBox, WinWait timed out. 
    return 
} 
else 
    WinMinimize ; minimize the window found by WinWaitActive. 

您可能還需要使用窗口檢查器獲取窗口/應用程序/進程名稱的真實名稱。

相關問題