Question

I'm a learning c++, I want to know that how programs are made that can interact with other application in windows.By interaction I mean like clicking a button, giving keyboard input, changing settings of that application, changing options or even editing or creating files.How can I make such Programs in C++?

Was it helpful?

Solution

How you interact with other applications depends on your OS. If e.g your application runs on windows you have to use the Win32 API. The Win32 API are functions provided by the OS allowing you to interact not just with other applications but also with the OS itself, e.g to set up windows or to open files.

Win32 provides a messaging system. Every application has a message loop and accepts messages from the OS (e.g about mouse clicks) but can also receive messsages from other applications. The receiver cant decide whether the message comes from the OS or from another process.

To e.g change the title, you have to send the other application a WM_SETTEXT message using the SendMessage function.

Directly interacting with another application (changing its values, not just modifying the GUI) is just possible, if the application provides some kind of interface. These could be a network connection, named pipes, shared memory or some module/plugin loading mechanism (through dlls). Otherwise its not possible (easily).

For UNIX based OS an API called POSIX exists providing similiar functionality as Win32.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top