2016-04-22 49 views
1

我有這個小腳本應該打開一個應用程序並鍵入一些字母。但是,由於某些原因,腳本不會運行一段代碼。它起來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 

回答

2

通過ommitting任何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,您應該沒事