Jump to content

Send text in input box


Recommended Posts

I have crated ten buttons in my GUI - 1;2;3;4;5;6;7;8;9;0 and an input box. I want to make button one send "1" in the input box, button two send "2" in the input box etc.

how can I do that?

Tanq!

while 1
 $Msg = GuiGetMsg()
  switch $Msg
   Case $button1;add text
     $text = GuiCtrlRead($Edit1)
     GuiCtrlSetData($Edit1, $Text & '1');to add the number to the text in the input
     
   Case $button2;replace text
     GuiCtrlSeytData($Edit1,'2')
.
.
.
  EndSwitch

wend
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

plz help me out with this. When i write 123456789 in the input box, my gui closes, when i don't write anything at all into the input box, it shows msgbox. What should I do to make msgbox appear when I wrote a wrong number combination in the input box?

#include <GuiConstants.au3>

GuiCreate("sample", 96, 66)
$text = "123456789"
$input = GUICtrlCreateInput("",3,3, 90, 30, $ES_NUMBER)
$Button_ok = GUICtrlCreateButton ("ok",-1,33,30,30, $BS_DEFPUSHBUTTON )

GUISetState ()
While 1
    $msg = GUIGetMsg()
    switch $msg
        
        Case $Button_ok
            If $text = GUICtrlRead($input)Then
                ExitLoop
            ElseIf not $text = GUICtrlRead($input) Then
                Msgbox(0, "", "false")
            EndIf
            
        Case $GUI_EVENT_CLOSE 
            ExitLoop
    EndSwitch
Wend
Link to comment
Share on other sites

#include <GuiConstants.au3>

GuiCreate("sample", 96, 66)
$text = "123456789"
$input = GUICtrlCreateInput("",3,3, 90, 30, $ES_NUMBER)
$Button_ok = GUICtrlCreateButton ("ok",-1,33,30,30, $BS_DEFPUSHBUTTON )

GUISetState ()
While 1
    $msg = GUIGetMsg()
    switch $msg
        
        Case $Button_ok
            If $text = GUICtrlRead($input)Then
                ExitLoop
            Else
                Msgbox(0, "", "false")
            EndIf
            
        Case $GUI_EVENT_CLOSE 
            ExitLoop
    EndSwitch
Wend


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

plz help me out with this. When i write 123456789 in the input box, my gui closes, when i don't write anything at all into the input box, it shows msgbox. What should I do to make msgbox appear when I wrote a wrong number combination in the input box?

#include <GuiConstants.au3>

GuiCreate("sample", 96, 66)
$text = "123456789"
$input = GUICtrlCreateInput("",3,3, 90, 30, $ES_NUMBER)
$Button_ok = GUICtrlCreateButton ("ok",-1,33,30,30, $BS_DEFPUSHBUTTON )

GUISetState ()
While 1
    $msg = GUIGetMsg()
    switch $msg
        
        Case $Button_ok
            If $text = GUICtrlRead($input)Then
                ExitLoop
            ElseIf not $text = GUICtrlRead($input) Then
                Msgbox(0, "", "false")
            EndIf
            
        Case $GUI_EVENT_CLOSE 
            ExitLoop
    EndSwitch
Wend

You are destroying the original value of $text which needs to be kept the same, and I don't think you can compare strings in AutoIt like that.

Try this

#include <GuiConstants.au3>

GuiCreate("sample", 96, 66)
$text = "123456789"
$input = GUICtrlCreateInput("",3,3, 90, 30, $ES_NUMBER)
$Button_ok = GUICtrlCreateButton ("ok",-1,33,30,30, $BS_DEFPUSHBUTTON )

GUISetState ()
While 1
    $msg = GUIGetMsg()
    switch $msg
       
        Case $Button_ok
             $text1 = GUICtrlRead($input)
             If StringLen($text1) = 9 and StringInStr($text,$text1) then
                ExitLoop
            Else
                Msgbox(0, "", "false")
            EndIf
           
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
Wend
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...