John Kelly

John Kelly

  • NA
  • 9
  • 0

Unmanaged code, sending text to another program

Oct 19 2007 3:55 PM
Good afternoon,
After banging away for a couple of days, I'm turning to this forum for some hints.  I'm trying control a program my company has for which we have no sources, only an exe.  Specifically, I'm trying to click buttons and make values appear in text boxes.  The compiled app looks like it's written in C++, has that MFC look about it.

I've been able to get the button clicking part working, lots of Win32 API 'FindWindow(...)', 'FindWindowEx(...)', 'SendMessage(..., BM_CLICK,...)' stuff.  Wotta hack!

My issue is specifically with setting the contents of a textbox.  I can get the window handle of the textbox, but using 'SetWindowText(handle, "Test string")' results in nothing appearing in the TB.  I can change the title of the parent form that's hosting the textbox, so at least I know I'm communicating.

I tried 'SendMessage( handle, WM_COPYDATA, 2, <couldn't figure out how to put a string here>)'.

I set a trap on the textbox Text_Changed event (did I mention I built a little test suite to figure this out, so I can instrument the target program, something I can't do with the compiled exe) but I get no event.

I'd be glad to supply any additional info that might be useful, and many thanks for any advice you can offer.

Regards,
JJ

Answers (7)