Sign in to follow this  
Followers 0
supersonic

Pressing ENTER in input control

5 posts in this topic

Hi!

May be this was discussed many times... :mellow:

I'm trying to ENTER an input control.

In order to work I have to press BACKSPACE or LEFT/RIGHT ARROW first.

Here's the sample code:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>

Local $hGUI     = GUICreate("", 200, 100, -1, -1)
Local $hGUI_C   = GUICtrlCreateInput("X", 1, 1, 198, 21)

GUISetState(@SW_SHOW, $hGUI)

While 1
    Local $msg = GUIGetMsg(1)
    Switch $msg[1]
        Case $hGUI
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    ExitLoop
                Case $hGUI_C
                    _test()
            EndSwitch
    EndSwitch
WEnd

GUIDelete($hGUI)
Exit

Func _test()
    MsgBox(0, "", "", 0, GUICreate(""))
EndFunc

Please, could somebody help me?

Greets,

-supersonic.

Share this post


Link to post
Share on other sites



What do you want to achieve with your code?

The GUI now displays an input control with the content ("X") already selected. Why dow you want to press BACKSPACE or LEFT/RIGHT ARROW first?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

There are probably other easyer wayes that arnt so brutali like thisone (like focusing on defolt button on enter),

You can do it like this

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#Include <Misc.au3>

Local $hGUI     = GUICreate("test", 200, 100, -1, -1)
Local $hGUI_C   = GUICtrlCreateInput("Working ENTER", 1, 1, 198, 21)
Local $hGUI_D   = GUICtrlCreateInput("...", 1, 20, 198, 21)

GUISetState(@SW_SHOW, $hGUI)

While 1
    If _IsPressed("0D") And WinActive("test") And ControlGetFocus("test") = "Edit1" Then
        _test()
    EndIf
    Local $msg = GUIGetMsg(1)
    Switch $msg[1]
        Case $hGUI
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    ExitLoop
                Case $hGUI_C
            EndSwitch
    EndSwitch
WEnd

GUIDelete($hGUI)
Exit

Func _test()
    MsgBox(0, "", "", 0, GUICreate(""))
EndFunc
Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

The input has the focus. I just want to press enter and - depending on the input data - an action starts...

Currently - in order to work - I first have to press BACKSPACE or LEFT/RIGHT ARROW within the input control.

Without, nothing happens...

I have changed the sample code:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>

Local $hGUI     = GUICreate("", 200, 100, -1, -1)
Local $hGUI_C   = GUICtrlCreateInput("", 1, 1, 198, 21)

GUISetState(@SW_SHOW, $hGUI)

While 1
    Local $msg = GUIGetMsg(1)
    Switch $msg[1]
        Case $hGUI
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    ExitLoop
                Case $hGUI_C
                    _test()
            EndSwitch
    EndSwitch
WEnd

GUIDelete($hGUI)
Exit

Func _test()
    Local $sTmp = GUICtrlRead($hGUI_C, 0)
    If Not $sTmp Then
        MsgBox(0, "", "Input control empty.")
    Else
        MsgBox(0, "", $sTmp)
    EndIf
EndFunc

Share this post


Link to post
Share on other sites

@bogQ - Thank you, I will give it a try...

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