2016-04-23 18 views
0

Ich muss einen Weg in AHK finden, um auf das Ende eines Programms zu warten, bevor ich ein neues starte.Warten Sie, bis der vorherige Prozess beendet ist, bevor Sie einen neuen starten

Grundsätzlich habe ich ein Skript, das eine Anwendung öffnet und einige Parameter eingibt. Die Anwendung verbringt dann eine unbekannte Zeitmenge mit der Verarbeitung der Eingabedaten.

Leider endet das ahk-Skript im Moment, bevor die Anwendung die Verarbeitung beendet hat. An diesem Punkt wird das gleiche ahk-Skript erneut ausgeführt und funktioniert nicht/unterbricht die vorherige Verarbeitung.

edit: (die ahk .exe verwendet subprocess Anrufe in Python genannt)

ist es eine Möglichkeit, oder irgendwelche Methoden dabei zu helfen?

Als Referenz das Skript:

#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

Welche Sprache ist das? Es ist sicherlich nicht Python. –

+0

AutoHotKey (AHK). Aber es wird von dem Subprozessmodul in Python aufgerufen. Ich habe Python verlinkt, weil ich nicht wusste, ob es etwas in Python gab, das ich verwenden konnte, genauso wie AHK –

Antwort

0

Sie haben:

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

das gesetzt wird, um die Anwendung zu starten/starten, wenn es nicht läuft. Dann ein Schlaf um zwei Zehntelsekunden dafür zu laden (was wahrscheinlich zu klein ist).

Statt nur einen 'Schlaf' Sie müssen 'WinWait' oder 'WinWaitActive', unter diesem Link: https://autohotkey.com/docs/commands/WinWaitActive.htm

Gefällt Ihnen dieses Beispiel:

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. 

Sie müssen unter Umständen auch verwenden der Fensterinspektor, um den richtigen Namen des Fenster-/Anwendungs-/Prozessnamens zu erhalten.