AI助手支持GPT4.0
using Microsoft.Win32;
private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
{
HotKey.UnregisterHotKey(Handle, 100);
}
class HotKey
{
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
public static extern bool RegisterHotKey(IntPtr hWnd,int id, KeyModifiers fsModifiers,Keys vk);
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
public static extern bool UnregisterHotKey(IntPtr hWnd,int id);
[Flags()]
public enum KeyModifiers
{
None = 0,
Alt = 1,
Ctrl = 2,
Shift = 4,
WindowsKey = 8
}
}
protected override void WndProc(ref Message m)
{
const int WM_HOTKEY = 0x0312;
switch (m.Msg)
{
case WM_HOTKEY:
switch (m.WParam.ToInt32())
{
case 160:
JPbutton.PerformClick();
break;
}
break;
}
base.WndProc(ref m);
}
private void MainForm_Load(object sender, EventArgs e)
{
HotKey.RegisterHotKey(Handle, 160, HotKey.KeyModifiers.Alt, Keys.E);
}