在 Windows 中读取当前鼠标坐标 [英] Read current mouse coordinates in Windows
本文介绍了在 Windows 中读取当前鼠标坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用C++读取鼠标在windows中的当前位置?
我想从鼠标访问原始数据并显示坐标.
How does one read the current position of mouse in windows using C++ ?
I want to access the the raw data from mouse and display the coordinates.
推荐答案
使用 Windows API,您可以 GetCursorPos().我现在无法编译代码来测试它,但它应该是这样的:
Using the Windows API, you could GetCursorPos(). I can't compile the code right now to test it, but it should work out something like this:
POINT cursor;
if (GetCursorPos(&cursor)) {
// Print out cursor.x and cursor.y
}
我确定你已经这样做了,但一定要包含 windows.h
.
I'm sure you've done this, but be sure to include windows.h
.
这篇关于在 Windows 中读取当前鼠标坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文