2011-11-22 09:26:51 +00:00
|
|
|
#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);
|
|
|
|
}
|
2011-11-22 09:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2012-04-01 08:40:30 +00:00
|
|
|
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
|
|
CONSOLE_SCREEN_BUFFER_INFO info;
|
2011-11-22 09:26:51 +00:00
|
|
|
|
2012-04-01 08:40:30 +00:00
|
|
|
GetConsoleScreenBufferInfo(out, &info);
|
|
|
|
COORD initial = info.dwCursorPosition;
|
2011-11-22 09:26:51 +00:00
|
|
|
|
2012-04-01 08:40:30 +00:00
|
|
|
CreateThread(NULL, 0,
|
|
|
|
pausingThread, NULL,
|
|
|
|
0, NULL);
|
2011-11-22 09:26:51 +00:00
|
|
|
|
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;
|
|
|
|
}
|
2011-11-22 09:26:51 +00:00
|
|
|
}
|
2012-04-01 08:40:30 +00:00
|
|
|
return 0;
|
2011-11-22 09:26:51 +00:00
|
|
|
}
|