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!
#include <iostream>
#include <Windows.h>
usingnamespace 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;
}
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.
#include <iostream>
#include <Windows.h>
usingnamespace 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;
}