I need to disable user mouse selection in the Windows console. Is it possible and how? I tried the function SetConsoleMode()
to disable mouse input with it, but it did not work as I expected. Selecting was still possible.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The console's quick-edit mode allows the user to quickly select and copy text using the mouse, without having to first enter mark mode (i.e. Ctrl+M, or Edit -> Mark on the menu). It's usually convenient to enable quick-edit mode, but it does interfere with getting mouse input. You can disable it using a handle for the console input buffer as follows:
DWORD prev_mode;
GetConsoleMode(hInput, &prev_mode);
SetConsoleMode(hInput, ENABLE_EXTENDED_FLAGS |
(prev_mode & ~ENABLE_QUICK_EDIT_MODE));
Remember to restore the previous mode at exit.