Jump to content
Sign in to follow this  
henryp

Capturing Menu Drop down tabs

Recommended Posts

henryp

I want to capture every tab's name under a file menu.

So when i click on file, i want to store into an array/string "New", "Edit", and "Print".

How is this possible? When i click File Menu and try to use the Window Info Target, the focus changes and the filemenu disappears.

Share this post


Link to post
Share on other sites
PsaltyDS

I want to capture every tab's name under a file menu.

So when i click on file, i want to store into an array/string "New", "Edit", and "Print".

How is this possible? When i click File Menu and try to use the Window Info Target, the focus changes and the filemenu disappears.

This demo gets the text from all the 'File' menu options of Notepad:
#include <GuiMenu.au3>

$iPID = Run("notepad.exe")
WinWait("Untitled - Notepad", "")
$hWin = WinGetHandle("Untitled - Notepad", "")
ConsoleWrite("Debug:  $hWin = " & $hWin & @LF)
$hMenu = _GUICtrlMenu_GetMenu($hWin)
ConsoleWrite("Debug:  $hMenu = " & $hMenu & @LF)
$iCnt = _GUICtrlMenu_GetItemCount($hMenu)
ConsoleWrite("Debug:  $iCnt = " & $iCnt & @LF)
$iFile = _GUICtrlMenu_FindItem($hMenu, "File")
ConsoleWrite("Debug:  $iFile = " & $iFile & @LF)
$hFile = _GUICtrlMenu_GetItemSubMenu($hMenu, $iFile)
ConsoleWrite("Debug:  $hFile = " & $hFile & @LF)
$iFileCnt = _GUICtrlMenu_GetItemCount($hFile)
ConsoleWrite("Debug:  $iFileCnt = " & $iFileCnt & @LF)
For $n = 0 To $iFileCnt - 1
    $sText = _GUICtrlMenu_GetItemText($hFile, $n)
    ConsoleWrite(@TAB & "Item: " & $n & " = " & $sText & @LF)
Next

ProcessClose($iPID)

:)


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

Share this post


Link to post
Share on other sites
henryp

Thanks for the reply =O).

However, i got 1 more question. Is AutoIt able to get submenus within the menu? I looked through the CtrlMenu and couldnt find it, but maybe there is a way?

I want to save the list under "Recently Opened" Menu list

File:

Open

Save

Exit

Recently Opened =>Doc1.text, Test.txt, Supply.txt

Edited by henryp

Share this post


Link to post
Share on other sites
Authenticity

#include <GUIMenu.au3>

Global $hWnd = WinGetHandle('[CLASS:SciTEWindow]')
Global $hMenu = _GUICtrlMenu_GetItemSubMenu(_GUICtrlMenu_GetMenu($hWnd), 0)

For $i = 0 To _GUICtrlMenu_GetItemCount($hMenu)-1
    Local $hSubMenu
    
    ConsoleWrite(_GUICtrlMenu_GetItemText($hMenu, $i) & @LF)
    $hSubMenu = _GUICtrlMenu_GetItemSubMenu($hMenu, $i)
    
    If $hSubMenu Then
        For $j = 0 To _GUICtrlMenu_GetItemCount($hSubMenu)-1
            ConsoleWrite(@TAB & _GUICtrlMenu_GetItemText($hSubMenu, $j) & @LF)
        Next
    EndIf
Next

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.