找回密码
 加入
搜索
查看: 3496|回复: 10

[GUI管理] [已解决]请教快捷键的问题(我自己思路错误,放弃。再次感谢!)

  [复制链接]
发表于 2010-7-2 10:03:25 | 显示全部楼层 |阅读模式
本帖最后由 ferelove 于 2010-7-2 11:56 编辑

$Button1 = GUICtrlCreateButton("按钮&A", 136, 72, 75, 25)
如上,加个&A,该按键即有Alt+A的快捷键,并且在按键上有个带有下划线的A显示。挺好用的,
如果快捷键是Ctrl+A呢?不知道怎么弄了?请教各位。谢谢!

好像用以下方法虽然也可以设置为Ctrl+A,但按钮上不会显示带下划线的A,界面不直观。
Dim $Form1_AccelTable[1][2] = [["^a", $Button1]]
GUISetAccelerators($Form1_AccelTable)

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-7-2 10:08:32 | 显示全部楼层
"&A"的意思是把"A"设置为快捷键,如果当前focus在此button上,点A就相当于按了此button
Alt+A是windows自带的功能,即focus不在此button上,点Alt+A也能生效

评分

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

查看全部评分

 楼主| 发表于 2010-7-2 10:13:25 | 显示全部楼层
本帖最后由 ferelove 于 2010-7-2 10:16 编辑

谢谢楼上。
我的意思是想设置为Ctrl+某。该如何写呢?譬如设置该按钮的快捷键为Ctrl+1,并且在按键上有显示带下划线的1

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2010-7-2 10:22:14 | 显示全部楼层
回复 3# ferelove


    #include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 206, 155, 242, 173)
$Button1 = GUICtrlCreateButton("Button1&a", 40, 40, 75, 25)
$Button2 = GUICtrlCreateButton("Button2&B", 40, 88, 75, 25)
Dim $Form1_AccelTable[2][2] = [["^a", $Button1],["^b", $Button2]]
GUISetAccelerators($Form1_AccelTable)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        MsgBox(0,"","你按了BUTTON1")
                Case $Button2
                        MsgBox(0,"","你按了BUTTON2")
        EndSwitch
WEnd
 楼主| 发表于 2010-7-2 10:33:07 | 显示全部楼层
谢谢4楼,可能是我表达不清楚。仍没达到要求。
4楼代码,一个按钮同时有了Ctrl+A和Alt+A快捷键。重复了。
再表达一下吧,譬如:
BUTTON1的快捷键是Alt+1
BUTTON2的快捷键是Ctrl+1
各按钮的快捷键不重复,并有带下划线显示。
发表于 2010-7-2 10:50:58 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 206, 155, 242, 173)
$Button1 = GUICtrlCreateButton("Button1&k", 40, 40, 75, 25)
$Button2 = GUICtrlCreateButton("Button2&1", 40, 88, 75, 25)
Dim $Form1_AccelTable[2][2] = [["!1", $Button1],["^1", $Button2]]
GUISetAccelerators($Form1_AccelTable)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        MsgBox(0,"","你按了BUTTON1")
                Case $Button2
                        MsgBox(0,"","你按了BUTTON2")
        EndSwitch
WEnd

评分

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

查看全部评分

 楼主| 发表于 2010-7-2 11:08:34 | 显示全部楼层
谢谢410521a !
当2个都要求为1时(只是其中一个按钮为Ctrl+1,另外一个按钮为Alt+1,并非是K等等其它字符)。
纯粹是偶想法错误。放弃。
再次感谢各位朋友!
发表于 2010-7-2 11:08:48 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 206, 155, 242, 173)
$Button1 = GUICtrlCreateButton("第一个&1", 40, 40, 75, 25)
$Button2 = GUICtrlCreateButton("第二个&1", 40, 88, 75, 25)

Opt("GUIOnEventMode", 1)
GUISetOnEvent($GUI_EVENT_CLOSE, "exitt")
HotKeySet("^1", "Button1")
GUICtrlSetOnEvent($Button2, "Button2")

GUISetState(@SW_SHOW)
While 1
sleep(1)
WEnd

Func exitt()
exit
EndFunc

Func Button1()
msgbox(0,"","CTRL + 1第一个按钮")
EndFunc

Func Button2()
msgbox(0,"","ALT + 1 第二个按钮")
EndFunc

评分

参与人数 1威望 +2 金钱 +40 收起 理由
afan + 2 + 40

查看全部评分

发表于 2010-7-2 13:05:59 | 显示全部楼层
本帖最后由 afan 于 2010-7-2 13:07 编辑

LS的例子可以达到LZ的要求~ 整理下~
Opt("GUIOnEventMode", 1)
HotKeySet("^1", "Button1")

GUICreate("Form1", 206, 155)
GUISetOnEvent(-3, "_exit")
$Button1 = GUICtrlCreateButton("(ctrl-1)第1个&1", 40, 40, 110, 25)
GUICtrlSetOnEvent($Button1, "Button1")
$Button2 = GUICtrlCreateButton("(alt-1)第2个&1", 40, 88, 110, 25)
GUICtrlSetOnEvent($Button2, "Button2")
GUISetState()

While 1
        Sleep(1)
WEnd

Func _exit()
        Exit
EndFunc   ;==>_exit

Func Button1()
        MsgBox(0, "", "CTRL+1 第1个按钮")
EndFunc   ;==>Button1

Func Button2()
        MsgBox(0, "", "ALT+1 第2个按钮")
EndFunc   ;==>Button2
发表于 2010-7-4 03:28:07 | 显示全部楼层
有道理的就呀顶!


















日本アニメ
发表于 2010-12-2 17:49:33 | 显示全部楼层
学习了 帮你
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-11 12:38 , Processed in 0.097548 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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