Hack Forums
[C#] C# Keypress and keysend - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] C# Keypress and keysend (/showthread.php?tid=5611990)



C# Keypress and keysend - Rinqt - Apr 30, 2017

Hello, pretty new to c# so i wan wondering if i could get some help
basically what i would like to do is check for a key press lets say for example "i"
if "i" is pressed i want to then simulate a keypress(keysend) of another key for example "c".

Desired output would be
if i is pressed
simulate c is pressed aswell

Anyone got any idea's?


* - Zilog80 - Apr 30, 2017

No idea what are you trying to do, but this should work:

PHP Code

<?php 
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
    if (
e.KeyCode == Keys.I)
    {
        
//do something, for instance SendKeys.Send("C")
    
}
} 



* - Owl - Apr 30, 2017

I would map them to a dictionary<keys, char/string> instead of a huge if statement.


* - Finn. - Apr 30, 2017

Check keys in or outside the program?


* - Rinqt - Apr 30, 2017

(Apr 30, 2017 02:46 PM)Finn. Wrote:  Check keys in or outside the program?

a blanket check, pretty much not application specific.


(Apr 30, 2017 12:47 PM)Zilog80 Wrote:  No idea what are you trying to do, but this should work:

PHP Code

<?php 
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
    if (
e.KeyCode == Keys.I)
    {
        
//do something, for instance SendKeys.Send("C")
    
}
} 
thanks for the help, however i think i am going to use the keybd_event from user32.dll


* - mfqn - May 1, 2017

try this ?

ttps://hackforums.net/showthread.php?tid=5579335&pid=54386164#pid54386164