Is there a simple way to create a tool which works in the background and simulates the CTRL+V key?
For example: Whenever I press the F1 button, windows pastes the copied text in an active textbox.
PS: sorry for STRG :( its the german version of CTRL
Ok Part II:
This way works for me:
private void Form1_Load(object sender, EventArgs e)
{
this.KeyPreview = true;
this.KeyDown += new System.Windows.Forms.KeyEventHandler(KeyEvent);
}
private void KeyEvent(object sender, KeyEventArgs e) //Keyup Event
{
if (e.KeyCode == Keys.F4)
{
SendKeys.Send("^(V)");
}
}
But it only works within my application.I also wan't my program to do this in other applications. For example: when i press [WindowsKey] + [R], the "proceed window" opens, if i klick f4 then my program should simulate an [CTRL] + [V] and paste the copied text. Any help?
SOLUTION:
I finally got it, the way it works for me:
using Utilities;
namespace F4paste
{
public partial class Form1 : Form
{
globalKeyboardHook gkh = new globalKeyboardHook();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
gkh.HookedKeys.Add(Keys.F4);
gkh.KeyDown += new KeyEventHandler(gkh_KeyDown);
}
void gkh_KeyDown(object sender, KeyEventArgs e)
{
SendKeys.Send("^(V)");
e.Handled = true;
}
private void label1_Click(object sender, EventArgs e)
{
}
}
}
This link is neccessary: A Simple C# Global Low Level Keyboard Hook