Shonnie Posted June 26, 2007 Posted June 26, 2007 Send(IniRead("Config.ini", "Login", "1", ".")) Thats my code. I would like to find a way to make it basically Exit the program if it doesnt find that string. IE: something like... Send(IniRead("Config.ini", "Login", "1", ".")) If @error = 1 Then Exit EndIf this doesnt work however, and i have read all over and ripped apart other scripts to try to find a way to make it work... WONT ! help pls thanks
ronriel Posted June 26, 2007 Posted June 26, 2007 Send(IniRead("Config.ini", "Login", "1", ".")) Thats my code. I would like to find a way to make it basically Exit the program if it doesnt find that string. IE: something like... Send(IniRead("Config.ini", "Login", "1", ".")) If @error = 1 Then Exit EndIf this doesnt work however, and i have read all over and ripped apart other scripts to try to find a way to make it work... WONT ! help pls thanks Maybe something like this: CODE$var=IniRead("Config.ini", "Login", "1", ".") Send($var) If $var = "." Then Exit Exits if it doesn't find the key or: CODE$var=IniRead("Config.ini", "Login", "1", ".") Send($var) If $var <> "The Value you're looking for" Then Exit Exits if it does not find the string. Maybe you can use StringRegExp to match the string you're looking for. I'm not sure. [font="Comic Sans MS"]-ronriel[/font][topic="48542"]r4r media player[/topic][topic="80836"]OCR & Paste[/topic]
Airwolf Posted June 26, 2007 Posted June 26, 2007 Try this: $string = IniRead("Config.ini","Login","1",".") If $string = "." Then Exit Else Send($string) EndIf Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
gsglive Posted June 26, 2007 Posted June 26, 2007 Try: Send("IniRead("Config.ini","Login","1",".")") - gsglive - gsglive
Airwolf Posted June 26, 2007 Posted June 26, 2007 (edited) Try: Send("IniRead("Config.ini","Login","1",".")") - gsglive If it doesn't find the value in the ini file then it will still send the "." This doesn't solve Shonnie's problem. Edited June 26, 2007 by Airwolf123 Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
enaiman Posted June 26, 2007 Posted June 26, 2007 There is something weird here ...Looking at IniRead command this line IniRead("Config.ini", "Login", "1", ".")would do:- read the value in the Config.ini assigned to 1 key- if the key "1" is not found it will return the default value (which is: ".")so ... considering this ... the solution given by Airwolf123 seem to be the correct one:Try this:CODE$string = IniRead("Config.ini","Login","1",".")If $string = "." Then ExitElse Send($string)EndIf SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
Shonnie Posted June 30, 2007 Author Posted June 30, 2007 (edited) $login_1 = IniRead("Config.ini", "Login", "1", ".") If $login_1 = "." Then MsgBox(48, "Error", "Login 1 does not exist. Please edit your Config.ini accordingly.") Exit Else Send($login_1) EndIf What I'm using. Doesnt work like I expected it to unfortunately. The concept is easy, exit if this string doesnt exist (from an ini) Any more help out there? Edited June 30, 2007 by Shonnie
i542 Posted June 30, 2007 Posted June 30, 2007 (edited) Version one:Types text if string is not found.Send(IniRead(@ScriptDir & "\Config.ini","Login","1","The string you are looking for is not found.")")Note... you must have Config.ini in same place as your script is.... Edited June 30, 2007 by i542 I can do signature me.
Shonnie Posted June 30, 2007 Author Posted June 30, 2007 (edited) Thanks much and it worked ! But... I optimized a little and ... well heres a snippet of my code so you get the idea... $login_1 = IniRead("Config.ini", "Login", "1", "xxx") $Button_1 = GuiCtrlCreateButton($login_1, 10, 10, 220, 30) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Exit Case $msg = $Button_1 $login_1 = IniRead("Config.ini", "Login", "1", ".") If $login_1 = "" Then MsgBox(48, "Error", "Login 1 does not exist. Please edit your Config.ini accordingly.") Exit Else $Login = 1 _Start() _Check() ExitLoop GUIDelete() EndIf EndSelect WEnd Exit GUI with one button, and the text on it is the string in Config.ini read from $login_1 But I'm sure you already knew that Edited June 30, 2007 by Shonnie
i542 Posted June 30, 2007 Posted June 30, 2007 Thanks much and it worked ! But... I optimized a little and ... well heres a snippet of my code so you get the idea... $login_1 = IniRead("Config.ini", "Login", "1", "xxx") $Button_1 = GuiCtrlCreateButton($login_1, 10, 10, 220, 30) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Exit Case $msg = $Button_1 $login_1 = IniRead("Config.ini", "Login", "1", ".") If $login_1 = "" Then MsgBox(48, "Error", "Login 1 does not exist. Please edit your Config.ini accordingly.") Exit Else $Login = 1 _Start() _Check() ExitLoop GUIDelete() EndIf EndSelect WEnd Exit GUI with one button, and the text on it is the string in Config.ini read from $login_1 But I'm sure you already knew that I am just been in a hurry so I didn't wanted to implent that...it was a little complicated....but it is a nice thought. I can do signature me.
Shonnie Posted June 30, 2007 Author Posted June 30, 2007 (edited) IF anyone is willing, and blah w/e if my program gets stolen...I would like someone > me to look over this and see if theres any further optimizations that can be madeexpandcollapse popup#include <File.au3> #include <GuiConstants.au3> ; $Sleep = Random(200, 500) $Login = 0 $config = "Config.ini" HotKeySet("{END}", "_Exit") If Not FileExists("Config.ini") Then _FileCreate("Config.ini") FileWrite($config, "[Login]" & @CRLF & "1=" & @CRLF & "2=" & @CRLF & "3=" & @CRLF & "4=" & @CRLF & @CRLF) FileWrite($config, "[Password]=" & @CRLF & "1=" & @CRLF & "2=" & @CRLF & "3=" & @CRLF & "4=" & @CRLF) MsgBox(48, "Error", "This is either your first time running Load n Login ~or~ you deleted your Config.ini. Please edit it accordingly.") Exit EndIf #region gui GuiCreate("Load n Login", 478, 90,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $login_1 = IniRead("Config.ini", "Login", "1", "xxx") $login_2 = IniRead("Config.ini", "Login", "2", "xxx") $login_3 = IniRead("Config.ini", "Login", "3", "xxx") $login_4 = IniRead("Config.ini", "Login", "4", "xxx") $Button_1 = GuiCtrlCreateButton($login_1, 10, 10, 220, 30) $Button_2 = GuiCtrlCreateButton($login_2, 240, 10, 230, 30) $Button_3 = GuiCtrlCreateButton($login_3, 10, 50, 220, 30) $Button_4 = GuiCtrlCreateButton($login_4, 240, 50, 230, 30) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Exit Case $msg = $Button_1 $login_1 = IniRead("Config.ini", "Login", "1", ".") If $login_1 = "" Then MsgBox(48, "Error", "Login 1 does not exist. Please edit your Config.ini accordingly.") Exit Else $Login = 1 _Start() _Check() ExitLoop GUIDelete() EndIf Case $msg = $Button_2 $login_2 = IniRead("Config.ini", "Login", "2", ".") If $login_2 = "" Then MsgBox(48, "Error", "Login 2 does not exist. Please edit your Config.ini accordingly.") Exit Else $Login = 2 _Start() _Check() ExitLoop GUIDelete() EndIf Case $msg = $Button_3 $login_3 = IniRead("Config.ini", "Login", "3", ".") If $login_3 = "" Then MsgBox(48, "Error", "Login 3 does not exist. Please edit your Config.ini accordingly.") Exit Else $Login = 3 _Start() _Check() ExitLoop GUIDelete() EndIf Case $msg = $Button_4 $login_4 = IniRead("Config.ini", "Login", "4", ".") If $login_4 = "" Then MsgBox(48, "Error", "Login 4 does not exist. Please edit your Config.ini accordingly.") Exit Else $Login = 4 _Start() _Check() ExitLoop GUIDelete() EndIf EndSelect WEnd Exit #endregion gui ; Func _Start() BlockInput(1) WinMinimizeAll() Sleep($Sleep) Run("c:\program files\diablo II\diablo ii.exe -w -res800 -nohide -title ""Diablo II"" -skiptobnet", "c:\program files\diablo II") Sleep($Sleep) $coord = PixelSearch(470, 290, 480, 300, 0xFCD45C, 3) If Not @error Then Sleep(500) Else If Not WinActive("Diablo II", "") Then WinActivate("Diablo II", "") WinWaitActive("Diablo II", "") Sleep(2000) MouseClick("left", 700, 560, 2, 1) If $Login = 1 Then Send(IniRead("Config.ini", "Login", "1", ".")) ElseIf $Login = 2 Then Send(IniRead("Config.ini", "Login", "2", ".")) ElseIf $Login = 3 Then Send(IniRead("Config.ini", "Login", "3", ".")) ElseIf $Login = 4 Then Send(IniRead("Config.ini", "Login", "4", ".")) EndIf Sleep($Sleep) Send("{TAB}") If $Login = 1 Then Send(IniRead("Config.ini", "Password", "1", ".")) ElseIf $Login = 2 Then Send(IniRead("Config.ini", "Password", "2", ".")) ElseIf $Login = 3 Then Send(IniRead("Config.ini", "Password", "3", ".")) ElseIf $Login = 4 Then Send(IniRead("Config.ini", "Password", "4", ".")) EndIf EndIf Sleep($Sleep) Send("{ENTER}") Sleep($Sleep) MouseMove(270, 215, 1) MouseDown("left") MouseMove(0, 385, 1) MouseUp("left") Sleep($Sleep) Run("maphack\map.exe", "maphack") Sleep($Sleep) ControlClick("", "Auto close loader after next install/remove", 1065) ControlClick("", "&Install/update", 1000) Sleep($Sleep) MouseClick("left", 730, 240, 1, 1) BlockInput(0) EndFunc ;==>_Start ; Func _Check() While 1 Sleep(5000) If WinExists("Diablo II") Then Else WinKill("x_x") WinMinimizeAllUndo() Exit EndIf WEnd EndFunc ;==>_Check Func _Exit() Exit 0 EndFuncIf so, thanks a lot, if not then oh well im just better at Autoit than i though yay me YES ITS FOR DIABLO II !I <3 AutoIt ! Edited June 30, 2007 by Shonnie
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now