找回密码
 加入
搜索
查看: 3844|回复: 5

[AU3基础] [已解决]事件模式下,如何让快捷键与按钮的动作一样,但又不用ControlClick?

  [复制链接]
发表于 2010-8-13 05:40:30 | 显示全部楼层 |阅读模式
本帖最后由 雨林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
发表于 2010-8-13 11:17:19 | 显示全部楼层
                Case $Button1 ;注意这里代码会很长
                                                _SendM()
直接定义成同样的自定义函数不行么

评分

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

查看全部评分

 楼主| 发表于 2010-8-13 19:22:22 | 显示全部楼层
也行! 难道函数中除了发送Click到Btn ,就再没方法了吗?!

去看示例去!~~~
发表于 2010-8-14 15:00:03 | 显示全部楼层
思路有问题,搜索:激活窗口快捷键
 楼主| 发表于 2010-8-14 15:12:30 | 显示全部楼层
回复 4# ceoguang

谢谢你的回复! 俺已经放弃这个问题了~!
发表于 2010-12-2 17:39:02 | 显示全部楼层
想研究下 呵呵
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-26 11:56 , Processed in 0.092787 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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