Shyke Posted October 9, 2005 Share Posted October 9, 2005 Here is my code:$User = IniRead($Ini, "Configuration", "UserName", "NotFound")How can I get it so that $User is set to the key that is to be read from $Ini from the section "Configuration" and the name "UserName"? Link to comment Share on other sites More sharing options...
Valuater Posted October 9, 2005 Share Posted October 9, 2005 user.ini [Configuration] UserName=Dave the script $Ini = "User.ini" $User = IniRead($Ini, "Configuration", "UserName", "NotFound") $User = "Dave" does that help??? 8) Link to comment Share on other sites More sharing options...
Valuater Posted October 9, 2005 Share Posted October 9, 2005 or maybe this.... where your $User="UserName" ( from your post ) $var = IniReadSection("User.ini", "Configuration") If @error Then MsgBox(4096, "", "Error occured, probably no INI file.") Else For $i = 1 To $var[0][0] MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1]) Next EndIf 8) Link to comment Share on other sites More sharing options...
Shyke Posted October 9, 2005 Author Share Posted October 9, 2005 Maybe I should give you more code:$LoginL = GUICtrlCreateGroup("Login", 10, 10, 220, 105)$UsernameL = GUICtrlCreateLabel("Username:", 20, 25, 50, 20)$Username = GUICtrlCreateInput("Username", 80, 25, 140, 20)$PasswordL = GUICtrlCreateLabel("Password:", 20, 45, 50, 20)$Password = GUICtrlCreateInput("Password", 80, 45, 140, 20, $ES_PASSWORD)$CharacterL = GUICtrlCreateLabel("Character:", 20, 65, 120, 20)$Character = GUICtrlCreateInput("1", 150, 65, 70, 20)$Login = GUICtrlCreateButton("Login", 90, 85, 60, 20)DirRemove($Path & "WDB", 1)GUISetState()While 1 $msg = GUIGetMsg() Select ; Login Case $msg = $Login $User = IniRead($Ini, "Configuration", "UserName", "NotFound") $Pass = IniRead($Ini, "Configuration", "Password", "NotFound") $Char = IniRead($Ini, "Configuration", "Character", "NotFound") GUICtrlSetData($Username, $User) GUICtrlSetData($Username, $Pass) GUICtrlSetData($Username, $Char)That should give you all the info needed, how can I make it so that there is like a "remember" feature like I was explaining? Link to comment Share on other sites More sharing options...
Valuater Posted October 9, 2005 Share Posted October 9, 2005 if you have globalized or dimed $User... once you have read the ini into user it is remembered throughout the script until it is terminated 8) Link to comment Share on other sites More sharing options...
Shyke Posted October 9, 2005 Author Share Posted October 9, 2005 I know that but how can I get the script to work properly? Link to comment Share on other sites More sharing options...
Valuater Posted October 9, 2005 Share Posted October 9, 2005 if i understand you scriptlet above correctly... you are asking for a user name with this $Username = GUICtrlCreateInput("Username", 80, 25, 140, 20) then when they press the "login" button. you are reading the $User from the ini with this $User = IniRead($Ini, "Configuration", "UserName", "NotFound") thenm you are replacing what the user typed in as their $Username with your ini read of $User with this GUICtrlSetData($Username, $User) thus... the information put in the $username in the GUI is lost maybe you want to iniwrite ????? 8) Link to comment Share on other sites More sharing options...
Shyke Posted October 9, 2005 Author Share Posted October 9, 2005 I will just put the whole script here... I really didn't want to though... expandcollapse popup#include <GuiConstants.au3> ; Order = left|up|width|height $Path = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Blizzard Entertainment\World of Warcraft\", "InstallPath") $WoW = $Path & "WoW.exe" $Ini = $Path & "login.ini" ;If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 GUICreate("WoW Auto Login", 240, 125, (@DesktopWidth - 240) / 2, (@DesktopHeight - 125) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $LoginL = GUICtrlCreateGroup("Login", 10, 10, 220, 105) $UsernameL = GUICtrlCreateLabel("Username:", 20, 25, 50, 20) $Username = GUICtrlCreateInput("Username", 80, 25, 140, 20) $PasswordL = GUICtrlCreateLabel("Password:", 20, 45, 50, 20) $Password = GUICtrlCreateInput("Password", 80, 45, 140, 20, $ES_PASSWORD) $CharacterL = GUICtrlCreateLabel("Character Number (1-10):", 20, 65, 120, 20) $Character = GUICtrlCreateInput("1", 150, 65, 70, 20) $Login = GUICtrlCreateButton("Login", 90, 85, 60, 20) DirRemove($Path & "WDB", 1) GUISetState() While 1 $msg = GUIGetMsg() Select ; Login Case $msg = $Login $User = IniRead($Ini, "Configuration", "UserName", "NotFound") $Pass = IniRead($Ini, "Configuration", "Password", "NotFound") $Char = IniRead($Ini, "Configuration", "Character", "NotFound") GUICtrlSetData($Username, $User) GUICtrlSetData($Username, $Pass) GUICtrlSetData($Username, $Char) FileDelete($Ini) IniWrite($Ini, "Configuration", "UserName", $Username) IniWrite($Ini, "Configuration", "Password", $Password) IniWrite($Ini, "Configuration", "WoW", $WoW) IniWrite($Ini, "Configuration", "Character", $Character) IniWrite($Ini, "Configuration", "Title", "World of Warcraft") IniWrite($Ini, "Configuration", "Delay", "13000") IniWrite($Ini, "Configuration", "Delay2", "6000") Else IniWrite($Ini, "Configuration", "UserName", $Username) IniWrite($Ini, "Configuration", "Password", $Password) IniWrite($Ini, "Configuration", "WoW", $WoW) IniWrite($Ini, "Configuration", "Character", $Character) IniWrite($Ini, "Configuration", "Title", "World of Warcraft") IniWrite($Ini, "Configuration", "Delay", "13000") IniWrite($Ini, "Configuration", "Delay2", "6000") EndIf $Character = IniRead($Ini, "Configuration", "Character", "NotFound") If $Character > 10 Or $Character < 0 Then MsgBox(48, "WoW Auto Login", "Error!" & @CRLF & "You have typed a character number that is out of bounds." & @CRLF & "Click OK to continue.") Exit EndIf $Title = IniRead($Ini, "Configuration", "Title", "NotFound") If WinExists($Title) Then ProcessClose("WoW.exe") Sleep(5000) Run($WoW) Else Run($WoW) EndIf $Delay = IniRead($Ini, "Configuration", "Delay", "NotFound") $Delay2 = IniRead($Ini, "Configuration", "Delay2", "NotFound") Sleep($Delay) Send($Username) Send("{TAB}") Send($Password) Send("{ENTER}") Sleep($Delay2) $DW = @DesktopWidth $DH = @DesktopHeight If $DW = 800 And $DH = 600 Then MouseClick("left", 701, 84, 1, 10) Else If $DW = 1024 And $DH = 768 Then MouseClick("left", 835, 110, 1, 10) Else MsgBox(48, "WoW Auto Login", "Error!" & @CRLF & "Your desktop resolution isn't supported, please change your desktop resolution to either 800 x 600 or 1024 x 768." & @CRLF & "Click OK to continue.") Exit EndIf EndIf Send("{DOWN " & $Character & "}") Sleep(1000) Send("{ENTER}") Exit Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Link to comment Share on other sites More sharing options...
Valuater Posted October 9, 2005 Share Posted October 9, 2005 did you read my last post... after all that this FileDelete($Ini) IniWrite($Ini, "Configuration", "UserName", $Username) re-writes the ini with the info read from the ini.... the user input is still lost 8) Link to comment Share on other sites More sharing options...
Shyke Posted October 9, 2005 Author Share Posted October 9, 2005 No, it reads in all the stuff, sets it to the input fields, then deletes the ini, makes a new one with new values. Link to comment Share on other sites More sharing options...
Valuater Posted October 9, 2005 Share Posted October 9, 2005 i have lots of errors with your script 1 $Path = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Blizzard Entertainment\World of Warcraft\", "InstallPath") then DirRemove($Path & "WDB", 1) ****** the $path is not a Dir that can be removed 2 ; Login Case $msg = $Login then Else IniWrite($Ini, "Configuration", "UserName", $Username) ******* the "Else" is for an "if" statement... not a "Case" 3 i dunno 8) Link to comment Share on other sites More sharing options...
Valuater Posted October 9, 2005 Share Posted October 9, 2005 sorry.... maybe my number "1" above will work... if you have a folder named "WDB" but you never write to that folder in your script. thus it will remove that folder... but your ini is written somewhere else 8) Link to comment Share on other sites More sharing options...
Shyke Posted October 9, 2005 Author Share Posted October 9, 2005 the first two issues you adressed works (removed WDB folder). The ini gets saved to the WoW base directory. I am clueless of how to work the Case crap and how to get it to do the Ini stuff I need.... Link to comment Share on other sites More sharing options...
Valuater Posted October 9, 2005 Share Posted October 9, 2005 okif i were writting this script.... i would1put a "save info" button on the gui2when the script is started it would look for ( and if found) read the ini and set the info into the gui3when they press login it just runs... no more ini stuff8)number 1 aboveGUICreate("WoW Auto Login", 240, 125, (@DesktopWidth - 240) / 2, (@DesktopHeight - 125) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $LoginL = GUICtrlCreateGroup("Login", 10, 10, 220, 105) $UsernameL = GUICtrlCreateLabel("Username:", 20, 25, 50, 20) $Username = GUICtrlCreateInput("Username", 80, 25, 140, 20) $PasswordL = GUICtrlCreateLabel("Password:", 20, 45, 50, 20) $Password = GUICtrlCreateInput("Password", 80, 45, 140, 20, $ES_PASSWORD) $CharacterL = GUICtrlCreateLabel("Character Number (1-10):", 20, 65, 120, 20) $Character = GUICtrlCreateInput("1", 150, 65, 70, 20) $Login = GUICtrlCreateButton("Login", 100, 87, 60, 20) $SaveIni = GUICtrlCreateButton("Save Info", 30, 87, 60, 20) DirRemove($Path & "WDB", 1) GUISetState() While 18) Link to comment Share on other sites More sharing options...
Shyke Posted October 9, 2005 Author Share Posted October 9, 2005 If you can show me how to do number 2 that you listed, I will try number 3. Link to comment Share on other sites More sharing options...
Valuater Posted October 9, 2005 Share Posted October 9, 2005 Number 2 Above this DirRemove($Path & "WDB", 1) Ini_Reader(); ****** ad this line here GUISetState() While 1 and this at the very bottom of yopur script ;----------- Functions -------------------- Func Ini_Reader() If FileExists($Ini) Then $User = IniRead($Ini, "Configuration", "UserName", "NotFound") $Pass = IniRead($Ini, "Configuration", "Password", "NotFound") $Char = IniRead($Ini, "Configuration", "Character", "NotFound") GUICtrlSetData($Username, $User) GUICtrlSetData($Password, $Pass) GUICtrlSetData($Character, $Char) EndIf EndFunc 8) Link to comment Share on other sites More sharing options...
Valuater Posted October 9, 2005 Share Posted October 9, 2005 something i "thought" i taught you beforekeep it cleanGUISetState() While 1 $msg = GUIGetMsg() If $msg = $Login Then ; hide the gui ???? Call("Run_Login") EndIf If $msg = $SaveIni Then Call("Save_Ini") EndIf If $msg = $GUI_EVENT_CLOSE Then Exit WEnd8) Link to comment Share on other sites More sharing options...
Shyke Posted October 9, 2005 Author Share Posted October 9, 2005 Alright, I fixed some stuff... expandcollapse popup#include <GuiConstants.au3> ; Order = left|up|width|height $Path = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Blizzard Entertainment\World of Warcraft\", "InstallPath") $WoW = $Path & "WoW.exe" $Ini = $Path & "login.ini" ;If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000 GUICreate("WoW Auto Login", 240, 125, (@DesktopWidth - 240) / 2, (@DesktopHeight - 125) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $LoginL = GUICtrlCreateGroup("Login", 10, 10, 220, 105) $UsernameL = GUICtrlCreateLabel("Username:", 20, 25, 50, 20) $Username = GUICtrlCreateInput("Username", 80, 25, 140, 20) $PasswordL = GUICtrlCreateLabel("Password:", 20, 45, 50, 20) $Password = GUICtrlCreateInput("Password", 80, 45, 140, 20, $ES_PASSWORD) $CharacterL = GUICtrlCreateLabel("Character Number (1-10):", 20, 65, 120, 20) $Character = GUICtrlCreateInput("1", 150, 65, 70, 20) $Login = GUICtrlCreateButton("Login", 80, 85, 60, 20) DirRemove($Path & "WDB", 1) Reader() Writer() Reader() $Title = IniRead($Ini, "Configuration", "Title", "NotFound") $Char = IniRead($Ini, "Configuration", "Character", "NotFound") $Delay = IniRead($Ini, "Configuration", "Delay", "NotFound") $Delay2 = IniRead($Ini, "Configuration", "Delay2", "NotFound") GUISetState() While 1 $msg = GUIGetMsg() Select ; Login Case $msg = $Login If FileExists($Ini) Then FileDelete($Ini) Writer() EndIf If $Char > 10 Or $Char < 0 Then MsgBox(48, "WoW Auto Login", "Error!" & @CRLF & "You have typed a character number that is out of bounds." & @CRLF & "Click OK to continue.") Exit EndIf If WinExists($Title) Then ProcessClose("WoW.exe") Sleep(5000) Run($WoW) Else Run($WoW) EndIf Sleep($Delay) Send($Username) Send("{TAB}") Send($Password) Send("{ENTER}") Sleep($Delay2) $DW = @DesktopWidth $DH = @DesktopHeight If $DW = 800 And $DH = 600 Then MouseClick("left", 701, 84, 1, 10) Else If $DW = 1024 And $DH = 768 Then MouseClick("left", 835, 110, 1, 10) Else MsgBox(48, "WoW Auto Login", "Error!" & @CRLF & "Your desktop resolution isn't supported, please change your desktop resolution to either 800 x 600 or 1024 x 768." & @CRLF & "Click OK to continue.") Exit EndIf EndIf Send("{DOWN " & $Char & "}") Sleep(1000) Send("{ENTER}") Exit Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd ;--------------------------------------------- Functions---------------------------------------------- Func Reader() If FileExists($Ini) Then $User = IniRead($Ini, "Configuration", "UserName", "NotFound") $Pass = IniRead($Ini, "Configuration", "Password", "NotFound") $Char = IniRead($Ini, "Configuration", "Character", "NotFound") GUICtrlSetData($Username, $User) GUICtrlSetData($Password, $Pass) GUICtrlSetData($Character, $Char) Else Writer() EndIf EndFunc ;==>Reader Func Writer() If Not FileExists($Ini) Then IniWrite($Ini, "Configuration", "UserName", $Username) IniWrite($Ini, "Configuration", "Password", $Password) IniWrite($Ini, "Configuration", "WoW", $WoW) IniWrite($Ini, "Configuration", "Character", $Character) IniWrite($Ini, "Configuration", "Title", "World of Warcraft") IniWrite($Ini, "Configuration", "Delay", "13000") IniWrite($Ini, "Configuration", "Delay2", "6000") Else Reader() EndIf EndFunc ;==>Writer Could you tell me what to fix so that I don't always get 5 as character, 7 pass password and 9 as character no matter what? Also could you tell me what I could do to improve my code? Link to comment Share on other sites More sharing options...
Valuater Posted October 9, 2005 Share Posted October 9, 2005 (edited) DirRemove($Path & "WDB", 1) Reader() Writer() ******** Else Reader() EndIf EndFunc;==>Writer ********* Reader() ?????? 8) Edited October 9, 2005 by Valuater Link to comment Share on other sites More sharing options...
Shyke Posted October 9, 2005 Author Share Posted October 9, 2005 I am not quite sure what you meant by that... Link to comment Share on other sites More sharing options...
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