Adils Adils
Adils Adils

Reputation: 241

getting control names of another exe

Hello all i have a rather specific Question and please consider my apologies if this is not a standard stack-overflow question , i need to know is it possible to get all control names of another exe e.g.

i have a c# application and i want to get all control names of another standalone application running on my computer say b.exe so if b.exe have a textbox and a button in it i want to have names of textbox and button in my c# exe and also i want to have a listener for click events of b.exe

till now whatever i have researched is nothing special actually i dont want full code snaps i just want a guideline can i do it thorugh pinvoke? or winapi? please explain what is pinvoke and winapi and is it possible through application hooking ? once again i need a guideline a way to follow so please help me out regarding this, i know i can get active windows name through pinvoke or winapi but my requirements are little high

Upvotes: 0

Views: 2360

Answers (1)

Martin Rosenau
Martin Rosenau

Reputation: 18503

1 . Access to control names:

Unfortunately I do not .NET (C#) but under Visual C++ this would be impossible.

The reason is: The controls do not have names in the executable any longer but the names are simply converted to numbers.

Example "myTextControl" would be 1234 in the executable. The information about the (original) name of the control gets completely lost while compiling.

2 . Accessing controls in other executables:

I think under .NET (C#) it is not as easy as under native programming languages (directly accessing the Windows API) but it is possible to access controls of other executables as long as you know the number (e.g. 1234).

Therefore you'll have to find out the window handle of the dialog window containing the control and then you can send messages to the control. Unfortunately many messages containing pointers will require some very tricky hacks. Messages without pointer work well.

3 . Creating a listener for a control in other executables:

Creating a listener (e.g. a click listener) on a control in another EXE is possible however very tricky: This would require writing a native (this means: not .NET / C#) DLL file which is then combined with the Windows API function "SetWindowsHookEx".

I do not think that a .NET API (required for C#) already exists that will do this because there are only few use cases for this.

Upvotes: 2

Related Questions