c# - Create an On-screen Keyboard -


i use postmessage simulate keystrokes in program in background. work fine except characters need shift on physical keyboard. how simulate shift? "

the code use roughly:

 vk vk = vkkeyscanex (c, getkeyboardlayout (0));   attachthreadinput (_attachedthredid, _attachedprocessid, true);  postmessage       (_window, wm_keydown, vk.key, 0x1);  postmessage       (_window, wm_keyup,   vk.key, 0xc0010001);  attachthreadinput (_attachedthredid, _attachedprocessid, false); 

how should handle extended part of vk?

edit

i'm trying create on-screen keyboard. each button on on-screen keyboard simulates sequence of keystrokes. receiver old program performs different tasks depending on keyboard sequence performed. keyboard sequences follows

  • {esc}nn{esc}nn
  • {esc}nn
  • ½nn
  • §nn

where {esc} simulate pressing esc key, nn hex values , §/½ program listen.

normally have special physical keyboard control program, expensive. in test environment not have physical keyboards, have enter these codes manually

you must compromise:

if want simulate keyboard input, must use sendinput, means being @ mercy of window has focus. sendinput hitting keys on physical keyboard. way can send keystrokes specific window using keyboard alt+tab right window.

if want send keystrokes specific window, incur funky behavior:

  1. applications handle input differently. , simple wm_keydown / wm_keyup messages not way detect keyboard input. example there keyboard state (getkeyboardstate()) have harder time simulating. you're experiencing.
  2. applications may rely on standard behavior of having focus while receiving keyboard input messages. posting messages these applications, invoke strange out-of-order behavior may crash them.
  3. now multiple windows on system can receiving keyboard input @ same time. might cause strange behavior.
  4. (etc...) hooks won't called input, keyboard / input drivers won't see it, won't recognized things directinput... it's never-ending patchwork of issues doing bad-bear way.

there no way around side-effects; it's consequence of doing shady stuff.


a solution purposes, because you're targeting single specific application, may use postmessage in conjunction setkeyboardstate simulate keyboard state including shift positions.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -