winpty/misc/SelectAllTest.cc

41 lines
1.0 KiB
C++
Raw Normal View History

#define _WIN32_WINNT 0x0501
#include <stdio.h>
#include <windows.h>
const int SC_CONSOLE_MARK = 0xFFF2;
const int SC_CONSOLE_SELECT_ALL = 0xFFF5;
CALLBACK DWORD pausingThread(LPVOID dummy)
{
2012-04-01 08:40:30 +00:00
HWND hwnd = GetConsoleWindow();
while (true) {
SendMessage(hwnd, WM_SYSCOMMAND, SC_CONSOLE_SELECT_ALL, 0);
SendMessage(hwnd, WM_CHAR, 27, 0x00010001);
}
}
int main()
{
2012-04-01 08:40:30 +00:00
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO info;
2012-04-01 08:40:30 +00:00
GetConsoleScreenBufferInfo(out, &info);
COORD initial = info.dwCursorPosition;
2012-04-01 08:40:30 +00:00
CreateThread(NULL, 0,
pausingThread, NULL,
0, NULL);
2012-04-01 08:40:30 +00:00
while (true) {
GetConsoleScreenBufferInfo(out, &info);
if (memcmp(&info.dwCursorPosition, &initial, sizeof(COORD)) != 0) {
printf("cursor moved to [%d,%d]\n",
info.dwCursorPosition.X,
info.dwCursorPosition.Y);
GetConsoleScreenBufferInfo(out, &info);
initial = info.dwCursorPosition;
}
}
2012-04-01 08:40:30 +00:00
return 0;
}