-2

I want to send enter command to another application via c# 4.0 win forms. How can i do that ? The commands will be sent inside vmware virtual pc win xp sp3

thank you

Furkan Gözükara
  • 22,964
  • 77
  • 205
  • 342
  • What is enter command? Do you want to start a new application? please define Enter command – Sandy Dec 05 '11 at 14:00
  • I assume he means he wants to send the "enter" keypress to a running application. –  Dec 05 '11 at 14:32
  • I really can not understand some people here. How can you not understand enter command. Enter command means sending enter key command. So doing same effect as pressing enter key. – Furkan Gözükara Dec 05 '11 at 19:41

2 Answers2

0

Perhaps ManagedSpy would provide the functionality you need for a WinForms app.

sfuqua
  • 5,797
  • 1
  • 32
  • 33
0

Your question was a little light on detail, so we might need more information to answer your question fully. For example, you mention that the program will be running in a virtual pc via VMWare. Does this mean that you wish the command to be sent to an application running on another PC? IF that is the case, you probably want to look at creating some sort of service, with a listener that intercepts messages via an IP port. There are lots of 3rd party tools and components that could help you there if you do a little research.

If you mean that you will have two apps running on the same system, perhaps you could use windows messaging.

In each of these cases, your app would then need to intercept some sort of message that your app would interpret as a keypress, either by triggering a component keypress in your app, or simply invoking your component's Onkeypress handler for the Enter Key.

I'd be able to provide a more detailed answer if I knew more about what it was you were specifically trying to do.

S.Robins
  • 703
  • 6
  • 6
  • they will be running on same os. both exe. currently i am able to send enter command. But after first enter command a popup appears like messagebox.show but at that confirm it fails. So my current way is not exactly same as keybaoard enter command. because on keyboard when i press enter it also works with that messagebox.show style confirm button – Furkan Gözükara Dec 06 '11 at 19:08
  • If you're trying to send an Enter Keypress to a built-in dialog box, then I would suggest replacing the dialog with your own so that you can control it's behavior more easily. If this is not an option (because you don't have the source code for example), then the only other thing that I can think of would be to somehow enumerate all of the window objects in the system, then drill down until you find the dialog box and the button you want to control, and then call it's keypress method. I'm not sure however if this will work with a DotNet application, and it's a very messy hack at best. – S.Robins Dec 06 '11 at 20:30
  • It just occurred to me that you might be trying to automate a test. If that is the case, there are testing tools you might use that will handle this sort of situation. If this is simply to provide a means to remotely control an application programmatically, then perhaps you may need to rethink your reasons for doing so, as there may be a better way to deal with the situation that has led you to want to do things in this way. :-) – S.Robins Dec 06 '11 at 20:37
  • i don't have any control of the other exe. The keyboard key press is working but my software send enter key is not working. So it is not exactly same. So i am not able to send enter key command as keyboard. How can i do that send enter command as keyboard ? – Furkan Gözükara Dec 07 '11 at 01:10