winpty/misc/Win32Test1.cc

47 lines
986 B
C++
Raw Normal View History

2011-11-19 10:26:48 +00:00
#define _WIN32_WINNT 0x0501
#include "../shared/DebugClient.cc"
2011-11-19 10:26:48 +00:00
#include <windows.h>
#include <stdio.h>
const int SC_CONSOLE_MARK = 0xFFF2;
CALLBACK DWORD writerThread(void*)
{
2012-04-01 08:40:30 +00:00
while (true) {
Sleep(1000);
trace("writing");
printf("X\n");
trace("written");
}
2011-11-19 10:26:48 +00:00
}
int main()
{
2012-04-01 08:40:30 +00:00
CreateThread(NULL, 0, writerThread, NULL, 0, NULL);
trace("marking console");
HWND hwnd = GetConsoleWindow();
PostMessage(hwnd, WM_SYSCOMMAND, SC_CONSOLE_MARK, 0);
2011-11-19 10:26:48 +00:00
2012-04-01 08:40:30 +00:00
Sleep(2000);
2011-11-19 10:26:48 +00:00
2012-04-01 08:40:30 +00:00
trace("reading output");
CHAR_INFO buf[1];
COORD bufSize = { 1, 1 };
COORD zeroCoord = { 0, 0 };
SMALL_RECT readRect = { 0, 0, 0, 0 };
ReadConsoleOutput(GetStdHandle(STD_OUTPUT_HANDLE),
buf,
bufSize,
zeroCoord,
&readRect);
trace("done reading output");
2011-11-19 10:26:48 +00:00
2012-04-01 08:40:30 +00:00
Sleep(2000);
2011-11-19 10:26:48 +00:00
2012-04-01 08:40:30 +00:00
PostMessage(hwnd, WM_CHAR, 27, 0x00010001);
2011-11-19 10:26:48 +00:00
2012-04-01 08:40:30 +00:00
Sleep(1100);
2011-11-19 10:26:48 +00:00
2012-04-01 08:40:30 +00:00
return 0;
2011-11-19 10:26:48 +00:00
}