S
S
Stratimon2016-01-24 11:14:46
C++ / C#
Stratimon, 2016-01-24 11:14:46

SendMessage how to send a click to the coordinates of an inactive window? Or find a replacement?

I've been digging forums for 3 days now, but I can't send a click on coordinates to an inactive window, for example, paint.
I tried a bunch of options and got completely confused!

HWND wnd1 = FindWindow(TEXT("MSPaintApp"),TEXT("Безымянный - Paint"));
//или
HWND wnd1 = FindWindow(NULL,"Безымянный - Paint");
//или
HWND wnd1 = FindWindow("MSPaintApp","Безымянный - Paint");
//или
HWND wnd1 = FindWindow("MSPaintApp",NULL);
//пробовал по разному 
SendMessage (wnd1, WM_LBUTTONDBLCLK, 0, MAKELPARAM(560, 425));
//тут тоже кучу вариантов испробовал

Well, not like he doesn’t want to click in paint, he also tried it with a calculator and other applications.
The maximum that I managed to click in the wow window and then provided that there was a mouse.
Actually please write a program that clicks on the coordinates in the inactive paint window.
And what other alternatives are there for clicking on an inactive window?
(Explanation is not required reading).
I will explain why I will open more than 3 game windows at once in which it is necessary to make simultaneous (desirable but not necessary) clicks on the same coordinates. For example, once every 30 seconds. in coordinates x=100 y=300.
Yes, you can make just an ordinary clicker that will switch between windows, but if there are 10-20+ windows, then it simply will not have time.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
AxisPod, 2016-01-24
@Sratimon

To begin with, I would advise you to look at what messages are flying to Spy ++ and hand over the same pack.

M
maaGames, 2016-01-24
@maaGames

FindWindow finds the handle of the application window and the click is sent to it, but it should be sent to the "view" window. Run spy (included with the studio) and copy the window handle with the canvas. Press the binoculars and drag the "sight" onto the canvas in an open paint - the window will be surrounded by a square. Then insert the descriptor into the code:

HWND wnd1 = (HWND)0x000704EC;

  ::SendMessage( wnd1, WM_LBUTTONDOWN, 0, MAKELPARAM( 100, 100 ) );
  ::SendMessage( wnd1, WM_LBUTTONUP, 0, MAKELPARAM( 100, 100 ) );

After that, you can try to get to the child window with which you want to interact from the application window handle. Also use spy to see if there are child windows in the game.

P
Peter, 2016-01-24
@petermzg

1. WM_LBUTTONDBLCLK is a double click.
a. And it may not be processed in the program, especially if the window does not have the CS_DBLCLKS flag
b. Many programs ignore it and determine themselves by the interval between receiving WM_LBUTTONDOWN. (GetDoubleClickTime)
2. FindWindow you get the main program window and send a message to its handler. And as a rule, the main window does not react to clicks in any way, the click is needed by child windows.
3. If you want to emulate a mouse click anywhere on the screen, then you need to use the mouse_event function (deprecated) or SendInput. Then the message from the mouse can enter the application's message queue and then correctly get to the child element, if there is one in the right place.

S
Stratimon, 2016-01-24
@Sratimon

AxisPod AxisPod thank you very much for the advice it helped a lot!
I implemented it like this Spy ++ ticked the mouse in the log
received data after the click, and as a result,
SendMessage (hidSL, WM_LBUTTONDOWN, 0x00000001, 0x0167027F);
SendMessage(hidSL, WM_LBUTTONUP, 0x00000000, 0x0167027F);
as I understand it, these are the coordinates 0x0167027F
0x00000001 what it is I have ideas but I'd better leave them to myself =)
maaGames maaGames
SendMessage( wnd1, WM_LBUTTONDOWN, 0, MAKELPARAM( 100, 100 ) ); it didn't work for me!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question