The screen scraping at the mouse position works fine for me. I am now trying to feed a program running in the system tray.
Activating that program in the tray in this case results in a menu being displayed. The up and down and return keys select and execute the menu items. That all works fine.
However, I'd like to check whether right menu item is being executed by reading the text at the text cursor position, which is the text selected by the up/down keys. The mouse position does not change and might be somewhere.
I did some experimenting with trying to predict and calculate the mouse position from the text cursor, but my way seems not reliable.
Any way to for example to get the selected menu text at the text cursor position in stead of the mouse position? Or perhaps a reliable way to set the mouse position at the selected menu text cursor position?
Screen scraping at text cursor position vs. mouse position
Moderators: JRL, Dorian (MJT support)
Can you determine the name of the window that contains the menu? If you can do that you should then be able to get the coordinates of the window using its name and GetWindowPos. You should also be able to figure out the distance from the window origin to the menu item you want to check. Add those together and you should have the screen coordinates of he menu item. Once you have the screen coordinates you should be able to get the text using GetTextAtPoint>
Thanks. One of the problems was indeed finding the (class) name of the window, since it had no window name. In the notification area (system tray) all popup menus (appear when a tray icon is clicked) appear to have the same class name: #32768 and no window name.
Besides that, I chose to do a GetTextInRect to check the menu displayed. The complete script is published as a script example under Scripts and Tips
Besides that, I chose to do a GetTextInRect to check the menu displayed. The complete script is published as a script example under Scripts and Tips