Jump to content

Enter Text in GUICtrlInput and select ENTER


Recommended Posts

Hi,

I am little stuck here fiddling around with different options. Can someone please help me out.

Basically, in the GUI I have given some Lable names. These lable names are for identifying which step needs to be done.

So, if I would need Step 1 to be performed, I would have to type '1' in the Input Box and select Enter. Same way if I enter '2' then the commands written for Step 2 will be performed.

Now I know the way how to get the text written in the Input box (as shown below) but not able to get this done in the below code. Also if any other number is pressed, other than 1-4 as (5 or 6 or 10) for which there are no functions added then when I press enter it should give the error "Incorrect Step".

        Case $OK
                        MsgBox(0,"",GUICtrlRead($Input_Text))

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 388, 241, 750, 360)
$Step1 = GUICtrlCreateLabel("Step 1", 32, 40, 42, 20)
$Step2 = GUICtrlCreateLabel("Step 3", 216, 40, 42, 20)
$Step3 = GUICtrlCreateLabel("Step 2", 120, 40, 42, 20)
$Step4 = GUICtrlCreateLabel("Step 4", 312, 40, 42, 20)
$Input_Text = GUICtrlCreateInput("", 48, 104, 289, 24)
$OK = GUICtrlCreateButton("OK", 152, 176, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    $aInfo = GUIGetCursorInfo($Form1)
    If $aInfo[2] Then
        If $aInfo[4] = $Input_Text Then GUICtrlSetData($Input_Text, "")
    EndIf

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $OK = 1
            ; It should run the Step1 Function

        Case $OK = 2
            ; It should run the Step2 Function

        Case $OK = 3
            ; It should run the Step3 Function

        Case $OK = 4
            ; It should run the Step4 Function
    EndSwitch
WEnd

;Func
    ;Step1
;EndFunc

;Func
    ;Step2
;EndFunc

;Func
    ;Step3
;EndFunc

 

 

Link to comment
Share on other sites

Can you try it using combo box

$Gui=GUICreate("GUI",300,200,750,350)
$combo=GuiCtrlCreateCombo=("",50,50,200,30)
GuiCtrlSetData(-1,"Step1|Step2|Step3|Step4")
$ok=GuiCtrlCreateButton("OK",50,100,75,25)
While 1
    $nMsg=GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ok
            $Step=GuiCtrlRead($combo)
            Switch $Step
                Case "Step1"
                    Step1()
                Case "Step2"
                    Step2()
                Case "Step3"
                   Step3()
                Case "Step4"
                    Step4()
            EndSwitch
    EndSwitch
WEnd
Func Step1()
    Msgbox(0,"","step1")
EndFunc
Func Step2()
    Msgbox(0,"","step2")
EndFunc
Func Step3()
    Msgbox(0,"","step3")
EndFunc
Func Step4()
    Msgbox(0,"","step4")
EndFunc

 

Link to comment
Share on other sites

Or

$Gui=GUICreate("GUI",300,200,750,350)
$combo=GuiCtrlCreateCombo=("",50,50,200,30)
GuiCtrlSetData(-1,"Step1|Step2|Step3|Step4|...")
$ok=GuiCtrlCreateButton("OK",50,100,75,25)
While 1
    $nMsg=GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ok
            $Step=GuiCtrlRead($combo)
            Call($Step)
    EndSwitch
WEnd
Func Step1()
    Msgbox(0,"","step1")
EndFunc
Func Step2()
    Msgbox(0,"","step2")
EndFunc
Func Step3()
    Msgbox(0,"","step3")
EndFunc
Func Step4()
    Msgbox(0,"","step4")
EndFunc

 

Link to comment
Share on other sites

Both of the above codes are not running, even after removing the '=' from GuiCtrlCreateCombo=("",50,50,200,30).

Also I do not want this as GUI Combo Drop box way... Below is the picture and the way I am looking for.

Whoever is using the code will know what is Step 1 | Step 2 | Step 3 | Step 4. So, they just have to enter either 1, 2, 3 or 4 and click OK. depending upon the numbers entered, it would run the functions assigned for.

So basically, if someone enters '1' in the box and hits OK, that '1' should run the function inside

Func Step1()
    Msgbox(0,"","step1")
EndFunc

Example.jpg

Edited by sunshinesmile84
Link to comment
Share on other sites

Ok, I figured out. This is how I was looking for.

I will let you know if any more issues.

Thanks for your help. :)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 388, 241, 750, 360)
$Step1 = GUICtrlCreateLabel("Step 1", 32, 40, 42, 20)
$Step2 = GUICtrlCreateLabel("Step 3", 216, 40, 42, 20)
$Step3 = GUICtrlCreateLabel("Step 2", 120, 40, 42, 20)
$Step4 = GUICtrlCreateLabel("Step 4", 312, 40, 42, 20)
$Input_Text = GUICtrlCreateInput("", 48, 104, 289, 24)
$OK = GUICtrlCreateButton("OK", 152, 176, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    $aInfo = GUIGetCursorInfo($Form1)
    If $aInfo[2] Then
        If $aInfo[4] = $Input_Text Then GUICtrlSetData($Input_Text, "")
    EndIf

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit


        Case $OK
            Select
                Case GUICtrlRead($Input_Text) = '1'
                    Msgbox(0,"","step1")

                Case GUICtrlRead($Input_Text) = '2'
                    Msgbox(0,"","step2")

                Case GUICtrlRead($Input_Text) = '3'
                    Msgbox(0,"","step3")

                Case GUICtrlRead($Input_Text) = '4'
                    Msgbox(0,"","step4")
            EndSelect

    EndSwitch
WEnd

 

Edited by sunshinesmile84
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...