I'm trying to do a Form using VS2017 and C# , it will be for personal use.
I want that when I press "F2" key in other application (like Word, Excel, Notepad) a text that was previously determined in a TextBox into Visual Studio automatically appears.
For example, If the form has a TextBox1 with a text that says "Hello" I want that I press F2 in Word and the text "Hello" appears.
By the moment I have this, but I think is wrong
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.F2)
{
SendKeys.Send(textBox1.Text);
}
}
}
}
If you can help me with this, I'll be glad! :)
Thank you!