'Setting mouse position?
Well I'm working on a small program and I'm trying to set the position of the window's mouse to it's center every time it moves. Thing is I have no idea how to make this work. I had the following code:
auto point = new Point(300.0, 200.0);
//auto ends up being Windows::Foundation::Point;
But I could still move the mouse freely all over the screen...
So then I searched the internet a bit and used:
Windows::UI::Input::PointerPoint point = Point(300.0, 200.0);//1
//and//
auto point = Windows::UI::Xaml::PointHelper::FromCoordinates(300.0, 200.0);//2
And example one wouldn't compile. Example 2 did compile but I could still move the mouse acrros the whole screen.
Don't know if it's important but I'm coding in C++, using DirectX for graphics and XAML for Text. (I'm also using the base class as C++/CX to work with XAML).
Solution 1:[1]
Try using SetCursorPos(), it should work on Windows.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Iosif Murariu |