c# - Get Keys from a ShortCut -
is there way of getting keys shortcut besides
sc of type system.windows.forms.shortcut
var k = (keys)sc;
i need separate strings each of keys , above won't work since i'm using progress abl .net bridge (don't ask).
i thought sc
should integer, apparently in .net line of code works fine.
the shortcut enum values chosen exact match keys enumeration short-cut. example, shortcut.ctrlshiftf1 0x30070 matches (keys.control | keys.shift | keys.f1): 0x20000 | 0x10000 | 0x00070 = 0x30070. not accident.
converting shortcut string provided, menu item in menustrip can automatically display string of menuitem.shortcut if set showshortcut property true. can use same technique in own code, use keysconverter class:
var sc = shortcut.ctrlshiftf1; var txt = new keysconverter().converttostring((keys)sc); console.writeline(txt);
output:
ctrl+shift+f1 .
Comments
Post a Comment