bossman
bossman

Reputation: 421

Handle mouse event from another process

In my program I use class Process to start another application. This application starts fullscreen. My purpose is to handle mouse click from that application in my program. What WinApi functions should I use?

Upvotes: 0

Views: 488

Answers (1)

Timores
Timores

Reputation: 14589

By "WinApi", I assume that you mean "Win32".

In order to handle messages of another process, you need to install a Win32 hook. See this article for more details. You need the WH_MOUSE hook and the SetWindowsHookEx Win32 API.

A hook function needs to be in a DLL, so that it can be injected in any process. You will need to filter the messages you get for the process that you started.

A hook function needs to be a global function so you must code it in C++. You will also need to use some inter-process communication to well, communicate with your main program, if needed.

Upvotes: 2

Related Questions