脚本不会运行一段代码

时间:2016-04-22 22:20:32

标签: autohotkey

我有这个小脚本应该打开一个应用程序并输入一些字母。但是,由于某种原因,脚本不会运行一段代码。它起来winMaximize然后停止。但如果应用程序已经打开,那么该部分运行?不确定我做错了什么,想法?

#NoEnv
CoordMode, Mouse, Window
SendMode 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
{
    RunWait, "C:\Program Files\Agisoft\PhotoScan Pro\photoscan.exe"
}
WinActivate  ; Automatically uses the window found above.
sleep,5
WinMaximize
;Macro5:
Click, 499, 426, 0
Click, 497, 427, 0
Click, 496, 427, 0
Click, 493, 428, 0
Click, 492, 429, 0
Click, 487, 431, 0
Click, 485, 433, 0
Click, 482, 435, 0
Click, 481, 435, 0
Click, 480, 435, 0
Click, 479, 436, 0
Click, 478, 436, 0
Click, 477, 437, 0
Click, 477, 438, 0
Click, 476, 438, 0
Send, {LControl Down}
Send, {r}
Click, -56, 157, 0
WinActivate, Run Python Script ahk_class QWidget
Send, {LControl Up}
Send, {LControl Down}
Send, {LControl Up}
Send, {LControl Down}
Send, {a}
Send, {LControl Up}
Send, {Backspace}
Send, {%1%} ; 1st argument is the images folder directory
Send, {Tab}
Send, {Tab}
Send, {LControl Down}
Send, {%2%} ; 2nd argument is additional args (in our case, the projectName)
Send, {LControl Up}
Send, {Backspace}
Send, {b}
Sleep, 703
Send, {Enter}
Click, 476, 438, 0
Return

1 个答案:

答案 0 :(得分:2)

通过省略任何wintitle参数,您在"The Last Found Window"上呼叫winactivatewinmaximize。我认为winMaximize根本没有执行因为没有找到窗口(它被称为“最后找到的窗口”,而不是“最后找到的窗口,或者可能不是”)。

Afaican看,您的堆栈跟踪是

> 
> IfWinNotExist, ahk_exe photoscan.exe ; does not exist. -> last found window: NONE
> RunWait, "C:\Program Files\Agisoft\PhotoScan Pro\photoscan.exe"
> ; still: last found window: NONE
> WinActivate / WinMaximize ; called on NONE

不确定为什么winActivate会终止。无论哪种方式,如果你添加ahk_exe photoscan.exe来winactivate和winmaximize,你应该没问题