控制台基本操作

· · 个人记录

#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
HANDLE Out=GetStdHandle(STD_OUTPUT_HANDLE);
bool over=false;
void CursorControl()
{
    POINT p;
    HWND hWnd=GetForegroundWindow();
    int dex,dey;
    while(!over)
    {
        MoveWindow(hWnd,0,0,1920,1020,false);
        SetWindowPos(hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
        GetCursorPos(&p);
        dex=p.x-990;
        dey=540-p.y;
        system("cls");
        cout<<dex<<' '<<dey<<endl;
        SetCursorPos(990,540);
        Sleep(10);
    }
}
int main()
{
    srand(time(NULL));
    thread Control(CursorControl);
    Control.detach();
    while(getch()!='e')
    {

    }
    over=true;
    return 0;
}