0

I'm trying to click a button on a windows application from other application. Basically, I want to click app B's button from app A's code.

I can use winapi findWindow to get a handler. The problem is that I have no idea the name of the button on the app B. Is this possible to list all the names or ids of an application?

I'm using c# to make it happen.

Moon
  • 22,195
  • 68
  • 188
  • 269
  • @Arion // None so far. I tried to google, got nothing. I know that this question might not fit here since I don't have any source code, but...I have no idea how to approach this problem. Any suggestions would be appreciated.. – Moon Apr 14 '12 at 22:10

3 Answers3

2

Since you're looking at suggestions (it's a pretty generic question really, it might or might not work depending on what other app/window is, is it e.g. browser or a 3rd party app etc., does it support automation)

Take a look at this closely related answer (it might be a duplicate but you're kind of 'looking for' still so maybe note).

Accessing Elements from Other Processes

Also this one on how to 'access' other app's 'inputs'
Pinvoke SetFocus to a particular control

Community
  • 1
  • 1
NSGaga-mostly-inactive
  • 14,052
  • 3
  • 41
  • 51
2

I have not tested this. But it looks like a intressting libary. Maybe there is some function you can use. It is called White. This is just a sample:

Application application = Application.Launch("foo.exe");
Window window = application.GetWindow("bar", InitializeOption.NoCache);

Button button = window.Get<Button>("save");
button.Click();
Arion
  • 31,011
  • 10
  • 70
  • 88
1

You can use tool such as Spy++ (included in any Visual Studio except Express editions) to find name and class of that button and then use these information as parameters of FindWindow().

Ňuf
  • 6,027
  • 2
  • 23
  • 26