找回密码
 加入
搜索
查看: 2189|回复: 3

如何捕获Input的回车事件?

[复制链接]
发表于 2008-7-30 14:05:28 | 显示全部楼层 |阅读模式
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>

Opt("GUIOnEventMode", 1)

$formInput = GUICreate("查询", 266, 21, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SYSMENU, $WS_DLGFRAME, $WS_POPUP, $WS_GROUP, $WS_CLIPSIBLINGS), BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_TRANSPARENT, $WS_EX_WINDOWEDGE))
$iptCondition = GUICtrlCreateInput("", 0, 0, 265, 21)
$iptCondition = GUICtrlCreateInput("", 0, 0, 265, 21)
GUICtrlSetOnEvent(-1, "iptConditionChange")
GUISetState(@SW_SHOW)

HotKeySet("{F8}", "ShowInputWindow")
HotKeySet("^{F8}", "HideInputWindow")

While 1
        Sleep(100)
WEnd

Func iptConditionChange()
        #cs
        If _IsPressed("0D") Then
                MsgBox("","","0d")
        Else
                MsgBox("","","")
        EndIf
        #ce
EndFunc   ;==>iptConditionChange

;显示输入窗口
Func ShowInputWindow()
        ViewInputWindow(True)
EndFunc   ;==>ShowInputWindow

;隐藏输入窗口
Func HideInputWindow()
        ViewInputWindow(False)
EndFunc   ;==>HideInputWindow

;设置窗口可见性
Func ViewInputWindow($Visible)
        If $Visible Then
                GUISetState(@SW_SHOW)
        Else
                GUISetState(@SW_HIDE)
        EndIf
EndFunc   ;==>ViewInputWindow

<P>&nbsp;</P>
<P>希望能在文本框 iptCondition 按下回车键的时候执行一些代码,可是当文本框内容发生变化时,iptConditionChange 根本不发生。</P>
<P>&nbsp;</P>
<P>请大家帮帮忙,应该怎么写好?</P>
<P>&nbsp;</P>

[ 本帖最后由 runningwater 于 2008-7-30 15:46 编辑 ]
 楼主| 发表于 2008-7-30 15:46:02 | 显示全部楼层
已经找到问题所在了,第 10 行又创建了一个文本框,所以 Change 事件不发生。
发表于 2011-2-14 13:38:11 | 显示全部楼层
很好 学习了
发表于 2011-3-15 05:14:40 | 显示全部楼层
回复 1# runningwater


        好东西啊 ~~~留个脚印
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-10-2 12:21 , Processed in 0.205586 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表