Jump to content

Automating pulldown menus & AutoIt v3 Window Info


Michiel
 Share

Recommended Posts

AutoIt v3 Window Info seems unable to provide (handle or otherwise) information about pulldown menus. Should pulldown menus always be automated using keyboard shortcuts? What if a menu option has no keyboard shortcut? Also, it seems AU3Recorder doesn't provide any code when I try to use it either for pulldown menus or anything else, really. ;)

More or less related to this post:

'?do=embed' frameborder='0' data-embedContent>>

Edited by Michiel
Link to comment
Share on other sites

In my experience, some controls just don't provide access so you can read them with the Window Info Tool or allow interaction.

I suspect it has to do with the type of control, and what program was used to create it, and maybe the programmer?

Sometimes, you can just send text matching a menu item name, but more usually it revolves around the dicey use of ALT, TAB etc.

A couple of my favorite programs give me issues like that, with some of their elements - foobar2000 & TagScanner.

This issue, is the main reason I've never made my Foobar Ipod Assistant program available for download ... too inherently dangerous for those not as careful or clued in as me.

No doubt someone here, knows more about it than me. I'm not conversant enough with other programming languages and that technical side of things.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

It should be possible to get the menu handle in this way:

 

#include <GuiMenu.au3>
#include <SendMessage.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
  ConsoleWrite( "5 seconds to open a menu ..." & @CRLF )
  Sleep( 5000 ) ; 5 seconds to open a menu
  Local $hMenu = GetMenuHandle()
  If Not $hMenu Then Return
  Local $iCount = _GUICtrlMenu_GetItemCount( $hMenu ), $sText
  For $i = 0 To $iCount - 1
    $sText = _GUICtrlMenu_GetItemText( $hMenu, $i )
    If $sText <> "" Then ConsoleWrite( $sText & @CRLF )
  Next
EndFunc

Func GetMenuHandle()
  Local $hDesktop = _WinAPI_GetDesktopWindow(), $i = 0
  Local $hChild = _WinAPI_GetWindow( $hDesktop, $GW_CHILD )
  While $hChild And $i < 3
    If _WinAPI_GetClassName( $hChild ) = "#32768" Then ExitLoop
    $hChild = _WinAPI_GetWindow( $hChild, $GW_HWNDNEXT )
    $i += 1
  WEnd
  If $i = 3 Then Return 0
  Local $hMenu = _SendMessage( $hChild, $MN_GETHMENU )
  If $hMenu > 0 Then Return $hMenu
  Return 0
EndFunc

The example prints menu item texts to Scite console.

Link to comment
Share on other sites

This may be useful, too:

MSDN - "Inspect"
 

 

Inspect (Inspect.exe) is a Windows-based tool that enables you select any UI element and view the element's accessibility data. You can view Microsoft UI Automation properties and control patterns, as well as Microsoft Active Accessibility properties. Inspect also enables you to test the navigational structure of the automation elements in the UI Automation tree, and the accessible objects in the Microsoft Active Accessibility hierarchy.

Inspect is installed with the Windows Software Development Kit (SDK) for Windows 8. (It is also available in previous versions of Windows SDK.) It is located in the bin<platform> folder of the SDK installation path (Inspect.exe).

Link to comment
Share on other sites

not sure what you mean by notepad is an MSAA provider (although it is) but menuitems in notepad are just reachable by their hwnd and normal AutoIT commands you do not neccesarily have to use IUIAutomation for notepad it just as good can be handled with AutoIT native functions

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...