Archived

This topic is now archived and is closed to further replies.

Chaucer

C#, C++ MFC

Recommended Posts

Hey, I want to write an application that will be controlling another application on my system. Say, like if I push button1 on this app, it will press 3 buttons on app2 that is already running. Can this be done using c++ or c#? Any pointers on how to go about this? I find that c# is alot easier than mfc for creating gui apps. I don't know much about c# yet but can I also use this along with a custom dll? Like could I create a dll in c++ and make use of it in c#? [edited by - Chaucer on November 7, 2002 6:18:25 PM]

Share this post


Link to post
Share on other sites
Yes you can call a c++ dll from C# but as far as I know unless you make it a managed dll you have to use the interop methods in order to call the methods of native dll''s

As for pressing buttons on a different app.... Good luck :D I have no idea how this can be done unless you somehow make the message que think it was sent a message that the app didn''t send. If you are going to do an app like this stick to the language you know best to do this. It will probably be complicated, and screwing up because you don''t know the proper syntax or somthing like that won''t be fun

Share this post


Link to post
Share on other sites
Thanks for your reply.

I would think that it can''t be done without just doing some sort of key press sequence except that I remember a friend doing something like this with one of AOL''s timeout messages several years ago. He would somehow get the timeout message and press the OK button when it came up WITHOUT having the program just press tab, enter or something.

Share this post


Link to post
Share on other sites
You can use FindWindow to get the HWND of the app you want to control, and use FindWindow again to get the HWND of the buttons (or using Spy++), and SendMessage, I think, will do the job.

I think both C++ and C# can do the job. C++ definitely can, I know VB can do this, so can C#. Anyway, why would you want to make it in a DLL? It's just gonna complicate things. And you know that is not good for the first try.


My compiler generates one error message: "does not compile."

EDIT: Oh wait, I don't know if using FindWindow to get the button's HWND is a good way...

[edited by - nicho_tedja on November 7, 2002 10:15:02 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Chaucer
Hey,
I want to write an application that will be controlling another application on my system. Say, like if I push button1 on this app, it will press 3 buttons on app2 that is already running.

Can this be done using c++ or c#? Any pointers on how to go about this? I find that c# is alot easier than mfc for creating gui apps.

I don''t know much about c# yet but can I also use this along with a custom dll? Like could I create a dll in c++ and make use of it in c#?

<SPAN CLASS=editedby>[edited by - Chaucer on November 7, 2002 6:18:25 PM]</SPAN>


If you want to press 3 buttons on a third-party application, then FindWindow and sending window messages would be the best solution. However, if you are writing the other app yourself, you might instead want to consider communicating through a socket or named pipe (I''m not completely sure about the later because I don''t have any experience with named pipes).

Share this post


Link to post
Share on other sites
quote:
...you might instead want to consider communicating through a socket or named pipe

Do named pipes even exist on Windows? Forgive my ignorance...

Share this post


Link to post
Share on other sites