How to disable user selection in Windows console

天大地大妈咪最大 提交于 2019-12-11 06:49:21

问题


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.



来源:https://stackoverflow.com/questions/46567248/how-to-disable-user-selection-in-windows-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!