c# - I want to be able to hold down control by code -
i'm using c#, visual studio 2010 windows application.
i want hold downwards ctrl key, release after while.
i tried didnt work.
[dllimport("user32.dll")] static extern bool keybd_event(byte bvk, byte bscan, uint dwflags, uintptr dwextrainfo); public const uint keyeventf_keyup = 0x02; public const uint vk_control = 0x11; // press command key. keybd_event(vk_control,0,0,0); //release command key keybd_event(vk_control, 0, keyeventf_keyup, 0);
but error
the best overloaded method match 'imager.form1.keybd_event(byte, byte, uint, system.uintptr)
cannot convert 'uint' 'byte'
cannot convert 'int' 'system.uintptr'
i didn't find examples of sendinput, examples @ http://www.pinvoke.net/default.aspx/user32.keybd_event didn't work me.
the best solution solve @ http://inputsimulator.codeplex.com/
now simple
//press ctrl;
inputsimulator.simulatekeydown(virtualkeycode.control);
//release ctrl inputsimulator.simulatekeyup(virtualkeycode.control);
c# keyboard-hook
No comments:
Post a Comment