c# - Simulate special key presses keyup events -


i'm using keybd_event function , i'm having issue simulating keys. @ moment, issue namely control button.

here's of code simulating key down , key events:

switch (record.keymsg) {     //key down event     case "wm_keydown":         keybd_event((byte)record.keycode, 0, keyeventf_keydown, 0);         debug.writeline("key down.");         break;     //key event     case "wm_keyup":         keybd_event((byte)record.keycode, 0, keyeventf_keyup, 0);         debug.writeline("key up.");         break; } 

now, when program simulates control button, seems button gets "stuck". visited site: http://javascript.info/tutorial/keyboard-events see kind of events being fired.

when press control button in event watcher on site, here's output:

keydown    keycode=17    which=17    charcode=0    char= +ctrl keyup      keycode=17    which=17    charcode=0    char= 

but when code simulates control button, here's output:

keydown    keycode=17    which=17    charcode=0    char= +ctrl keyup      keycode=17    which=17    charcode=0    char= +ctrl 

furthermore, same sort of problem happens shift key. using same site mentioned before, when manually type shift key, here's output:

keydown    keycode=16    which=16    charcode=0    char= +shift keyup      keycode=16    which=16    charcode=0    char= 

yet, when program simulates this, here's output:

keydown    keycode=16    which=16    charcode=0    char= +shift 

it isn't doing keyup event @ point.

does know how fix this? believe culprit of key being "stuck" keyup event, have no clue how i'm supposed fix that. have tips or clues?

edit: elaborate on meant "stuck: when code simulates control button, , try type things notepad, computer believes control key still being pressed. when type s, prompts save in notepad, etc.. fix this, press both left ctrl , right ctrl fix this.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -