BCW0928 Posted October 8, 2009 Posted October 8, 2009 Hey guys, I try to find topic of using AutoIt build in function to access Context Menu, but i was not successful. Does anyone knows how to access items in a pop up context menu Class:#32768. I want to check some items in the context menu to see if it is enabled to disabled I have some code are in the following: Local $hWnd = WinGetHandle("[CLASS:#32768]") If $hWnd <> "" Then Local $hContextMenu = "0x" & "Hex(_SendMessage($hWnd, $MF_GETHANDLE, 0, 0)); i don't know what is the value for $MF_GETHANDLE, does anyone know it? Does anyone know any other way to get the menu handle from a pop up context menu? Local $bDisabled = _GUICtrilMenu_GetItemDisabled($hContextMenu, "Export") Thank you
Authenticity Posted October 8, 2009 Posted October 8, 2009 (edited) Look at the included files. I've posted it somewhere in the general forum but I'm afraid it's now gibberish or not a readable content. If you want to know if the menu item is disabled or enabled when the popup menu is about the be visible then this is for you, otherwise you'll find it just as a minor reference... If you want to farther qualify the application or the thread that owns this popup window you can use ProcessExists() or _WinAPI_GetWindowThreadProcessId() or $iEvent variable to get greater details about the popup window at hand. PS, if you know how to write and install global dll hook procedure, WH_CBT for example, you can be notified about more general messages like WM_CONTENTMENU or WM_INITMENUPOPUP which are much preferred ways because this WinEventProc got a few problems with consistency.WinEventHook.au3WinEventHookTest.au3 Edited October 8, 2009 by Authenticity
EvgeniyEgiazarov Posted April 11, 2014 Posted April 11, 2014 (edited) These days $MF_GETHANDLE became $MN_GETHMENU found that on a german speaking forum (still same gibberish for me ) And now the legendary code looks like this (the popup must be shown to get it working!): #include <GuiMenu.au3> #include <WindowsConstants.au3> $hWnd = WinGetHandle("[CLASS:#32768]"); Part one of the magic - this is the classname for popups. $hMenu = "0x" & Hex(_SendMessage($hWnd, $MN_GETHMENU, 0, 0)); Part two of the magic ; where _SendMessage is found in Paul Campbell's Windows SDK ; library routines (A3LWinSDK.au3) $text = _GUICtrlMenu_GetItemText($hMenu, 0, $MF_BYPOSITION) MsgBox(4096,"", "Menu item text: " & $text) Edited April 11, 2014 by EvgeniyEgiazarov
Vitaliy4us Posted July 9, 2014 Posted July 9, 2014 Tried to use this approach for my context menu to get a text from it. But not successful. The script returns an empty string for each context menu item. From another hand, a new text could be setted for the each item, but it is not displayed in the menu. For example, result of the script shown below is: "This is a text of the item0 : Item0 " "This is a text of the item0 : Item1 " ..... and so on But the text of the items shown in console is not displayed in the menu. From another hand, new items could be added and are displayed successfully. Also all menu items are accessible by there first letters (the option could be called by sending the corresponding letter to the menu). For $i =0 To _GUICtrlMenu_GetItemCount($hMenu) - 1 _GUICtrlMenu_SetItemText($hMenu, $i, "Item" & $i) Next For $i = 0 to _GUICtrlMenu_GetItemCount($hMenu) - 1 $text = _GUICtrlMenu_GetItemText($hMenu, $i, $MF_BYPOSITION) ConsoleWrite("This is a text of the item " & $i & ": " & $text & @CRLF) Next
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now