Jump to content

Sub Menu


Recommended Posts

Hello,

Brand new to AUTOIT. It is amazing!

I'm having trouble getting the state of a sub menu (fly out menu)

I'm using this code, but don't know what to do next.

$hWnd = WinGetHandle($Title)

$hMain = _GUICtrlMenu_GetMenu ($hWnd)

$hFile = _GUICtrlMenu_GetItemSubMenu ($hMain, 2)

Thought I could use:

_GUICtrlMenu_GetItemSubMenu ($hFile, 2)

this didn't work.

Posted Image

Thank you for your help

Cygnus

Cygnus

Link to comment
Share on other sites

Here is a example:

$Menu_2 = GUICtrlCreateMenu("Partner");menu
$Menu_2_Item_10a = GUICtrlCreateMenuItem("", $Menu_2);creates line divider between items
$Menu_2_Item_11 = GUICtrlCreateMenu("Enterprise Service Management", $Menu_2);menu item under partner. Is header for sub menu
$Menu_2_Item_12 = GUICtrlCreateMenuitem("Enterprise Service Management Home", $Menu_2_Item_11);item under sub menu

to get the state, use a msgbox while you click on it to see what the return is. Are you trying to automate a menu?

Edited by Volly
Link to comment
Share on other sites

Hey Volly,

Thanks for the reply. Yes, I'm trying to automate the menu. My goal is really to check the state of items on the menu to see if they are checked or not.

I got a message box to pop up but it wasn't very helpful.

MsgBox(0, "x", WinMenuSelectItem($SU_Title,"","&View", "Hidden Geometry"))

Anything else I should try?

Thanks.

Cygnus

Link to comment
Share on other sites

Hello,

Brand new to AUTOIT. It is amazing!

I'm having trouble getting the state of a sub menu (fly out menu)

I'm using this code, but don't know what to do next.

$hWnd = WinGetHandle($Title)

$hMain = _GUICtrlMenu_GetMenu ($hWnd)

$hFile = _GUICtrlMenu_GetItemSubMenu ($hMain, 2)

Thought I could use:

_GUICtrlMenu_GetItemSubMenu ($hFile, 2)

this didn't work.

This demo can be run in SciTE and will show you the entire process for finding the View|Status Bar menu item and reading its state:

#include <GuiMenu.au3>

Opt("WinTitleMatchMode", 4)

Global $iView = -1
$hWin = WinGetHandle("[CLASS:SciTEWindow]")
ConsoleWrite("Debug: $hWin = " & $hWin & @LF)
$hMenu = _GUICtrlMenu_GetMenu($hWin)
ConsoleWrite("Debug: $hMenu = " & $hMenu & @LF)
$iMenuItems = _GUICtrlMenu_GetItemCount($hMenu)
ConsoleWrite("Debug: $iMenuItems = " & $iMenuItems & @LF)
For $i = 0 To $iMenuItems - 1
    $sItemText = _GUICtrlMenu_GetItemText($hMenu, $i, True)
    ConsoleWrite("Debug: Item " & $i & ": " & $sItemText & @LF)
    If StringInStr($sItemText, "&View") Then
        $iView = $i
        ConsoleWrite("Debug: $iView = " & $iView & @LF)
    EndIf
Next
$hView = _GUICtrlMenu_GetItemSubMenu($hMenu, $iView)
ConsoleWrite("Debug: $hView = " & $hView & @LF)
$iViewItems = _GUICtrlMenu_GetItemCount($hView)
ConsoleWrite("Debug: $iViewItems = " & $iViewItems & @LF)
For $i = 0 To $iViewItems - 1
    $sItemText = _GUICtrlMenu_GetItemText($hView, $i, True)
    ConsoleWrite("Debug: Item " & $i & ": " & $sItemText & @LF)
    If StringInStr($sItemText, "&Status Bar") Then
        $iStatusBar = $i
        ConsoleWrite("Debug: $iStatusBar = " & $iStatusBar & @LF)
    EndIf
Next
$iStatusBarStatus = _GUICtrlMenu_GetItemState($hView, $iStatusBar, True)
ConsoleWrite("Debug: $iStatusBarStatus = " & $iStatusBarStatus & @LF)

Of course, all the ConsoleWrite()s are just to show how it works in the console.

Now, my dumb question is: How do you click an item? I see how to check one, or select a radio type item... but how do you click/select/activate a simple item like View|Toggle all folds? There is no _GuiCtrlMenu_ItemClick(), or _GuiCtrlMenu_ItemSelect().

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I still have not figure this one out. I can get the position, the text etc...of the sub menu but I need to get into the next fly out menu to check the state of those sub items.

I need to get the item names on the fly out menu.

Posted Image

Thank you

This demo can be run in SciTE and will show you the entire process for finding the View|Status Bar menu item and reading its state:

#include <GuiMenu.au3>

Opt("WinTitleMatchMode", 4)

Global $iView = -1
$hWin = WinGetHandle("[CLASS:SciTEWindow]")
ConsoleWrite("Debug: $hWin = " & $hWin & @LF)
$hMenu = _GUICtrlMenu_GetMenu($hWin)
ConsoleWrite("Debug: $hMenu = " & $hMenu & @LF)
$iMenuItems = _GUICtrlMenu_GetItemCount($hMenu)
ConsoleWrite("Debug: $iMenuItems = " & $iMenuItems & @LF)
For $i = 0 To $iMenuItems - 1
    $sItemText = _GUICtrlMenu_GetItemText($hMenu, $i, True)
    ConsoleWrite("Debug: Item " & $i & ": " & $sItemText & @LF)
    If StringInStr($sItemText, "&View") Then
        $iView = $i
        ConsoleWrite("Debug: $iView = " & $iView & @LF)
    EndIf
Next
$hView = _GUICtrlMenu_GetItemSubMenu($hMenu, $iView)
ConsoleWrite("Debug: $hView = " & $hView & @LF)
$iViewItems = _GUICtrlMenu_GetItemCount($hView)
ConsoleWrite("Debug: $iViewItems = " & $iViewItems & @LF)
For $i = 0 To $iViewItems - 1
    $sItemText = _GUICtrlMenu_GetItemText($hView, $i, True)
    ConsoleWrite("Debug: Item " & $i & ": " & $sItemText & @LF)
    If StringInStr($sItemText, "&Status Bar") Then
        $iStatusBar = $i
        ConsoleWrite("Debug: $iStatusBar = " & $iStatusBar & @LF)
    EndIf
Next
$iStatusBarStatus = _GUICtrlMenu_GetItemState($hView, $iStatusBar, True)
ConsoleWrite("Debug: $iStatusBarStatus = " & $iStatusBarStatus & @LF)

Of course, all the ConsoleWrite()s are just to show how it works in the console.

Now, my dumb question is: How do you click an item? I see how to check one, or select a radio type item... but how do you click/select/activate a simple item like View|Toggle all folds? There is no _GuiCtrlMenu_ItemClick(), or _GuiCtrlMenu_ItemSelect().

:)

Edited by CygnusX1

Cygnus

Link to comment
Share on other sites

I still have not figure this one out. I can get the position, the text etc...of the sub menu but I need to get into the next fly out menu to check the state of those sub items.

I need to get the item names on the fly out menu.

Posted Image

Thank you

Use the same process to get the handle of the 'Row' menu with _GuiCtrlMenu_GetItemSubMenu(), as I did to get the handle to 'View'. Then enumerate the items under 'Row' exactly as I did for 'View' in the demo. Note that the hotkey underline of the R in 'Row' means the text will be "&Row".

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Well after some mucking around I finally got what I was trying to do to work, sort of. However, I having one heck of a time getting the menu items to be "checked". I've come across a very odd thing. When I use

_GUICtrlMenu_SetItemChecked ($hSubMenu, 0)
and use ConsoleWrite to query the State of the menu item it returns it's checked. But when I manually click on the Menu > SubMenu it's not checked. Watch the video to see what I'm talking about.

What you are about to see is my script using

_GUICtrlMenu_SetItemChecked ($hSubMenu, 0)
to check the item, then I use MouseClick on the menu and slowly move my mouse down over the submenu I wanted to be checked. When my mouse goes over the submenu you'll see a check mark appear. When the mouse leaves and comes back the check mark is gone. Why is it doing that?

Watch my video

Anyone ever see this before?

Thank you

Cygnus

Use the same process to get the handle of the 'Row' menu with _GuiCtrlMenu_GetItemSubMenu(), as I did to get the handle to 'View'. Then enumerate the items under 'Row' exactly as I did for 'View' in the demo. Note that the hotkey underline of the R in 'Row' means the text will be "&Row".

:)

Cygnus

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...