2014-10-01 111 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