Page 1 of 1

[C++] Really basic question - mousemove relatively

Posted: 15 Nov 2016, 18:21
by Brazolek123

Code: Select all

void dragDrop(HWND hWindow, POINT from, POINT to)
{
    POINT currentPos = getCurrentPos(hWindow);
    DWORD coordinates = MAKELPARAM(from.x, from.y);
    PostMessage(hWindow, WM_MOUSEMOVE, 0, coordinates);
    PostMessage(hWindow, WM_LBUTTONDOWN, MK_LBUTTON, coordinates);
	
	INT relX = from.x - 10;									// here starts the problem
	INT relY = from.y + 10;
    coordinates = MAKELPARAM(relX.x relY.y);
    PostMessage(hWindow, WM_MOUSEMOVE, 0, coordinates);              
    Sleep(1);												// end here it ends
    
    coordinates = MAKELPARAM(to.x, to.y);
    PostMessage(hWindow, WM_MOUSEMOVE, MK_LBUTTON, coordinates);
    PostMessage(hWindow, WM_LBUTTONUP, 0, coordinates);
    coordinates = MAKELPARAM(currentPos.x, currentPos.y);
    PostMessage(hWindow, WM_MOUSEMOVE, 0, coordinates);
}
Heey, its a really simple problem to solve, however I'm not so good in all this cpp variable types, so thought that maybe you will help me to modify it. All the marked part has to do is to movemouse relatively to 'from' position -10 to the right and + 10 pixels to up. Even looked through autohotkey source code but it is done a little bit different there, without all this makelparam things.
I need this because autohotkey's control click and mouse click drag doesnt work on my minimized window whereas this script written in c++ works perfectly. Thought I will be able to transform it somehow to dll file and then call it in my ahk script.

Thanks for help!

Re: [C++] Really basic question - mousemove relatively

Posted: 15 Nov 2016, 18:33
by guest3456
Brazolek123 wrote: I need this because autohotkey's control click and mouse click drag doesnt work on my minimized window whereas this script written in c++ works perfectly.
It obviously doesn't work perfectly heh :)

How do you even know this will work at all? I've never heard of being able to click minimized windows

And AHK has PostMessage so if it even is possible, there's no need for C++. You can do ControlClick U/D and then PostMessage the WM_MOUSEMOVE. Looks like Lexikos even posted an attempt here:
https://autohotkey.com/board/topic/4063 ... -dragging/

Re: [C++] Really basic question - mousemove relatively

Posted: 16 Nov 2016, 05:11
by Brazolek123
Well, Im playing one game with two different game clients. On one client all functions works properly controlclick and control-mouse click drag no matter if is on top or is maximized or minimized on c++ and ahk ver. Whereas while playing on second client, the one with a good bot protection only c++ ver works propely. But in this case I must to place this relative mouse movement so game client will be able to recognize object movement.

Re: [C++] Really basic question - mousemove relatively

Posted: 16 Nov 2016, 09:01
by guest3456
ahhh, maybe that second client is checking for ahk scripts running as part of its bot protection

Re: [C++] Really basic question - mousemove relatively

Posted: 16 Nov 2016, 12:11
by Brazolek123
fixed.