找回密码
 加入
搜索
查看: 2644|回复: 4

[GUI管理] 下拉菜单空间选中状态如何获取呢[已解决]

[复制链接]
发表于 2017-6-14 10:56:32 | 显示全部楼层 |阅读模式
本帖最后由 heroxianf 于 2017-6-14 11:48 编辑

我想获取$item1空间的 选中状态,请问用什么函数呢?

#include <GuiButton.au3>

GUICreate("AU3",300,200)
$Label1 = GUICtrlCreateLabel("右键菜单", 18, 160, 70, 15)
GUICtrlSetColor($Label1,0xff0000)
$context = GUICtrlCreateContextMenu($Label1)
$item1 = GUICtrlCreateMenuItem('菜单1', $context)
$item2 = GUICtrlCreateMenuItem('菜单2', $context)
GUISetState(@SW_SHOW)

While 1
        $msg = GUIGetMsg()
        Switch $msg
                Case -3
                        Exit
                Case $item1
                        GUICtrlSetState($item1, 1)
                Case $item2
                       Local $tt = _GUICtrlButton_GetState($item1)
                                           MsgBox(0, "", $tt)
        EndSwitch
WEnd
 楼主| 发表于 2017-6-14 11:02:26 | 显示全部楼层
采用TrayItemGetState函数不管选没选中得到的都是 1
#include <GuiButton.au3>
#include <TrayConstants.au3>

GUICreate("AU3",300,200)
$Label1 = GUICtrlCreateLabel("右键菜单", 18, 160, 70, 15)
GUICtrlSetColor($Label1,0xff0000)
$context = GUICtrlCreateContextMenu($Label1)
$item1 = GUICtrlCreateMenuItem('菜单1', $context)
$item2 = GUICtrlCreateMenuItem('菜单2', $context)
GUISetState(@SW_SHOW)

While 1
        $msg = GUIGetMsg()
        Switch $msg
                Case -3
                        Exit
                Case $item1
                        GUICtrlSetState($item1, 1)
                Case $item2
                       Local $tt = TrayItemGetState($item1)
                                           MsgBox(0, "", $tt)
        EndSwitch
WEnd
发表于 2017-6-14 11:25:05 | 显示全部楼层
Local $tt = GUICtrlRead($item1) - 64
 楼主| 发表于 2017-6-14 11:48:38 | 显示全部楼层
回复 3# afan


    A大这个好啊,  我还在想判断 65 和 68  的问题   减一下就好了。
发表于 2018-4-12 19:39:53 | 显示全部楼层
这是有源码情况下获取菜单状态,请问大神们知道其他程序的菜单如何操作,在自定义UDF 关于菜单的操作都不起作用,,,
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-3-29 13:13 , Processed in 0.077599 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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