c# - How to send continuous keypress to a program? -



c# - How to send continuous keypress to a program? -

i have been using sendkeys.send() & sendkeys.sendwait() send keys foreground programme (a programme different application written).

i tried sending continuous key-press sending repeatedly same key delay between them effect not same continuous keypress in application.

my question is: how can send continuous key-press program? effect of keypress must same pressing myself key continuously in application.

solution edit

the solution phone call method:

[dllimport("user32.dll")] static extern int sendmessage(intptr hwnd, uint wmsg, uintptr wparam, intptr lparam);

with parameters obtained from:

public system.diagnostics.process[] p = system.diagnostics.process.getprocessesbyname("process");

p[0].mainwindowhandle hwnd

and using spy on window:

right clicking on message line in spy shows wmsg, wparam , lparam (all 3 in hexadecimal)

sendmessage(p[0].mainwindowhandle, (uint)0x0100, (uintptr)0x00000041, (intptr)(0x001e0001));

by sending 1 wm_keydown message effect key pressed continuously. stop programme acting key continuously pressed have press key on keyboard , release it, wm_keyup generated. sending wm_keyup in code gives system.overflow "arithmetic operation resulted in overflow." exception. ideea why might happen?

thanks replies: ation , takrl

try utilize win api sendmessage wm_keydown , wm_keyup. proper delay should between messaging. utilize postmessage async sending.

[dllimport("user32.dll")] public static extern int sendmessage(intptr hwnd, uint msg, int wparam, int lparam);

c# winforms console

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -