Sign in to follow this  
Followers 0
GreenHouse

Example for GUI with multiple input boxes PLZ?

5 posts in this topic

:P = me

Could someone please give me some guidance on how to create multiple input boxes on a single window gui?

I need a user to input information there and then store it in a variable so it can be sent to my automation tool I have made.

I don't have any code because I am clueless (and too tired... :) ) to comprehend where to start.

Thanks a bunch guys.

"Just because I'm Dutch and was born in Amsterdam; have a Joint as an avatar and am nicked GreenHouse does NOT mean that I agree with the use of marijuana products in any way, shape or form!"... Yeah Right! :)

Share this post


Link to post
Share on other sites



Koda is the answer for your first question (graphic GUI builder)

I need a user to input information there and then store it in a variable

The answer is GUICtrlRead.

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 :)

Share this post


Link to post
Share on other sites

Hi GreenHouse,

You really haven't given much to go on with your ask for an example.

When you say "I need a user to input information there and then store it in a variable so it can be sent to my automation tool I have made."

A bit more clarification and it would make it easier to provide an example...

eg: " the tool I've made will need to read the variable from an ini file" or "I wrote the tool with Autoit and I would like to add some code directly to it so it can accomplish what I'm after" or "Hell I have no clue what the tool does but here's the tool which way can I add what I'm after"... etc

In the mean time here's a brief way of adding 12 input boxes to 1 window...

#include <GUIConstants.au3>

Global $Input[13], $y = 5

$Gui = GUICreate("Mutiple input boxes in 1 window", 170, 330)
For $d = 1 To 12
    $Input[$d] = GUICtrlCreateInput("Input " & $d, 5, $y, 160, 20)
    $y += 25
Next
GUISetState(@SW_SHOW, $Gui)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect       
WEnd

Be a bit more specific and I'll add what's needed to the example.

Cheers Bud :)

Share this post


Link to post
Share on other sites

Enaiman and Smashly,

Thanks a lot for the response. I am sorry I was really tired last night so I apologize for the lack of detail.

Ok here goes:

I created a script that runs a service pack for our companies clients. It's like a regular next, next finish type deal.

During the installation of this service pack it will ask the user to input a domain admin account in three seperate input fields (User, Password, Domain) so that when the people who work at that client log into their local machines and do not have the rights to install the software it will run it with the domain admin account credentials.

In my script I would like to present the person running the script with a window that asks for the credentials and then have my script test those credentials and see if they are valid then send it to the seperate input fields in the service pack when it is ran.

I have included part of the script code for your reference, but I do not have implemented any of what is described above.

#include "CopyDirWithProgress.au3"
#include "SP_Install.au3"
#include "WINXP.au3"
#include "WIN2003.au3"
#include "WIN2000.au3"
;#include "VISTA.au3"

; Read The Impact.MD/TouchChart Path From The Windows Registry:
$var = RegRead("HKEY_CLASSES_ROOT\TypeLib\{42743168-8506-3652-BDEF-D967642E50EA}\1.0\HELPDIR", "")
$var2 = RegRead("HKEY_CLASSES_ROOT\TypeLib\{867CD6E9-B6E0-3CEC-A59E-D67FB23E1A40}\8.5\HELPDIR", "")

; Set Window Title Match Mode For Easier Reference:
Opt("WinTitleMatchMode", 2)

GUISetIcon("Allscripts.ico")

; Prompt the user to run the script - use a Yes/No prompt (4 - see help file)
$answer = MsgBox(4, "Allscripts Service Pack Upgrade", "This program will upgrade you to the latest Service Pack.  Run?")


; Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
    MsgBox(0, "Allscripts Service Pack Upgrade", "End Script")
    Exit
EndIf

; Prompt the user if he/she has created a SQL backup
$answer = MsgBox(4, "Allscripts Service Pack Upgrade", "Have you created a backup of the database yet? Click NO and create one then re-run SP Upgrade, Click YES to proceed.")


; Check the user's answer to the prompt (see the help file for MsgBox return values)
; If "No" was clicked (7) then exit the script
If $answer = 7 Then
    MsgBox(0, "Allscripts Service Pack Upgrade", "End Script")
    Exit
EndIf


;Find out the O/S Version and act accordingly

$OSVersion = @OSVersion
ClipPut($OSVersion)


If $OSVersion = "WIN_VISTA" Then
MsgBox(0, "Sorry...", "This program will not work on windows Vista... Ending program")
Exit
;   _VISTA ()
EndIf



If $OSVersion = "WIN_2000" Then
    _WIN2000 ()
EndIf



If $OSVersion = "WIN_XP" Then
    _WINXP ()
EndIf



If $OSVersion = "WIN_2003" Then
    _WIN2003 ()
EndIf


;Backup The TouchChart Folder:
_CopyDirWithProgress ($var, "\TouchChart_BAK")

WinWaitClose("Copying...", "Copying file:")

WinWaitActive("of ImpactMD 3.31 Service Pack 38 Install.exe Completed", "Saving:", 5)
WinWaitClose("of ImpactMD 3.31 Service Pack 38 Install.exe Completed", "Saving:")

;MsgBox(0, "Allscripts Service Pack Upgrade", "DONE!")

;Run ServicePack:
_SP_Install ()

Thanks a bunch guys!

Share this post


Link to post
Share on other sites

If you're using SciTE as your editor then you can look into Tools menu for Koda Form Designer - that is a good tool for creating GUI and get the generated code. Play with that and you will see how easy is to make a nice interface having all inputboxes you need.

This is an example from the help file GUICtrlCreateInput (modified a little bit to show how to use GUICtrlRead)

#include <GUIConstants.au3>

GUICreate(" My GUI input ", 320,120 )
$input = GUICtrlCreateInput ( "Type something here", 10,  5, 300, 20)
$btn = GUICtrlCreateButton ("Ok", 40,  75, 60, 20)

GUISetState () 

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
       $msg = GUIGetMsg()
       Select
           Case $msg = $btn
               $input_content = GUICtrlRead($input)
               MsgBox(0, "Input content", "You typed: "&$input_content)
               exitloop
       EndSelect
Wend

Take a look at this script and try to understand what's happening. You will be ready to do your work :)

Something to keep in mind the help (SciTE - F1 key) is your best friend - keep it closer anytime.


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 :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0