Jump to content

Recommended Posts

Posted

Hi Guys,

it is so simple, but i can't figure out this :DD

$Input5 = GUICtrlCreateInput("", 8, 312, 121, 21)
GUICtrlSetTip(-1, "Gime some")
$Label8 = GUICtrlCreateLabel("test input", 8, 336, 116, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button5 = GUICtrlCreateButton("Check", 136, 312, 65, 25, BitOR($BS_NOTIFY,$WS_TABSTOP,$WS_VISIBLE,$WS_CHILD))

any ideas how do the trick with enter to go, i mean after input some stuff in input field i want to hit enter to 'check'

offcorse i can do TAB-enter or use mouse .. but its will be nice if after inpus some and hit enter its will go forward :(

Thx and regards

  • Moderators
Posted

lxxl,

I am not too sure what exactly you want to do, so this might be wide of the mark. :)

If you want something to happen when you press "Enter" after entering something in an Input, you can do it with an Accelerator key like this:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$hInput = GUICtrlCreateInput("", 10, 10, 480, 20)
$hLabel = GUICtrlCreateLabel("", 10, 50, 480, 20)
$hDummy = GUICtrlCreateDummy()

GUISetState()

; Set accelerator for Enter to action the Dummy code
Dim $AccelKeys[1][2]=[["{ENTER}", $hDummy]]
GUISetAccelerators($AccelKeys)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hDummy
            GUICtrlSetData($hLabel, GUICtrlRead($hInput))
    EndSwitch

WEnd

Now pressing "Enter" will run the code for the Dummy control Case in the GUIGetMsg loop.

I hope that is what you wanted. If not, explain again! :(

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:

  Reveal hidden contents

 

Posted

  On 3/26/2010 at 1:07 PM, 'Melba23 said:

If you want something to happen when you press "Enter" after entering something in an Input, you can do it with an Accelerator key like this:

Started before, but had a meeting :( ...

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

$hGUI = GUICreate(" My GUI", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45)

$dummy_input_start = GUICtrlCreateDummy()
$input1 = GUICtrlCreateInput("", 10, 5, 300, 20)
$input2 = GUICtrlCreateInput("", 10, 35, 300, 20)
$dummy_input_end = GUICtrlCreateDummy()

$dummy_input_trigger = GUICtrlCreateDummy()
Global $iActiveInput

$btn = GUICtrlCreateButton("Exit", 40, 75, 60, 20)

Dim $AccelKeys[1][2] = [["{ENTER}", $dummy_input_trigger]]
GUISetAccelerators($AccelKeys)

GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUICtrlSetState($input1,$GUI_FOCUS)
GUISetState()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
    Select
        Case $msg = $btn
            ExitLoop
    EndSelect
WEnd

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    $nNotifyCode = BitShift($wParam, 16)
    $nID = BitAND($wParam, 0x0000FFFF)
    $hCtrl = $lParam

    if $nID > $dummy_input_start and $nID < $dummy_input_end then
        if $nNotifyCode = 256 then $iActiveInput = $nID
    endif

    if $nID = $dummy_input_trigger Then
        Switch $iActiveInput
            Case $dummy_input_end -1
                GUICtrlSetState($dummy_input_start+1,$GUI_FOCUS)
                ControlSend($hGUI,"",$dummy_input_start+1,"{END}")
            Case Else
                GUICtrlSetState($iActiveInput+1,$GUI_FOCUS)
                ControlSend($hGUI,"",$iActiveInput+1,"{END}")
        EndSwitch
    endif

    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_COMMAND
  • Moderators
Posted (edited)

KaFu,

Very nice - and I think you understood better than I did! :(

However, I will raise you with this modified version:

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

Global $iActiveInput

$hGUI = GUICreate(" My GUI", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45)

$input1 = GUICtrlCreateInput("", 10, 5, 300, 20)
$input2 = GUICtrlCreateInput("", 10, 35, 300, 20)

$dummy_input_trigger = GUICtrlCreateDummy()

$btn_1 = GUICtrlCreateButton("Exit", 40, 75, 60, 20)
$btn_2 = GUICtrlCreateButton("Log In", 140, 75, 60, 20)
$dummy_log_in = GUICtrlCreateDummy()

Dim $AccelKeys[1][2] = [["{ENTER}", $dummy_input_trigger]]
GUISetAccelerators($AccelKeys)

GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
GUICtrlSetState($input1, $GUI_FOCUS)
GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $btn_1
            ExitLoop
        Case $btn_2, $dummy_log_in
            MsgBox(0, "", "Logging in")
            GUICtrlSetState($input1, $GUI_FOCUS)
            GUICtrlSetData($input1, "")
            GUICtrlSetData($input2, "")
    EndSwitch

WEnd

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    $nNotifyCode = BitShift($wParam, 16)
    $nID = BitAND($wParam, 0x0000FFFF)
    $hCtrl = $lParam

    If $nID = $input1 Or $nID = $input2 Then
        If $nNotifyCode = 256 Then $iActiveInput = $nID
    EndIf

    If $nID = $dummy_input_trigger Then
        Switch $iActiveInput
            Case $input2
                GUICtrlSendToDummy($dummy_log_in)
            Case Else
                GUICtrlSetState($input2, $GUI_FOCUS)
                GUICtrlSetData($input2, "")
        EndSwitch
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_COMMAND

Now pressing Enter on the second input logs in! :)

M23

Edit: Typnig!

Edited by Melba23

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:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...