Why not store the various accounts and passwords in a 2 dimensional array and run your code in the loop.
Something like this:
Loop, read, %A_ScriptDir%\Login.txt ; in username{Tab}Password{NewLine} format
{
RecordNumber:=A_Index
Loop, parse, A_LoopReadLine, %A_Tab% ; uses tab to separate items
{
Array_%RecordNumber%_%A_Index% := A_LoopField
}
}
MaxRecords:=RecordNumber
Loop, %MaxRecords%
{
acc1:=Array_%A_Index%_1
pw1:=Array_%A_Index%_2
Run your code here
}
Return
Adding more {Tab} separated items e.g. unique button locations to the text file are automatically stored in the array as Array_%A_Index%3, Array%A_Index%_4, etc. and can be used in the loop code.
Or if you want to launch it with Ctrl+Alt+1 , Ctrl+Alt+2 , etc. define the acc1 and pw1 per hotkey and run the code.
;Autologin #1.
Return
^!1::
acc1=UserName
pw1=passwd
GoSub, MyScript
Return
^!2::
acc1=UserName2
pw1=passwd2
GoSub, MyScript
Return
MyScript:
ImageSearch,ExistUser_X,ExistUser_Y,0,0,A_ScreenWidth,A_ScreenHeight,%A_TEMP%\ExistUser.bmp
If !ErrorLevel
{
Click,%ExistUser_X%,%ExistUser_Y%
ImageSearch,Login_X,Login_Y,0,0,A_ScreenWidth,A_ScreenHeight,%A_TEMP%\Login.bmp
Click,%Login_X%,%Login_Y%
If !ErrorLevel
Send,%acc1%{Tab}%pw1%{Enter}
Else
MsgBox,The login page is not visible.
Return
}
Else If ErrorLevel=1
{
ImageSearch,Login_X,Login_Y,0,0,A_ScreenWidth,A_ScreenHeight,%A_TEMP%\Login.bmp
Click,%Login_X%,%Login_Y%
If !ErrorLevel
Send,%acc1%{Tab}%pw1%{Enter}
Else
MsgBox,The login page is not visible.
Return
}
Else
MsgBox,The login page is not visible.
Return