敲键盘上的回车键模拟点击按钮功能该如何写(已解决)
本帖最后由 qsy666888 于 2018-4-1 13:54 编辑不用鼠标点击$Button1 按钮,敲键盘上的回车键来指令$Button1 按钮功能'#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 310, 190)
$Button1 = GUICtrlCreateButton("回车键", 112, 56, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 112, 88, 75, 25)
$Button3 = GUICtrlCreateButton("Button3", 112, 120, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
MsgBox(0,'','敲键盘上的回车键模拟点击$Button1 按钮功能')
EndSwitch
WEnd
$Button1 = GUICtrlCreateButton("回车键", 112, 56, 75, 25,$BS_DEFPUSHBUTTON)
焦点在此按钮上 回复 2# 229989799
不是你那个意思,我是想执行$Button2按钮 或者$Button3按钮操作后,按一下回车键就执行了$Button1按钮的功能 论坛有很多例子啊~·搜索一下 回复 3# qsy666888
http://www.autoit3.cn/thread-56537-1-2.html
我就记得是你提问的来着,果不其然~
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 310, 190)
$Button1 = GUICtrlCreateButton("回车键", 112, 56, 75, 25,$BS_DEFPUSHBUTTON)
$Button2 = GUICtrlCreateButton("Button2", 112, 88, 75, 25)
$Button3 = GUICtrlCreateButton("Button3", 112, 120, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
MsgBox(0,'','敲键盘上的回车键模拟点击$Button1 按钮功能')
GUICtrlSetState($Button1,256)
Case $Button2
MsgBox(0,'','按钮2')
GUICtrlSetState($Button1,256)
Case $Button3
MsgBox(0,'','按钮3')
GUICtrlSetState($Button1,256)
EndSwitch
WEnd
本帖最后由 austere 于 2018-3-9 11:18 编辑
回复 1# qsy666888
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 310, 190)
$Button1 = GUICtrlCreateButton("回车键", 112, 56, 75, 25)
Dim $123 = [["{ENTER}", $Button1]]
GUISetAccelerators($123)
$Button2 = GUICtrlCreateButton("Button2", 112, 88, 75, 25)
$Button3 = GUICtrlCreateButton("Button3", 112, 120, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
MsgBox(0, '', '敲键盘上的回车键模拟点击$Button1 按钮功能')
EndSwitch
WEnd
回复 7# austere
谢谢兄弟,让兄弟笑了,上一个帖子是让按钮建立退格功能,这次是让按钮跟键盘的回车键相联,谢谢兄弟了 回复 8# qsy666888
实际上是一样的~你用我发的这个,也适合你退格那个~ 多搜索一下就好了
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 310, 190)
$Button1 = GUICtrlCreateButton("回车键", 112, 56, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 112, 88, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_fc_1()
Case $Button2
HotKeySet("{enter}",'_fc_1')
ConsoleWrite(2)
EndSwitch
WEnd
Func _fc_1()
MsgBox(0,'','敲键盘上的回车键模拟点击$Button1 按钮功能')
EndFunc
回复 10# fenhanxue
HotKeySet这个代码问题多,运行这个代码就不能操作其他程序,
页:
[1]