-
May 11th, 2010, 05:51 AM
#1
Capture mouse position
Hey. I am trying to capture the mouse position in a c++ command app, it's important that it's mousepos relative to the screen and not the command app itself. Here's some of my code:
Code:
#include <iostream>
#include <windows.h>
int main()
{
cout << "Please move your mouse to the pixel of your selection";
system("pause")
"Get mouse position on the screen (preferably which pixel it's at)"
cout << mousepos_pixel_x << " " << mousepos_pixel_y;
system("pause")
}
All help is appreciated!
-
May 11th, 2010, 06:00 AM
#2
Re: Capture mouse position
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
-
May 11th, 2010, 10:15 AM
#3
Re: Capture mouse position
Need to know what platform, it's different for all of them.
-
May 11th, 2010, 11:05 AM
#4
Re: Capture mouse position
Originally Posted by ninja9578
Need to know what platform, it's different for all of them.
I went by this.
Code:
#include <windows.h>
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman
-
May 11th, 2010, 11:59 AM
#5
Re: Capture mouse position
-
September 16th, 2020, 09:13 AM
#6
Re: Capture mouse position
Originally Posted by JohnW@Wessex
This one returns the coordinates of the screen.
how to convert these coordinates to window coordinates so that i can capture the mouse cursor location when moved on a CStatic control on a dialog box
-
September 16th, 2020, 11:28 AM
#7
Re: Capture mouse position
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|