using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace C_Sharp_Form_HotKey
{
public partial class Form1 : Form
{
KeyboardHook hook;//control alt tuşlarını dinleme nesnesi
Form form2;//alt control f12 ile açmak istediğimiz form nesnesi
public Form1()
{
InitializeComponent();
//tuş dinleme nesnesinin örneğin oluşturma
hook = new KeyboardHook();
//bir tuşa basıldığında çalışan olan olay
hook.KeyPressed += new EventHandler
(hook_KeyPressed);
//control alt F12 tuşlarına aynı anda basıldığında olay tetiklensin
//burayı HookModifierKeys enum değerlerine göre geniletebilirsiniz
hook.RegisterHotKey(HookModifierKeys.Control | HookModifierKeys.Alt,
Keys.F12);
}
**** hook_KeyPressed(object sender, KeyPressedEventArgs e)
{
//form2 açma fonksiyonunu çağır
form2Ac();
}
private **** Form1_Load(object sender, EventArgs e)
{
//yapılacak olan işlemler
}
private **** form2Ac()
{
//eğre form2 nesnesi daha önce oluşturulmadıysa
//ilk örneğini oluştur
if (form2 == null)
form2 = new Form2(this);
//form2 de form1 ile işlem yapmak
//için construtor (yapıcıya) this yani form nesnesini
//parametre olarak ekle
//form2 nesnesini control alt F12 tuşlarına basılmış is çalıştır
form2.Show();
}
}
}