PostMessage

Hello I have problem,one in which I was using SendInput somehow managed to block that,soo I cant use SendInput ,soo I was looking for another way to "input" mouse click in game .
I decided to use PostMessage .
Problem comes when I need to find a specific window ,which I dont wanna to ,I wanna to be able to use it also in other apps.
1
2
3
4
5
		POINT p;
		GetCursorPos(&p);
		LPARAM lParam = MAKELPARAM(p.x, p.y);
		PostMessage(?,WM_LBUTTONDOWN, MK_LBUTTON, lParam);
		PostMessage(?,WM_LBUTTONUP, 0, lParam);


Also I tired using GetForegroundWindow() function but it doesnt let me click in Chrome.
Soo is there way to make it click without fiding specific window.
Last edited on
Since no one is answering this I’ll give it a go. Frankly, though, you have not given me much to work on.

The SendInput() function uses PostMessage() (or equivalent) behind the scenes. You aren’t going to get around the problem that way.

The SendInput documentation|https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-sendinput makes it clear the primary reasons this function may fail are:

  • UIPI — your process has lower privilege than the process you are trying to manipulate, or

  • another thread (possibly not of your process?) has interfered with it.

Whatever the case, SendInput() has never been the most reliable way to manipulate another process.


If you want to automate other processes, try something like Expect|https://core.tcl.tk/expect/index or AutoIt|https://www.autoit.com/. Both of these have a lot of code specialized to handle situations far and beyond what SendInput() can do.

Hope this helps.
Topic archived. No new replies allowed.