c# - How to detect CAPS-Lock and make sure it's always disabled -


this question has answer here:

well, might wondering why use of having caps-lock enabled no matter what. well, starters, have barcode scanning system scans alphanumeric barcodes includes small case , upper case letters, etc etc. when barcode scans, input captures characters , verifies barcode , other stuff. has caused me quite few problems users have caps-lock on x,y reason , of course, when scan items, characters become capitalized , nothing works there.

my question, there way able "disable" (might wrong choice of words) caps lock or perhaps turn off if it's on. ideal if it's detected there's textchanged event happening make sure it's off.

    private void barcodeval_textchanged(object sender, eventargs e)     {          //check if caps lock on. if is, turn off , evaluate barcode     } 

is need happen.

upon searching, code taken this page page seems work:

using system; using system.runtime.interopservices; using system.windows.forms;  public class capslockcontrol {     [dllimport("user32.dll")]     static extern void keybd_event(byte bvk, byte bscan, uint dwflags,uintptr dwextrainfo);     const int keyeventf_extendedkey = 0x1;     const int keyeventf_keyup = 0x2;  public static void main() {     if (control.iskeylocked(keys.capslock))         {             console.writeline("caps lock key on.  we'll turn off");             keybd_event(0x14, 0x45, keyeventf_extendedkey, (uintptr) 0);             keybd_event(0x14, 0x45, keyeventf_extendedkey | keyeventf_keyup,             (uintptr) 0);         }     else         {             console.writeline("caps lock key off");         }     } } 

would possible force barcode strings upper or lower , compare them against upper or lower cased string database?


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -