2016-04-23 71 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. 

您可能还需要使用窗口检查器获取窗口/应用程序/进程名称的真实名称。

相关问题