I have a button on a form to which I wish to assign a hot-key:
namespace WebBrowser
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
int GetPixel(int x, int y)
{
Bitmap bmp = new Bitmap(1, 1, PixelFormat.Format32bppPArgb);
Graphics grp = Graphics.FromImage(bmp);
grp.CopyFromScreen(new Point(x,y), Point.Empty, new Size(1,1));
grp.Save();
return bmp.GetPixel(0, 0).ToArgb();
}
//
// THIS! How can I make a hot-key trigger this button?
//
void Button1Click(object sender, EventArgs e)
{
int x = Cursor.Position.X;
int y = Cursor.Position.Y;
int pixel = GetPixel(x,y);
textBox1.Text = pixel.ToString();
}
void MainFormLoad(object sender, EventArgs e)
{
webBrowser1.Navigate("http://google.com");
}
}
}