<connectionStrings>
<add name="IPhoneDBContext"
connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=True;MultipleActiveResultSets=True;AttachDBFilename=|DataDirectory|\IPhoneDB.mdf;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace ScrMaster
{
public partial class MainForm : Form
{
private int uniqId = 1;
private int ALT = 0x0001;
private Keys key = Keys.PrintScreen;
private bool canWork = true;
Timer timer = new Timer();
public MainForm()
{
timer.Tick += Timer_Tick;
timer.Interval = 5_000;
InitializeComponent();
}
private void Timer_Tick(object sender, EventArgs e)
{
canWork = true;
timer.Stop();
}
private void MainForm_Load(object sender, EventArgs e)
{
SetHotKey();
this.FormClosing += ClearHotKey;
}
private void SetHotKey()
{
RegisterHotKey(this.Handle, uniqId, (uint)ALT, (uint)key);
}
private void ClearHotKey(object sender, CancelEventArgs e)
{
UnregisterHotKey(this.Handle, uniqId);
}
#region Extern Dll
[DllImport("user32.dll")]
public static extern
bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);
[DllImport("user32.dll")]
public static extern
bool UnregisterHotKey(IntPtr hWnd, int id);
#endregion
protected override void WndProc(ref Message keyPressed)
{
if (keyPressed.Msg == 0x0312)
{
if (canWork)
{
switch (keyPressed.WParam.ToInt32())
{
case 1: SetPrtSc(); break;
}
}
}
base.WndProc(ref keyPressed);
}
private void SetPrtSc()
{
canWork = !canWork;
MessageBox.Show("");
timer.Start();
}
}
}