c# - Can I cancel selecting text in console? -
i'm making console application in c# , wonder if it's possible disable selecting text while holding shift , pressing arrows.
i tried using console.cancelkeypress doesn't work in case.
try use these methods:
[dllimport("user32.dll", charset = charset.auto, setlasterror = true)] private static extern intptr setwindowshookex(int idhook, lowlevelkeyboardproc lpfn, intptr hmod, uint dwthreadid); [dllimport("user32.dll", charset = charset.auto, setlasterror = true)] [return: marshalas(unmanagedtype.bool)] private static extern bool unhookwindowshookex(intptr hhk);
and in hook method:
private static intptr hookcb(int ncode, intptr wparam, intptr lparam) { if (ncode >= 0 && wparam == (intptr)wm_keydown) { int keycode = marshal.readint32(lparam); string keyname = ((keys)keycode).tostring(); //there can define key pressed , react accordingly }}
Comments
Post a Comment