2014-10-01 64 views
0

定義變量並將其打印出來AutoHotKey - 定義變量並將其打印出來

嘿傢伙!

我剛剛找到AHK,我喜歡它!

我目前正在寫一個劇本,這讓我從下拉一些不同的選項,然後它將從下拉列表中的特定字段自動進入價值:

現在我的問題是,當我如選擇「SPIRIT」 - 由於某種原因,它進入這些數字:

「643232442221」,而不是數字它應該:「6432324422」

這就像它添加額外的數字到外地。這是爲什麼???

#T:: 
Gui, Add, Text, x26 y177 w420 h30 , Vælg Handling Agent 
Gui, Add, DropDownList, x26 y217 w420 h20 vCfs, WFS|Spirit 
Gui, Show, x131 y91 h381 w481, New GUI Window 

Submit: 
Gui, Submit 

varCfs = %cfs% 
varConsol = %consol% 
varMawb = %mawb% 

if(varCfs = "WFS"){ 
    varCfs = 6402111562 
} else if (varCfs = "SPIRIT"){ 
    varCfs = 6432324422 
} 

Gui, Hide 

;After submit. If the console # is already opened in EDIe, make that window active 
;if not, let's generate an error, saying that the user must lookup the console. 
IfWinExist, Edit Consol %consol% 
{ 
    WinActivate ; use the window found above 
    ;Arrival Info 
    Click 697,76 
    Click 651,109 
    Send {Ctrl Down}a{Ctrl Up} 
    Sleep 200 
    Send {Delete} 
    Sleep 350 
    Send %varCfs%  

    +F11::Send, %mawb% ;Shift+F11 


} else { 
    WinActivate, ediEnterprise 
    MsgBox, 4, Find Consol #, Error! 
    Gui, Destroy 
    Gui, show 
    Return ;Then stop! 
} 



Return 

GuiClose: 
ExitApp 
+0

什麼是'varMawb'?它有沒有「21」? – Dane 2014-10-01 16:57:53

+0

是的,它是217xxxxxxx – oliverbj 2014-10-02 04:43:56

+1

試試@ vasili111的答案。你不能像'+ F11 ::'那樣在'IfWinExist'內聲明一個熱鍵。我敢打賭,在發送'%varCfs%'之後,你馬上會得到'發送,%mawb%'。要聲明一個有條件的熱鍵,用戶'#IfWinExist'(http://www.autohotkey.com/docs/commands/_IfWinActive.htm)。 – Dane 2014-10-02 16:45:42

回答

0

我無法重現環境來測試您的代碼。但是我做了一些修正,可能會對你有所幫助。試試這個代碼:

#T:: 
Gui, Add, Text, x26 y177 w420 h30 , Vælg Handling Agent 
Gui, Add, DropDownList, x26 y217 w420 h20 vCfs, WFS|Spirit 
Gui, Show, x131 y91 h381 w481, New GUI Window 

Submit: 
Gui, Submit 

varCfs := cfs 
varConsol := consol 
varMawb := mawb 

if(varCfs = "WFS"){ 
    varCfs := 6402111562 
} else if (varCfs = "SPIRIT"){ 
    varCfs := 6432324422 
} 

Gui, Hide 

;After submit. If the console # is already opened in EDIe, make that window active 
;if not, let's generate an error, saying that the user must lookup the console. 
IfWinExist, Edit Consol %consol% 
{ 
    WinActivate ; use the window found above 
    ;Arrival Info 
    Click 697,76 
    Click 651,109 
    Send {Ctrl Down}a{Ctrl Up} 
    Sleep 200 
    Send {Delete} 
    Sleep 350 
    Send %varCfs%  




} else { 
    WinActivate, ediEnterprise 
    MsgBox, 4, Find Consol #, Error! 
    Gui, Destroy 
    Gui, show 
    Return ;Then stop! 
} 



Return 

+F11::Send, %mawb% ;Shift+F11 

GuiClose: 
ExitApp 
相關問題