如果让一个输入框响应键盘而不响应鼠标改变
本帖最后由 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函数询捕 实现了这个功能,想知道怎么实现的。。
求达人 #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 。。这么简单啊。。
那再问一下case里面 逗号 和 OR的区别在那里呢? 回复 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 = [["{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 = GUICtrlGetHandle($Input1) Then
GUICtrlSetData($label1, GUICtrlRead($Input1))
EndIf
EndSwitch
WEnd
页:
[1]