Click here to Skip to main content
15,889,651 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey I have two questions.
1.How can I get the MousePosition coordinates for my screen?
2.How can I know what is the color at that pixel or location in rgb?
Posted
Updated 4-Nov-12 22:11pm
v2

Yeah, use functions GetCursorPos/GetPixel
 
Share this answer
 
you can use this API to get cursor information.
This API Retrieves information about the global cursor.

C++
BOOL WINAPI GetCursorInfo
(
    _Inout_  PCURSORINFO pci
);


Parameters
pci [in, out]
Type: PCURSORINFO
A pointer to a CURSORINFO structure that receives the information. Note that you must set the cbSize member to sizeof(CURSORINFO) before calling this function.

Return value
Type: BOOL
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

you can also use
C++
GetCursorPos

consider the example below.

C++
POINT cordinate;
GetCursorPos(&cordinate);
cout << "The mouse is at:" << cordinate.x << cordinate.y << endl;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900