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

[AU3基础] 如果让一个输入框响应键盘而不响应鼠标改变

[复制链接]
发表于 2011-12-3 01:47:55 | 显示全部楼层 |阅读模式
本帖最后由 jamer 于 2011-12-3 01:50 编辑

可能题目讲的不是很严谨,我的意思是这样的,一个输入框,当我输入完成后,按回车,自动调用某函数(我额外弄个了按钮,目的就是为了表现输入框中按回车和点击按钮的效果一样)
#include <GUIConstantsEx.au3>

$Form1_1 = GUICreate("Form1", 298, 100, 450, 339)
$Input1 = GUICtrlCreateInput("password", 20, 16, 137, 21)
$label1 = GUICtrlCreateLabel("原文",20,50,147,21)
$Button2 = GUICtrlCreateButton("显示", 240, 16, 49, 73)
GUISetState(@SW_SHOW)
 
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        Case $Button2 Or $label1
                 GUICtrlSetData($label1,GUICtrlRead($Input1))
        EndSwitch
WEnd
我的愿意是,输入框输入完成后,按回车,输入框内容输出到标签上
但是上面这个代码也响应鼠标改变,即输入完文本后,移动鼠标,输入框内容也会输出到标签上,我想禁止这个响应,只在键盘回车时会输出内容(如果能检测输入框内容改变 然后输出内容就更好了)
Au3Chm函数询捕 实现了这个功能,想知道怎么实现的。。
求达人
发表于 2011-12-3 02:02:13 | 显示全部楼层
#include <GUIConstantsEx.au3>

$Form1_1 = GUICreate("Form1", 298, 100, 450, 339)
$Input1 = GUICtrlCreateInput("password", 20, 16, 137, 21)
$label1 = GUICtrlCreateLabel("原文",20,50,147,21)
$Button2 = GUICtrlCreateButton("显示", 240, 16, 49, 73)
GUISetState(@SW_SHOW)
 
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        Case $Button2,$Input1
                 GUICtrlSetData($label1,GUICtrlRead($Input1))
        EndSwitch
WEnd

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

 楼主| 发表于 2011-12-3 02:15:52 | 显示全部楼层
。。这么简单啊。。
那再问一下case里面 逗号 和 OR的区别在那里呢?
发表于 2011-12-3 09:37:12 | 显示全部楼层
回复 3# jamer
#include <GUIConstantsEx.au3>

$Form1_1 = GUICreate("Form1", 298, 100, 450, 339)
$Input1 = GUICtrlCreateInput("password", 20, 16, 137, 21)
$label1 = GUICtrlCreateLabel("原文", 20, 50, 147, 21)
$Button2 = GUICtrlCreateButton("显示", 240, 16, 49, 73)
$Dummy = GUICtrlCreateDummy()
GUISetState(@SW_SHOW)

Local $Key[1][2] = [["{Enter}", $Dummy]]
GUISetAccelerators($Key)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button2
                        GUICtrlSetData($label1, GUICtrlRead($Input1))
                Case $Dummy
                        Local $aResult = DllCall("user32.dll", "hwnd", "GetFocus")
                        If $aResult[0] = GUICtrlGetHandle($Input1) Then
                                GUICtrlSetData($label1, GUICtrlRead($Input1))
                        EndIf
        EndSwitch
WEnd

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-10 15:16 , Processed in 0.089583 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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