Skip to Content
Jan 22, 2019 at 06:21 AM

c# GUI Api how do i get the element under the mouse position?


Restored question from @fborchez aka Federico Manuel Borchez Amigo, 2019/01/22

Hello SAP community :P
I'm researching some automation applications and for a simple recorder, i need to get the element id from SAP.

I'm using SAPFEWSELib and SapROTWr libraries and i can loop through elements, but i can't seem to get the element by position, and even worse, when looking for the okcd quick launch field, i find that the Left+ScreenLeft position doesn't match the actual left of the textfield, but somewhere in the middle (around 30 points), and the top is also off by 2 points.

Is there a way to get the actual bounding box on screen to get the element at a given position (x,y)?

Another way i think i could achieve this, is if there was a way to match the guicomponent to a windows automationelement, so i can get the automationelement from the screen and then match it to the sap guicomponent to get the id, but i couldn't figure out how to do this either.

Any help is appreciated.

Thanks in advance!