c 实时显示鼠标地址

最近在学习c,练习项目

#include <stdio.h>
#include<windows.h>

int main(int ac,char **pav)
{
    LONG x=-1, y=-1;
    POINT pt= {0,0};
        for(;;){              
        GetCursorPos(&pt);    //获取鼠标当前位置      
        if ((x!=pt.x) || (y!=pt.y)) //如果位置与之前的位置不一样则输出新位置
        {
            system("cls");
            printf("x=%d,y=%d\n",pt.x, pt.y);
            x=pt.x,y=pt.y;
        }	          
    }   
    return 0;
}
posted @ 2021-11-28 00:15  MuRKuo  阅读(33)  评论(0编辑  收藏  举报