Sign in to follow this  
Followers 0
Queener

press enter while in textbox or input

6 posts in this topic

#1 ·  Posted (edited)

I'm kind of lost on how to code this; when the cursor focus in the input box or textbox and user press Enter, it calls a function.

Only guess that I can think of is:

 
While GUICtrlSetState($searchinput, $GUI_FOCUS)
if send("{ENTER}") then
testfunction()
endif
WEnd
Edited by asianqueen

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I'm not sure about the input box ect. but here's how you can detect when they press enter.

http://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm

IE:

#include <Misc.au3>

Local $hDLL = DllOpen("user32.dll")

While 1
    If _IsPressed("0D", $hDLL) Then
        MsgBox(0, "Test", "Enter was pressed")
    EndIf
    Sleep(250)
WEnd
Edited by Damein

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites

You can do this with Accelerators. Something like this:

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

GUICreate("Test", 300, 300)
$input = GUICtrlCreateInput("", 10, 10, 280, 100)
Local $accelerators[1][2]
    $accelerators[0][0] = "{ENTER}"
    $accelerators[0][1] = $input

GUISetAccelerators($accelerators)

GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $input
                MsgBox(0, "", "Enter Sent")
        EndSwitch
    WEnd

GUIDelete()

When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

Without accelerators.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $Button_1, $Button_2, $msg
    GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered

    Opt("GUICoordMode", 2)
    $Button_1 = GUICtrlCreateButton("Run Notepad", 10, 30, 100, 20, $BS_DEFPUSHBUTTON) ;make default button
    $Button_2 = GUICtrlCreateButton("Button Test", 0, -1)
    GUICtrlCreateInput("", 10, -1, 200, 20); when ebter pressed with focus on input, acts like default button was pressed. and will in this case run notepad

    GUISetState() ; will display an  dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                Run('notepad.exe') ; Will Run/Open Notepad
            Case $msg = $Button_2
                MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed
        EndSelect
    WEnd
EndFunc   ;==>Example

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Also,

have a look >here


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

thanks for the info, but this works well for me. I got from searching the forum...

Local $nMsg[5]
While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
        Case $GUI_EVENT_CLOSE
            _Exit()
        Case $ExitB1
            _Exit()
        Case $searchinput ;when press Enter, go to Func Search
            Search()
    EndSwitch
WEnd

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

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