tedesco 0 Posted April 28, 2011 Ok, I desperatley need help with this. I am tryin to write to a .ini file then read the .ini file and put the results into a windows iput box. Sounds easy enough but what am I doing wrong. Im extremely new to Autoit so please be nice if my script looks like a 2 yr old wrote it. #include <GUIConstants.au3>#include <String.au3>$GUI = GUICreate("Login",210,80,-1,-1,0x16C80000,0x00000181) $Name = GUICtrlCreateInput("",5,5,200,20,0x01) $Pas = GUICtrlCreateInput("",5,30,200,20,0x21)$Login = GUICtrlCreateButton("Login",50,55,100,20) GUISetState ()$msg = 0While $msg <> $GUI_EVENT_CLOSE$msg = GUIGetMsg()SelectCase $msg = $Login $var = IniWrite("c:\Temp1.ini", "Username", "USERNAME", GUICtrlRead($Name)) IniWrite("C:\Temp1.ini", "Password", "PASSWORD", GUICtrlRead($Pas)) exitloopEndSelectWendSend("#r")WinWaitActive("Run")Send("control mlcfg32.cpl{Enter}")WinWaitActive("Mail Setup")Send("{Enter}")Send("!N")Send("{Enter}")Send("!m{Enter}")Send("{Down}")Send("{Enter}")Send("mailserver.com {Tab 2}")Send ($var) <------- This is not writing to the windows input box. it is coming up as 1 or 3 as i change things? but never the varExit Share this post Link to post Share on other sites
katoNkatoNK 0 Posted April 28, 2011 (edited) I'm also fairly new to AutoIt, but give '$var = IniRead' a try - as you are pulling the $var from the ini not feeding to it - if i understood it correctly.. edit: make sure the $var is after the IniWrite otherwise it will only read the previously written value from 'last login' Edited April 28, 2011 by katoNkatoNK Share this post Link to post Share on other sites
pieeater 1 Posted April 29, 2011 this isn't really a solution but i organized your code to be much easyer to follow. #include <GUIConstants.au3> #include <String.au3> $GUI = GUICreate("Login",210,80,-1,-1,0x16C80000,0x00000181) $Name = GUICtrlCreateInput("",5,5,200,20,0x01) $Pas = GUICtrlCreateInput("",5,30,200,20,0x21) $Login = GUICtrlCreateButton("Login",50,55,100,20) GUISetState () While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit ;<===== so you can close the GUI If $msg = $Login Then login() ;<==== in case you want to add another function to the script WEnd Func login() $var = IniWrite("c:\Temp1.ini", "Username", "USERNAME", GUICtrlRead($Name)) IniWrite("C:\Temp1.ini", "Password", "PASSWORD", GUICtrlRead($Pas)) Send("#r") WinWaitActive("Run") Send("control mlcfg32.cpl{Enter}") WinWaitActive("Mail Setup") Send("{Enter}") Send("!N") Send("{Enter}") Send("!m{Enter}") Send("{Down}") Send("{Enter}") Send("mailserver.com {Tab 2}") Send ($var) Exit EndFunc [spoiler]My UDFs: Login UDF[/spoiler] Share this post Link to post Share on other sites
Jayson 0 Posted April 29, 2011 (edited) This might help you : #include <GUIConstantsEx.au3> #include <array.au3> Global $Data = "Info.ini" Global $iniRead = IniReadSection($Data, "Times") $GUI = GUICreate("Saving data", 150, 50) $input = GUICtrlCreateInput("", 5, 5, 50, 20) $save = GUICtrlCreateButton("Save", 60, 5, 50, 22) GUISetState() If $IniRead <> 1 Then For $i = 1 To $IniRead[0][0] GUICtrlSetData($input, $IniRead[1][1]) Next EndIf While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $save IniWrite($Data, "Times", "Test", GUICtrlRead($input)) EndSwitch WEnd Info.ini : [Times] test=test123 Edited April 29, 2011 by Jayson Share this post Link to post Share on other sites