Jump to content

How do I pass varibles entered by user into an app as run time Vars


Recommended Posts

Hi,

I am writing a little app to pass some varibles to an exe when it is run.

I am new to scripting in autoit and have tried a few things but am getting stuck.

The command line app runs froma a dos windows in windows 2003 server and looks like this

EVAperf fnh <HOSTname> <username> <Password> -cont

The -cont option leaves the dos windows open and updates continuously.

I will cut the portions of script I have done.

Basically I am trying to get the user to enter the hostname their name and password, which will be passed with the executable when run.

GuiCtrlCreateLabel(" Login Account:", 10, 353)

$Login = GUICtrlCreateInput ( " " , 90, 350, 80, 20, )

GuiCtrlCreateLabel(" Password:", 180, 353)

$Password = GUICtrlCreateInput ( "" , 240, 350, 80, 20, $ES_PASSWORD )

GuiCtrlCreateLabel(" Friendly Name Host::", 10, 320)

$FNH = GUICtrlCreateInput ( "" , 110, 318, 80, 20 )

I am using a case statement as the gui has little buttons with different options and each button runs various scripts etc.

Select

Case $msg[0] = $App1

RunWait("C:\Program Files\Hewlett-Packard\EVA Performance Monitor\evaperf fnh" & GUICtrlRead($FNH) & GUICtrlRead($Login) & GUICtrlRead($Password))

In the above version I tried the gui read but have tried a few other ideas to no avail.

Any guidance would be great

Cheers

Steve

Link to comment
Share on other sites

  • Moderators

This should get you going in the right direction.

#include <GuiConstants.au3>

GUICreate("Test")
GUICtrlCreateLabel(" Login Account:", 10, 353)
$Login = GUICtrlCreateInput(" ", 90, 350, 80, 20)
GUICtrlCreateLabel(" Password:", 180, 353)
$Password = GUICtrlCreateInput("", 240, 350, 80, 20, $ES_PASSWORD)
GUICtrlCreateLabel(" Friendly Name Host::", 10, 320)
$FNH = GUICtrlCreateInput("", 110, 318, 80, 20)
$App1 = GUICtrlCreateButton("App1", 10, 10)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $App1
            $sHostName = GUICtrlRead($FNH)
            $sLogin = GUICtrlRead($Login)
            $sPassword = GUICtrlRead($Password)
            $sPath = @ProgramFilesDir & "\Hewlett-Packard\EVA Performance Monitor\evaperf fnh"
            
            If $sHostName And $sLogin And $sPassword Then
                RunWait($sPath & " " & $sHostName & " " & $sLogin & " " & $sPassword)
            Else
                MsgBox(48, "Error", "You must provide all required information.")
            EndIf
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd
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...