Use "Select All" instead of "Mark" to freeze the console.
The Mark command moves the cursor to the top-left, which interferes with lynx, a full-screen Cygwin web browser, and probably other programs. The Select All command also puts the console into selection mode, blocking console output.
This commit is contained in:
parent
023e5f333f
commit
bba54c0703
@ -13,6 +13,7 @@
|
||||
#include <windows.h>
|
||||
|
||||
const int SC_CONSOLE_MARK = 0xFFF2;
|
||||
const int SC_CONSOLE_SELECT_ALL = 0xFFF5;
|
||||
const int SYNC_MARKER_LEN = 16;
|
||||
#define CSI "\x1b["
|
||||
|
||||
@ -47,7 +48,7 @@ Agent::Agent(const QString &socketServer,
|
||||
m_timer = new QTimer(this);
|
||||
m_timer->setSingleShot(false);
|
||||
connect(m_timer, SIGNAL(timeout()), SLOT(pollTimeout()));
|
||||
m_timer->start(500);
|
||||
m_timer->start(25);
|
||||
|
||||
Trace("agent starting...");
|
||||
}
|
||||
@ -322,7 +323,7 @@ void Agent::scrapeOutput()
|
||||
|
||||
void Agent::freezeConsole()
|
||||
{
|
||||
SendMessage(m_console->hwnd(), WM_SYSCOMMAND, SC_CONSOLE_MARK, 0);
|
||||
SendMessage(m_console->hwnd(), WM_SYSCOMMAND, SC_CONSOLE_SELECT_ALL, 0);
|
||||
}
|
||||
|
||||
void Agent::unfreezeConsole()
|
||||
|
40
Misc/SelectAllTest.cc
Normal file
40
Misc/SelectAllTest.cc
Normal file
@ -0,0 +1,40 @@
|
||||
#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)
|
||||
{
|
||||
HWND hwnd = GetConsoleWindow();
|
||||
while (true) {
|
||||
SendMessage(hwnd, WM_SYSCOMMAND, SC_CONSOLE_SELECT_ALL, 0);
|
||||
SendMessage(hwnd, WM_CHAR, 27, 0x00010001);
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
CONSOLE_SCREEN_BUFFER_INFO info;
|
||||
|
||||
GetConsoleScreenBufferInfo(out, &info);
|
||||
COORD initial = info.dwCursorPosition;
|
||||
|
||||
CreateThread(NULL, 0,
|
||||
pausingThread, NULL,
|
||||
0, NULL);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
56
Misc/VkEscapeTest.cc
Normal file
56
Misc/VkEscapeTest.cc
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Sending VK_PAUSE to the console window almost works as a mechanism for
|
||||
* pausing it, but it doesn't because the console could turn off the
|
||||
* ENABLE_LINE_INPUT console mode flag.
|
||||
*/
|
||||
|
||||
#define _WIN32_WINNT 0x0501
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <windows.h>
|
||||
|
||||
CALLBACK DWORD pausingThread(LPVOID dummy)
|
||||
{
|
||||
if (1) {
|
||||
Sleep(1000);
|
||||
HWND hwnd = GetConsoleWindow();
|
||||
SendMessage(hwnd, WM_KEYDOWN, VK_PAUSE, 1);
|
||||
Sleep(1000);
|
||||
SendMessage(hwnd, WM_KEYDOWN, VK_ESCAPE, 1);
|
||||
}
|
||||
|
||||
if (0) {
|
||||
INPUT_RECORD ir;
|
||||
memset(&ir, 0, sizeof(ir));
|
||||
ir.EventType = KEY_EVENT;
|
||||
ir.Event.KeyEvent.bKeyDown = TRUE;
|
||||
ir.Event.KeyEvent.wVirtualKeyCode = VK_PAUSE;
|
||||
ir.Event.KeyEvent.wRepeatCount = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
HANDLE hin = GetStdHandle(STD_INPUT_HANDLE);
|
||||
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
COORD c = { 0, 0 };
|
||||
|
||||
DWORD mode;
|
||||
GetConsoleMode(hin, &mode);
|
||||
SetConsoleMode(hin, mode &
|
||||
~(ENABLE_LINE_INPUT));
|
||||
|
||||
CreateThread(NULL, 0,
|
||||
pausingThread, NULL,
|
||||
0, NULL);
|
||||
|
||||
int i = 0;
|
||||
while (true) {
|
||||
Sleep(100);
|
||||
printf("%d\n", ++i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user