Jump to content

Sending a variable


JayT
 Share

Recommended Posts

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 = 0

While $msg <> $GUI_EVENT_CLOSE

$msg = GUIGetMsg()

Select

Case $msg = $Login

$var = IniWrite("c:\Temp1.ini", "Username", "USERNAME", GUICtrlRead($Name))

IniWrite("C:\Temp1.ini", "Password", "PASSWORD", GUICtrlRead($Pas))

exitloop

EndSelect

Wend

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) <------- This is not writing to the windows input box. it is coming up as 1 or 3 as i change things? but never the var

Exit

Link to comment
Share on other sites

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 by katoNkatoNK
Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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 by Jayson
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...