dllimport - SendKeys with C# PostMessage - Underscore -


i'm trying send underscore postmessage best can -, can here cannot find answer anywhere.

i send string character loop gets each 1 , uses postmessage send key, works fine cannot figure out _.

public bool sendkeys(string message)     {         var success = false;         uint wparam = 0 << 29 | 0;         foreach (var child in getchildwindows(window.windowhandle))         {             var sb = new stringbuilder(100);             getclassname(child, sb, sb.capacity);             //(intptr)keys.h             if (sb.tostring() != window.targetwindow) continue;             foreach (var c in message)             {                 var k = convertfromstring(c.tostring());                 if (string.equals(c.tostring(), c.tostring().toupper(), stringcomparison.ordinal))                 {                     postmessage(child, wm_char, (intptr) k, (intptr) wparam);                 }                 else                 {                     postmessage(child, wm_keydown, (intptr)k, (intptr)wparam);                 }                 success = true;                 thread.sleep(200);             }         }         return success;     } 

convertfromstring (keys)enum.parse(typeof (keys), keystr); really, getting key system.form.keys

can identify how send underscore??

convertfromstring (keys)enum.parse(typeof (keys), keystr);

that fundamental flaw, there no keys enumeration value represent underscore. keys virtual keys, same anywhere in world. characters produce not same, depends modifier keys , active keyboard layout user selected.

an american user must first press shift key, press keys.oemminus. german user must press shift, keys.oemquestion. french user presses keys.d8. spanish user presses altgr, keys.d7. etcetera.

you'll need ahead dropping dependency on keys if want predictable result. use wm_char , pass actual character want.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -