本帖最后由 雨林GG 于 2010-8-14 15:13 编辑
想着按Ctrl+Enter后,如何执行与按钮一样的动作?
1.类似于快捷键的动作与$Button1的动作一样,但又不想在_SendM()中再复制一遍代码.
2.不想用_GUICtrlButton_Click和ControlClick等点击行为.#include <GuiButton.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiImageList.au3>
Opt("GUIOnEventMode", 1)
HotKeySet("^{ENTER}", "_SendM")
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 372, 313, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "OnEvent_Main")
$Edit1 = GUICtrlCreateEdit("", 10, 9, 350, 237)
GUICtrlSetData(-1, "Edit1")
$Button1 = GUICtrlCreateButton("Button1", 117, 258, 100, 43, 0)
GUICtrlSetOnEvent(-1, "OnEvent_Main")
$hImage1 = _GUIImageList_Create(24, 24, 5, 3, 0)
_GUIImageList_AddIcon($hImage1, "Shell32.dll", -165, True)
_GUICtrlButton_SetImageList(-1, $hImage1, 0, 0, 5)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
Sleep(100)
WEnd
Func OnEvent_Main()
Switch @GUI_CtrlId
Case $Button1 ;注意这里代码会很长
GUICtrlSetData($Edit1, "不想用ControlClick&_GUICtrlButton_Click") ;并不只是为了设置下文本
ControlFocus($Form1, "", $Edit1)
Case $Edit1 ;
;
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
EndFunc ;==>OnEvent_Main
Func _SendM()
;_GUICtrlButton_Click($Button1) ;会看到按钮被按下
;ControlClick("Form1", "", "Button1", "left") ;按钮得到焦点
GUICtrlSetData($Edit1, "不想用ControlClick&_GUICtrlButton_Click")
ControlFocus($Form1, "", $Edit1)
EndFunc ;==>_SendM
|