2017-04-06 138 views
0

所以这是我第一个AHK程序,我对语言一点也不熟悉。不过我对C#很熟悉。我有以下`程序循环通过一个文件并分割用管道(|)符号分割的用户名和密码。现在,当我运行程序时,它不会在文件结束后停止循环。AutoHotKey - 循环文件在文件结束后不再停止,发送不发送变量

另外,我尝试使用StrSplit函数访问由管道符号分隔的用户名和密码。到目前为止,当我运行该程序时,用户名有时只是entered正确进入浏览器。密码不会输入到浏览器中。我很确定`我正在使用鼠标右键。

在此先感谢您的帮助!

#SingleInstance, Force 
SetWorkingDir, %A_ScriptDir% ; if an absolute path isn't specified 

;; GUI input 
;------------------------------- 
; --------------------------------------- 
Gui, Add, Button, x10 y20 gStart, Start the tool 
Gui, Show, w300 h300, Steam Tool  
return 

; Labels 
; ----------------------- 
; -------------------------------- 

Start:  
Loop, read, accounts.txt ; the file name must be separated by a comma 
{ 
    ; MsgBox %A_LoopReadLine% 
    loop, parse, A_LoopReadLine, 
    {     
     IfWinNotExist, Multiloginapp - 01.3.15 
     { 
      Run, C:\Program Files (x86)\Multiloginapp\multiloginapp.exe 
      WinWait, Multiloginapp - 01.3.15 
      Sleep, 20000 
     } 
     IfWinNotActive, Multiloginapp - 01.3.15, ,WinActivate, Multiloginapp - 01.3.15 
     WinWaitActive, Multiloginapp - 01.3.15 
     Click 724, 260 
     sleep, 1500 
     WinWait, Multiloginapp - Mozilla Firefox 
     WinActivate, Multiloginapp - Mozilla Firefox 
     WinWaitActive, Multiloginapp - Mozilla Firefox 
     Click 408, 55 
     Sleep 5000 
     Send, ^a 
     Send, {Backspace} 
     SendInput, store.steampowered.com/account ; SendInput is faster in sending text 
     Send, {enter} 
     Sleep, 5000 
     ; Use: 
     ; SendInput, %A_LoopField% 
     ; if you want to send the current substring (field) from the line 
     s:=StrSplit(A_LoopReadLine, "|") 
     Click, 149, 355 
     urnme := s[0] 
     Send, %usrnme% 
     Click, 172 455 
     pwd := s[1] 
     Send, %pwd% 
     Click, 87 507 


    } 
} 
return 
+0

L对我来说就像你在使用循环,解析错误。我会尝试循环,解析,A_LoopReadLine,CSV,因为你提到你的文件是逗号分隔。 – errorseven

回答

0

试试这样说:

#SingleInstance, Force 
SetWorkingDir, %A_ScriptDir% ; if an absolute path isn't specified 

;; GUI input 
;------------------------------- 
; --------------------------------------- 
Gui, Add, Button, x10 y20 gStart, Start the tool 
Gui, Show, w300 h300, Steam Tool  
return 

; Labels 
; ----------------------- 
; -------------------------------- 

Start: 
IfWinNotExist, Multiloginapp - 01.3.15 
{ 
    Run, C:\Program Files (x86)\Multiloginapp\multiloginapp.exe 
    WinWait, Multiloginapp - 01.3.15 
    Sleep, 20000 
} 
IfWinNotActive, Multiloginapp - 01.3.15, ,WinActivate, Multiloginapp - 01.3.15 
WinWaitActive, Multiloginapp - 01.3.15 
Click 724, 260 
sleep, 1500 
WinWait, Multiloginapp - Mozilla Firefox 
WinActivate, Multiloginapp - Mozilla Firefox 
WinWaitActive, Multiloginapp - Mozilla Firefox 
Click 408, 55 
Sleep 5000 
Send, ^a 
Send, {Backspace} 
SendInput, store.steampowered.com/account ; SendInput is faster in sending text 
Sleep, 300 
Send, {enter} 
Sleep, 5000 

; If the title of the window changes after this, you should use: 
; WinWait, new title 
; WinActivate, new title 
; WinWaitActive, new title 

Click, 149, 355 

; ... continue using one of the next options  
; ... 

return 

第一种选择 - 发送用户名和密码直接(不读文件):

SendInput, username 
Sleep, 300 
Click, 172, 455 ; or Send, {Tab} if it activates the password field 
Sleep, 300 
SendInput, password 
Click, 87, 507 ; or Send, {enter} if it activates the log-in field 

第二个选项 - 如果你有阅读的用户名和密码:

FileReadLine, OutputVar, accounts.txt, 1 ; If username|password (without spaces) is the first line in this file 
usrnme := StrSplit(OutputVar,"|").1 
pwd := StrSplit(OutputVar,"|").2 
SendInput, %usrnme% 
Sleep, 300 
Click, 172, 455 ; or Send, {Tab} if it activates the password field 
Sleep, 300 
SendInput, %pwd% 
Sleep, 300 
Click, 87, 507 ; or Send, {enter} if it activates the log-in field