readonly int Space = (int)AppHotKey.GlobalAddAtom(Guid.NewGuid().ToString()); //0x3254; //唯一ID才对 protected override void WndProc(ref Message m) { base.WndProc(ref m); if (m.Msg == WM_HOTKEY) { if (m.WParam.ToInt32() == Space) { if (this.Visible) { this.Hide(); } else { Visible = true; } } } switch (m.Msg) { case WM_CREATE: //AppHotKey.RegKey(this.Handle , Space , AppHotKey.KeyModifiers.Alt , Keys.Z); break; case WM_DESTROY: AppHotKey.Unregkey(this.Handle, Space); break; default: break; } }
private void Btn2_Click(object sender, EventArgs e) { AppHotKey.Unregkey(Handle, Space); }