caram1992 0 Posted April 11, 2010 (edited) Hello I am new to Autoit, I am doing a Macro to auto log into my program. but am having trouble, I want him to read a username and password from an external file (config.ini) And write this login, when read in external file (config.ini) I know I'm doing something wrong, possibly something that anyone would ever would do heheh I'm just starting it. but that part is essential $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Button1 Run("C:Arquivos de programasmyprogramengine.exe") MouseMove(614, 557,20) Sleep(5000) MouseClick("left") Sleep(22000) MouseMove(509,384,20) $Read = FileReadLine("config.ini",1) StringLeft($Read,8) = "Login:" Then Send($Read) Exit Case $Label1 EndSelect WEnd [/autoit] External File ( Config.ini) Login:Username Here Password:Pass Here Att. Edited April 11, 2010 by caram1992 Share this post Link to post Share on other sites
Yoriz 6 Posted April 11, 2010 (edited) StringLeft returns a number of characters from the left-hand side of a string, your StringLeft($Read,8) would return the first 8 letters which would be 'Login:Us' to make it check for only 'Login:'it should be 6 chars, so you need it to be StringLeft($Read,6). You have no 'If' in front of StringLeft and no endif after Send($Read), if you only intend to send the actual username you need to remove 'Login:' when doing so. If im right in thinking this is what you want, it could be done with the following . If StringLeft($Read,6) = "Login:" Then ; if (first 6 chars) = "Login:" then Send(StringTrimLeft($Read,6)) ; send (first 6 chars removed) EndIf Another way would be to create the External File ( Config.ini) in a proper .ini way, it would look something like this [Login&Password] Login=Username Here Password=Pass Here You can then use $Read = IniRead(@ScriptDir & "\Config.ini","Login&Password","Login"," ") If $Read Then Send($Read) Edited April 11, 2010 by Yoriz GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Share this post Link to post Share on other sites
caram1992 0 Posted April 11, 2010 (edited) Thank you Now another doubt .. for me to run the program with external file (Config.ini) --- I did like this worked correctly the question is I do not know if that can give any errors ... I think not expandcollapse popupWhile 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Button1 MsgBox(16,"Atenção","O Macro está em operação aguarde o processo de login ser finalizado.",8) Sleep(3000) $Read = IniRead(@ScriptDir & "\Config.ini","Diretorio","Local"," ") If $Read Then Run($Read) If StringLeft($Read,6) = "Local:" Then ; FileOpen($Read,6) EndIf MouseMove(614, 557,20) Sleep(8000) MouseClick("left") Sleep(52000) MouseMove(509,384,20) $Read = IniRead(@ScriptDir & "\Config.ini","Login&Password","Login"," ") If $Read Then Send($Read) If StringLeft($Read,6) = "Login:" Then ; Send(StringTrimLeft($Read,6)) ; EndIf MouseMove(523,404,10) MouseClick("left") $Read = IniRead(@ScriptDir & "\Config.ini","Login&Password","Password"," ") If $Read Then Send($Read) If StringLeft($Read,9) = "Password:" Then ; if (first 6 chars) = "Login:" then Send(StringTrimLeft($Read,9)) ; send (first 6 chars removed) EndIf MouseMove(490,438,10) MouseClick("Left") Exit Case $Label1 EndSelect WEnd External File (Config.ini) [Diretorio] Local=C:\Arquivos de programas\myprogam\engine.exe [Login&Password] Login=10031992 Password=caram1992 Edited April 11, 2010 by caram1992 Share this post Link to post Share on other sites
Yoriz 6 Posted April 11, 2010 Your mixing the two methods i gave into one, you only need use one way or the other. when you do $Read = IniRead(@ScriptDir & "\Config.ini","Login&Password","Password"," ", it returns just the value of Password=, that means $Read will only contain 'caram1992'. when it then does If $Read Then Send($Read) it means it would only send if $Read is not empty. your then try If StringLeft($Read,9) = "Password:" Then at this point read only = 'caram1992' so it wont = "Password:" and the next line Send(StringTrimLeft($Read,9)) althought it wont happen because the if statment is false would send nothing as $Read is only 9 chars wide. GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Share this post Link to post Share on other sites
caram1992 0 Posted April 11, 2010 thank you ... explain to me now understand very well Share this post Link to post Share on other sites