More or less familiar with WinApi, working with c #. Through WinSpector, I look at the data of windows, buttons, etc. It is necessary to right-click on a specific tray icon and then click on a specific item in the context menu that appears. The displayed items in the tray are determined by a single object of the ToolbarWindow32 class, but I don’t know how to access certain elements. It also interests how you can find out the data from the pop-up window (Baloon message).
1 answer
To click on the tray icon, you can use Automation.
For example, if hwnd for the tray icon is 65696, then we write
#r "UIAutomationTypes" #r "UIAutomationClient" using System.Windows.Automation; var a = AutomationElement.FromHandle((IntPtr) 65696); var p = a.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern; p.Invoke(); Menu items can be obtained using menuItems .
Hwnd is available from HWndSpy .
Example right click - see here .
- I am still a newcomer in this area and I have done very little. I often get the handle through Title or ClassName in the code itself. I take them, either from Winspector, or from my application, which performs almost the same functions as HWndSpy. How can I get the handle if the tray goes in one container (object?). menuitems works incorrectly for me, even with copy-paste (does not display anything). - Andrei Tsapenko
- Understood with menuitem, but only menu items are displayed there, and I need a context menu. Also, is it possible to get text from a pop-up message of a certain application? - Andrei Tsapenko
- "How can I get the handle of an icon if the tray goes in one container (object?)" - in HWndSpy there is a WindowFromPoint function. there is indicate the coordinates of the icon, then get hwnd - Stack
- @Andrey Tsapenko "Is it possible to get the text from the pop-up message of a certain application" is possible. It is necessary to intercept the creation of windows. this is done using automation events or global hooks. but it is not easy. - Stack
- "in HWndSpy there is a WindowFromPoint function" - I use this function, only, I repeat once again, the tray is one window with the ToolbarWindow32 class. And the pop-up window is tooltips_class32. How can I extract information from these windows? This is the question. To intercept this one, the problem is to get the text and coordinates of a particular icon. - Andrey Tsapenko
|