D
D
druidus2017-02-14 00:15:27
Programming
druidus, 2017-02-14 00:15:27

C# How to move the mouse in a window in multithreaded mode?

C# Visual Studio.
There is a SetCursorPos() function from the user32.dll library, but it works fine only when the window is active and in one thread. If the window is not active, then the mouse does not move in this window. There is a task to move a mouse in a multithread specifying in what window it to move. To identify the window, of course, the title of the window is used. Please tell me how the task of moving the mouse in multithreaded mode is solved, when each thread has its own window, and without using the SetCursorPos () function?
If possible, then with a code example.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nrv, 2017-02-21
@nrv

Is the window your own or someone else's (trying to manage someone else's application)? If it’s your own, then there is such a moment that you can only do something with the window from the thread that created this window (or from the main thread of the application, I don’t remember already). Well, then you will have to somehow send a message (command) to that_thread_only_which_can_manage_the window, after receiving which it will do something with the window (for example, in order to make it active).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question