0

This isn't my area of programming, but I have one of my junior programmers working on a Windows application that needs to reference the UI elements of a Microsoft Office application, namely to get the coordinates of a button or menu item, such as the coordinates of the compose email button in Outlook or the edit menu item label frame in Excel, for example.

Specifically, is there a way of programatically obtaining the exact coordinates of a UI element from an Office application that is running with a visible window? Is there some kind of API Microsoft provides to programmers to allow determining object metrics.

So far, this is all I could find:

https://msdn.microsoft.com/en-
us/library/system.windows.controls.frame(v=vs.110).aspx

Thanks for any help!

jdeckman
  • 119
  • 10
  • In prior versions of Windows, UI elements are rendered as windows with a registered window type and ID. From that, you can get the metrics. I think the utility "Spy" is used to inspect the Windows UI elements and can give you that kind of detail. – theGleep Sep 28 '17 at 21:10
  • Here is a totally different StackExcange question that will probably give you a good boost in the right direction: https://stackoverflow.com/questions/1967604/how-can-i-get-functionality-similar-to-spy-in-my-c-sharp-app – theGleep Sep 28 '17 at 21:12
  • You're welcome...glad to help! – theGleep Sep 28 '17 at 21:17

1 Answers1

1

You can extract the coordinate in developer mode of where the mouse is. So by hovering over a button you can see where the coordinate is but any change in resolution or screen size will throw this off.

Many UI options have hotkeys. Have you thought about using those? e.g if you wanna code it to click on file, fire a "alt+f" event and it will

Turan
  • 302
  • 2
  • 9
  • Thanks, yeah he got that far, but really needs to coordinates within the code it self, while the program is running. For example, if an open window of say Outlook is running, his program will need to get the position of a UI object relative to the window it's in, if if the window is moved or resized later. – jdeckman Sep 28 '17 at 21:09