Screen scraping at text cursor position vs. mouse position

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Dick99999
Pro Scripter
Posts: 84
Joined: Thu Nov 27, 2008 10:25 am
Location: Netherlands

Screen scraping at text cursor position vs. mouse position

Post by Dick99999 » Sun Jun 23, 2013 1:13 pm

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?

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jun 24, 2013 5:49 pm

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>

Dick99999
Pro Scripter
Posts: 84
Joined: Thu Nov 27, 2008 10:25 am
Location: Netherlands

Post by Dick99999 » Thu Jun 27, 2013 7:00 am

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

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts