2

I've an EXE for an application "MyWindow1" which launches a window which has few drop-down menus, few buttons etc..

I don't have the source code for this application "MyWindow1". What I've is just it's EXE & some of it's dependent DLLs which are required for it to launch it's window & do it's functionality.

Now I've another C++ module from which I'm launching this "MyWindow1" application automatically by using "CreateProcess() APIs" & ending it automatically by using "system(taskkill)".

But I even want to automate the drop-down menu selection, few button clicks for the buttons present in this "MyWindow1" application. Is there a way I can automate this even though I don't have the source code for this "MyWindow1" application (may be using MFC)

codeLover
  • 3,720
  • 10
  • 65
  • 121

3 Answers3

3

Use SendInput to simulate keystrokes and mouse movements. Simulating keystrokes is probably the most accurate way to automate menus.

Also, killing the process is not a very clean way to exit it. You can send WM_CLOSE to the main window, or continue automating keystrokes via SendInput to exit properly as a user would.

tenfour
  • 36,141
  • 15
  • 83
  • 142
  • Thank you. Since I don't have the source code for the "MyWindow1" application (which has the drop-down menus, buttons etc..), can you please help me with a sample source code snippet in C++ so as to how to achieve this automation of specific buttons clicks, selecting particular option in drop-down menu. – codeLover Sep 21 '14 at 16:06
1

It's probably easiest to use something like autohotkey ( http://www.autohotkey.com/ ) and generate the different autohotkey scripts with C++ to be run. Autohotkey also has a user contributed interop library for .Net according to wikipedia ( http://en.wikipedia.org/wiki/AutoHotkey ).

Twig
  • 621
  • 5
  • 17
  • Thank you. Since I don't have the source code for the "MyWindow1" application (which has the drop-down menus, buttons etc..), can you please help me with a sample source code snippet in C++ so as to how to achieve this automation of specific buttons clicks, selecting particular option in drop-down menu. – codeLover Sep 21 '14 at 16:06
0

I'd recommend pywinauto Python package. I use it for MFC applications on regular basis. You will find demo video on the author's web site.

Vasily Ryabov
  • 9,386
  • 6
  • 25
  • 78