Jump to content

Getting Input name.


Recommended Posts

Hey ive got this script. I want to make it so when you type your name into $Input1 and then i will be shown again at Input2, but just with the Sir/Mr/Baron title on.

Ive done that with the titles, but i cant simply get my input boxses to work. Cloud someone help me?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Hello Mr.", 446, 109, 192, 124)
Global $Input1 = GUICtrlCreateInput("", 16, 16, 281, 21)
Global $Button1 = GUICtrlCreateButton("Button1", 296, 8, 113, 41)
Global $Checkbox1 = GUICtrlCreateRadio("Sir", 24, 40, 73, 25)
Global $Checkbox2 = GUICtrlCreateRadio("Mr", 104, 40, 73, 25)
Global $Checkbox3 = GUICtrlCreateRadio("Baron", 184, 40, 81, 25)
Global $Input2 = GUICtrlCreateInput("", 8, 80, 417, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $msg=GUIGetMsg()
    If $msg =-3 Then Exit
    If $msg = $Checkbox1 Then checkbox1()
    If $msg = $button1 Then button1()
WEnd


Func Checkbox1()
    EndFunc
Func button1()
    If GUICtrlRead($Checkbox1) = $GUI_UNCHECKED Then
        GUICtrlSetData($Input2, $YourName)
    EndIf
    If GUICtrlRead($Checkbox2) = $GUI_UNCHECKED Then
        GUICtrlSetData($Input2, $YourName)
    EndIf
    If GUICtrlRead($Checkbox3) = $GUI_UNCHECKED Then
        GUICtrlRead($Input2, $YourName)
    EndIf
    If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
        GUICtrlSetData($Input2, "Sir " & $YourName)
    EndIf
    If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then
        GUICtrlSetData($Input2, "Mr " & $YourName)
    EndIf
    If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then
        GUICtrlSetData($Input2, "Baron " & $YourName)
    EndIf
    EndFunc

//: bigfattoby

Edited by bigfattoby

Getting hang on the basic, still much to learn.If I take high class, taking high test im getting highscore right?

Link to comment
Share on other sites

  • Moderators

bigfattoby,

You need to read the content of the input first and then look at the radio buttons like this: ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $Form1 = GUICreate("Hello Mr.", 446, 109, 192, 124)
Global $Input1 = GUICtrlCreateInput("", 16, 16, 281, 21)
Global $Button1 = GUICtrlCreateButton("Button1", 296, 8, 113, 41)
Global $Radio1 = GUICtrlCreateRadio("Sir", 24, 40, 73, 25)
Global $Radio2 = GUICtrlCreateRadio("Mr", 104, 40, 73, 25)
Global $Radio3 = GUICtrlCreateRadio("Baron", 184, 40, 81, 25)
Global $Input2 = GUICtrlCreateInput("", 8, 80, 417, 21)
GUISetState(@SW_SHOW)


While 1
    $msg=GUIGetMsg()
    If $msg =-3 Then Exit
    If $msg = $Radio1 Then Radio1()
    If $msg = $button1 Then button1()
WEnd

Func Radio1()

EndFunc

Func button1()

    $YourName = GUICtrlRead($Input1)

    If GUICtrlRead($Radio1) = $GUI_CHECKED Then
        GUICtrlSetData($Input2, "Sir " & $YourName)
    ElseIf GUICtrlRead($Radio2) = $GUI_CHECKED Then
        GUICtrlSetData($Input2, "Mr " & $YourName)
    ElseIf GUICtrlRead($Radio3) = $GUI_CHECKED Then
        GUICtrlSetData($Input2, "Baron " & $YourName)
    Else
        GUICtrlSetData($Input2, $YourName)
    EndIf

EndFunc

All clear? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Yes thank you.

I can see you also made som other changes with in my Func button1()

Does Else and ElseIf work better than just alots of IF and endif?

Getting hang on the basic, still much to learn.If I take high class, taking high test im getting highscore right?

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...