Sign in to follow this  
Followers 0
SuddenGunfire

Input into the edit box

5 posts in this topic

Basically I have created a GUI with a edit box. I am going to add some buttons.

When I click the button I would like the text to be entered into the edit box I created.

Thanks:

Source so far:

;***************************************
;*    COPYRIGHT: 2009 SJN Programs     *
;*    AUTHOR: Sam Nicholson            *
;*    VERSION: 1.0.0                   *
;*    EMAIL: sam.j.nicholson@live.co.uk*
;***************************************

; Include the constants command.
#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

_Main ()

Func _Main()
    ;Variable start
    Local $GUIWidth = 500, $GUIHeight = 500
    Local $Edit_1, $msg, $iMsgBoxAnswer
    
    ;Window create using the Width and Height Variable. Quicker way.
    GUICreate("Batch Command Generator", $GUIWidth, $GUIHeight)
    
    ;Create the edit box with the MUST have for all batch - @echo off
    $Edit_1 = GUICtrlCreateEdit("@echo off", 5, 5, 280, 500)
    
    ;Button 1 
    
    ;echo off message
    Dim $iMsgBoxAnswer 
    $iMsgBoxAnswer = MsgBox(8774,"Batch Note","Please note that the command @echo off removes the command echo from a CMD window. I suggest that you always declare this variable. ",30)
    Select
   Case $iMsgBoxAnswer = 2  ;Cancel

   Case $iMsgBoxAnswer = 11 ;Continue

   Case $iMsgBoxAnswer = -1 ;Timeout

EndSelect
    
    ;Make the window a visible applications
    GUISetState(@SW_SHOW)
    
    ;Loop until:
    ;- user presses Esc
    ;- user presses Alt+F4
    ;- user clicks the close button
    While 1
        ;After every loop check if the user clicked something in the GUI window
        $msg = GUIGetMsg()

        Select

            ;Check if user clicked on the close button
            Case $msg = $GUI_EVENT_CLOSE
                ;Destroy the GUI including the controls
                GUIDelete()
                ;Exit the script
                Exit
            EndSelect
        WEnd
        
        EndFunc   ;==>_Main

Share this post


Link to post
Share on other sites



Basically I have created a GUI with a edit box. I am going to add some buttons.

When I click the button I would like the text to be entered into the edit box I created.

Thanks:

Source so far:

;***************************************
;*    COPYRIGHT: 2009 SJN Programs     *
;*    AUTHOR: Sam Nicholson            *
;*    VERSION: 1.0.0                   *
;*    EMAIL: sam.j.nicholson@live.co.uk*
;***************************************

; Include the constants command.
#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

_Main ()

Func _Main()
    ;Variable start
    Local $GUIWidth = 500, $GUIHeight = 500
    Local $Edit_1, $msg, $iMsgBoxAnswer
    
    ;Window create using the Width and Height Variable. Quicker way.
    GUICreate("Batch Command Generator", $GUIWidth, $GUIHeight)
    
    ;Create the edit box with the MUST have for all batch - @echo off
    $Edit_1 = GUICtrlCreateEdit("@echo off", 5, 5, 280, 500)
    
    ;Button 1 
    
    ;echo off message
    Dim $iMsgBoxAnswer 
    $iMsgBoxAnswer = MsgBox(8774,"Batch Note","Please note that the command @echo off removes the command echo from a CMD window. I suggest that you always declare this variable. ",30)
    Select
   Case $iMsgBoxAnswer = 2  ;Cancel

   Case $iMsgBoxAnswer = 11 ;Continue

   Case $iMsgBoxAnswer = -1 ;Timeout

EndSelect
    
    ;Make the window a visible applications
    GUISetState(@SW_SHOW)
    
    ;Loop until:
    ;- user presses Esc
    ;- user presses Alt+F4
    ;- user clicks the close button
    While 1
        ;After every loop check if the user clicked something in the GUI window
        $msg = GUIGetMsg()

        Select

            ;Check if user clicked on the close button
            Case $msg = $GUI_EVENT_CLOSE
                ;Destroy the GUI including the controls
                GUIDelete()
                ;Exit the script
                Exit
            EndSelect
        WEnd
        
        EndFunc   ;==>_Main

I'm not sure I understand what you mean... Maybe it's just me though..

Share this post


Link to post
Share on other sites

Say if a a button said "Hello" When I click the button I want it to be typed into the edit box.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Here's a quick and dirty way of doing what you want.

#include <guiconstantsex.au3>

$gui = GUICreate("Test", 270, 100)
$Input = GUICtrlCreateInput("", 50, 25, 150, 20)
$Button1 = GUICtrlCreateButton("Button 1", 50, 50, 50, 20)
$Button2 = GUICtrlCreateButton("Button 2", 100, 50, 50, 20)
$Button3 = GUICtrlCreateButton("Button 3", 150, 50, 50, 20)
$Exit = GUICtrlCreateButton("Exit", 200, 75, 50, 20)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Exit
            Exit
        Case $Button1
            GUICtrlSetData($Input, "Button 1")
        Case $Button2
            GUICtrlSetData($Input, "Button 2")
        Case $Button3
            GUICtrlSetData($Input, "Button 3")
    EndSwitch
WEnd
Edited by 5t0n3r

Share this post


Link to post
Share on other sites

Say if a a button said "Hello" When I click the button I want it to be typed into the edit box.

Probably not the best way.. but it works..

;***************************************
;*    COPYRIGHT: 2009 SJN Programs     *
;*    AUTHOR: Sam Nicholson            *
;*    VERSION: 1.0.0                   *
;*    EMAIL: sam.j.nicholson@live.co.uk*
;***************************************

; Include the constants command.
#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)



_Main ()

Func _Main()
    ;Variable start
    Local $GUIWidth = 500, $GUIHeight = 500
    Local $Edit_1, $msg, $iMsgBoxAnswer, $Button_1, $Button_1text

    ;Window create using the Width and Height Variable. Quicker way.
    GUICreate("Batch Command Generator", $GUIWidth, $GUIHeight)

    ;Create the edit box with the MUST have for all batch - @echo off
    $Edit_1 = GUICtrlCreateEdit("@echo off", 5, 5, 280, 500)

    ;Button 1
    $Button_1 = GUICtrlCreateButton("Hello",300,25,40,25)

    ;echo off message
    Dim $iMsgBoxAnswer
    $iMsgBoxAnswer = MsgBox(8774,"Batch Note","Please note that the command @echo off removes the command echo from a CMD window. I suggest that you always declare this variable. ",30)
    Select
   Case $iMsgBoxAnswer = 2  ;Cancel

   Case $iMsgBoxAnswer = 11 ;Continue

   Case $iMsgBoxAnswer = -1 ;Timeout

EndSelect

    ;Make the window a visible applications
    GUISetState(@SW_SHOW)

    ;Loop until:
    ;- user presses Esc
    ;- user presses Alt+F4
    ;- user clicks the close button
    While 1
        ;After every loop check if the user clicked something in the GUI window
        $msg = GUIGetMsg()

        Select

            Case $msg = $Button_1
            $Button_1text = ControlGetText("Batch Command Generator","","[CLASS:Button; INSTANCE:1]")
            ControlSetText("Batch Command Generator", "" , "[CLASS:Edit; INSTANCE:1]",$Button_1text)
            ;Check if user clicked on the close button
            Case $msg = $GUI_EVENT_CLOSE
                ;Destroy the GUI including the controls
                GUIDelete()
                ;Exit the script
                Exit
            EndSelect
        WEnd

        EndFunc   ;==>_Main

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