GetMouseMovePointsEx()

Nov 29, 2015 at 1:21am
Yo guys!

I am trying to make a program which blocks the movement of the mouse, so the person can't move his mouse.
I could get the resolution of the window(I want the cursor to be set to the middle of the desktop/window), but I am stuck with the function, called GetMouseMovePointsEx().
And my 2nd question would be that why do I need to use reference at the GetWindowRect()'s second paramater?I dont really get that
Any help would be nice , thank you!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
  #include <iostream>
#include <Windows.h>


using namespace std;

void BlockMouseMovement()//Block the mouse movement
{
	MOUSEMOVEPOINT mmp;

	if (GetMouseMovePointsEx(sizeof(mmp), &mmp, &mmp, 2, 1) >= 0)
	{
		cout << "cool";
	}
	else
	{
		cout << "shit";
	}
}

int WindowX()//Get the window's X resolution
{
	RECT desktop_rect_;// RECT struct {LONG left; LONG right; LONG top; LONG bottom;} || needed for the GetWindowRect()
	HWND desktop_ = GetDesktopWindow();//Handle to the desktop
	GetWindowRect(desktop_, &desktop_rect_);// Gets the RECT struct's four members ( left, right, top, bottom) 
	return desktop_rect_.right;//Return with the window's X resolution
}

int WindowY()//Get the window's Y resolution
{
	RECT desktop_rect_;// RECT struct { LONG left; LONG right; LONG top; LONG bottom; } || needed for the GetWindowRect()
	HWND desktop_ = GetDesktopWindow();//Handle to the desktop
	GetWindowRect(desktop_, &desktop_rect_);// Gets the RECT struct's four members ( left, right, top, bottom) 
	return desktop_rect_.bottom;//Return with the window's Y resolution
}

int main()
{
	cout << WindowX() << " " << WindowY() << endl;
	BlockMouseMovement();
	system("PAUSE");

	return 0;
}
Last edited on Nov 29, 2015 at 1:24am
Nov 29, 2015 at 12:32pm
And my 2nd question would be that why do I need to use reference at the GetWindowRect()'s second paramater?
GetWindowRect takes a pointer as it's second parameter, not a reference, and you're supplying a pointer... not a reference.

I didn't see any first question.
Nov 29, 2015 at 2:45pm
How to use GetMouseMovePointsEx(), because it has got some problem, I think I gave bad paramters or something like that

When I put the * before the mmp like this: *mmp, it had error with it....
http://postimg.org/image/x4677y56t/
Last edited on Nov 29, 2015 at 2:50pm
Nov 29, 2015 at 6:59pm
kocka wrote:
I think I gave bad paramters or something like that

Yes, you did. Referring to the documentation is recommended.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms646259%28v=vs.85%29.aspx
docs wrote:
lppt [in]

Type: LPMOUSEMOVEPOINT

A pointer to a MOUSEMOVEPOINT structure containing valid mouse coordinates (in screen coordinates).


kocka wrote:
When I put the * before the mmp like this: *mmp, it had error with it...

As expected. mmp is not a pointer.
Nov 29, 2015 at 7:07pm
What should I do? I still don't get it ...
Nov 29, 2015 at 10:39pm
Just found this code
1
2
3
4
MOUSEMOVEPOINT mp_in;
MOUSEMOVEPOINT mp_out[64];

GetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &mp_in, mp_out, 64, GMMP_USE_DISPLAY_POINTS);


But still doesnt work. And I do not even really get why is there an "address of" operator...
Nov 29, 2015 at 10:47pm
I would, again, refer you to the documentation. mp_in must contain valid mouse coordinates.

I would strongly suggest you review the documentation and understand it before you go around "finding stuff" and applying it indiscriminately in your quest to stumble onto something that works.

And perhaps search out a tutorial on pointers, since you don't seem to know what they are or why they might be used.
Nov 29, 2015 at 11:03pm
Ok, I found an easier way....Will take a look at the GetMouseMovePointsEx(), but not nowadays.....

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <Windows.h>


using namespace std;
void BlockMouseMovement();//Block the mouse movement


int WindowX()//Get the window's X resolution
{
	RECT desktop_rect_;// RECT struct {LONG left; LONG right; LONG top; LONG bottom;} || needed for the GetWindowRect()
	HWND desktop_ = GetDesktopWindow();//Handle to the desktop
	GetWindowRect(desktop_, &desktop_rect_);// Gets the RECT struct's four members ( left, right, top, bottom) ||Miért referencia?
	return desktop_rect_.right;//Return with the window's X resolution
}

int WindowY()//Get the window's Y resolution
{
	RECT desktop_rect_;// RECT struct { LONG left; LONG right; LONG top; LONG bottom; } || needed for the GetWindowRect()
	HWND desktop_ = GetDesktopWindow();//Handle to the desktop
	GetWindowRect(desktop_, &desktop_rect_);// Gets the RECT struct's four members ( left, right, top, bottom) ||Miért referencia?
	return desktop_rect_.bottom;//Return with the window's Y resolution
}

void BlockMouseMovement()
{
	while (true)
	{
		SetCursorPos(WindowX() / 2, WindowY() / 2);
	}
}

int main()
{
	cout << WindowX() << " " << WindowY() << endl;
	BlockMouseMovement();
	system("PAUSE");

	return 0;
}
Topic archived. No new replies allowed.