jeaman 发表于 2008-5-30 22:56:46

如何实现在Input控件中输入回车键后执行指定操作?

如题。据说注册消息可以,但是我看了一天这方面的资料还是没弄懂。或者谁有系统消息这方面的资料比较详细讲解的。
http://hi.baidu.com/zhch_ao/blog/item/cdc4efecdb7aa22662d09fe3.html
上面的文章讲解的比较详细了。但是还不能完全参透。

penguinl 发表于 2008-6-1 22:20:12

如果你多个控件都需要接收回车这个事件的话,那就比较复杂,如果只是单一的一个input的话,你可以用hotkey来实现!好像是这样写的吧!不是很记得了,你翻一下帮助!

hehui 发表于 2008-6-2 08:46:19

AU3在消息处理方面有待加强!

webhelp 发表于 2008-11-29 01:41:36

GUISetAccelerators()函数

例子在6楼。

[ 本帖最后由 webhelp 于 2008-11-29 05:23 编辑 ]

sanhen 发表于 2008-11-29 01:46:13

直接按照教程的方法注册Input控件的事件即可。

webhelp 发表于 2008-11-29 05:13:41

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Process.au3>


GUICreate("Input回车示例", 533, 142, 219, 320)
GUICtrlCreateLabel("输入网址后按回车和按打开按钮一样的效果,且不会影响其他窗口。", 16, 20, 380, 17)
GUICtrlCreateLabel("输入正确的网址:", 16, 55, 116, 17)
$Address = GUICtrlCreateInput("Http://www.baidu.com", 136, 52, 377, 21)
$Run = GUICtrlCreateButton("打开(&O)", 104, 96, 113, 25, 0)
$Exit = GUICtrlCreateButton("退出(&X)", 298, 96, 113, 25, 0)

Dim $AccelKeys=[["{Enter}", $Address], ["{Enter}", $Run]]
GUISetAccelerators($AccelKeys)

GUISetState(@SW_SHOW)


While 1
        $Msg = GUIGetMsg()
        Select
                Case $Msg = $GUI_EVENT_CLOSE Or $Msg = $Exit
                        Exit
                Case $Msg = $Address
                        _RunDOS("start "& GUICtrlRead($Address))
                Case $Msg = $Run
                        _RunDOS("start "& GUICtrlRead($Address))
    EndSelect
WEnd

嘿嘿,这样就OK了。主要看下GUISetAccelerators()函数,貌似只有新版里才有。

botanycc 发表于 2009-6-5 09:39:16

终于找到例子了,爽

javarike 发表于 2009-6-5 10:49:50

呵呵,热键处理。。
页: [1]
查看完整版本: 如何实现在Input控件中输入回车键后执行指定操作?