|zyciis| 如何在windows 中的任意地方 按了键盘的[F10] 就能掉用我的WinForm程序的一个按钮事件 比如我的WinForm启动后最小化然后他有一个Button_Click()事件为MessageBox.Show("程序调用成功");现在要求这个程序运行后在我的Windows中的任何地方按了[F10]的话就能调用这个Click()事件谢谢怎么办 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 系统热键啊大概需要 这么4个[DllImport("user32.dll")]public static extern UInt32 RegisterHotKey( IntPtr hWnd, UInt32 id, UInt32 fsModifiers, UInt32 vk);[DllImport("user32.dll")]public static extern UInt32 UnregisterHotKey( IntPtr hWnd, UInt32 id); [DllImport("kernel32.dll")]public static extern UInt32 GlobalAddAtom( String lpString );[DllImport("kernel32.dll")]public static extern UInt32 GlobalDeleteAtom( UInt32 nAtom );baidu一下 满大街都是。我相信楼下会给出搜索结果 string strKeys; private void Form1_Load(object sender, EventArgs e) { RegisterHotKey(Handle, 100, 0, Keys.F10); } [Flags()] public enum KeyModifiers { None = 0, Alt = 1, Control = 2, Shift = 4, Windows = 8 } private void ProcessHotkey()//主处理程序 { button2_Click(null, null); } protected override void WndProc(ref Message m)//循环监视Windows消息 { const int WM_HOTKEY = 0x0312;//按快捷键 switch (m.Msg) { case WM_HOTKEY: ProcessHotkey();//调用主处理程序 break; } base.WndProc(ref m); } [DllImport("user32.dll", SetLastError = true)] public static extern bool RegisterHotKey(IntPtr hWnd, // handle to window int id, // hot key identifier KeyModifiers fsModifiers, // key-modifier options Keys vk // virtual-key code ); [DllImport("user32.dll", SetLastError = true)] public static extern bool UnregisterHotKey(IntPtr hWnd, // handle to window int id // hot key identifier ); private void button2_Click(object sender, EventArgs e) { MessageBox.Show("ddd"); } string strKeys; private void Form1_Load(object sender, EventArgs e) { RegisterHotKey(Handle, 100, 0, Keys.F10); } [Flags()] public enum KeyModifiers { None = 0, Alt = 1, Control = 2, Shift = 4, Windows = 8 } private void ProcessHotkey()//主处理程序 { button2_Click(null, null); } protected override void WndProc(ref Message m)//循环监视Windows消息 { const int WM_HOTKEY = 0x0312;//按快捷键 switch (m.Msg) { case WM_HOTKEY: ProcessHotkey();//调用主处理程序 break; } base.WndProc(ref m); } [DllImport("user32.dll", SetLastError = true)] public static extern bool RegisterHotKey(IntPtr hWnd, // handle to window int id, // hot key identifier KeyModifiers fsModifiers, // key-modifier options Keys vk // virtual-key code ); [DllImport("user32.dll", SetLastError = true)] public static extern bool UnregisterHotKey(IntPtr hWnd, // handle to window int id // hot key identifier ); private void button2_Click(object sender, EventArgs e) { MessageBox.Show("ddd"); } LZ把这个在MSDN上搜一下或者直接去google搜C#注册系统热键 为什么属性名称和方法的名称不能相同呢? 求懂.net中 SocketAsyncEventArgs 类的高手解答小问题 【小白电脑前坐等高手答复】Gridview下载和删除 图片抽奖系统有些问题 怎么实现TextBox.Enable=False,并且字体颜色为黑色 关于C#的WEB Service的奇怪问题!!!! 请教关于mdi问题 C#关于引用类型,地址 我在用regsvcs命令时出现如下提示(执行成功),如何解决? State问题(给分) split问题 DataGridView DataTable DataSet 的关系及应用
大概需要 这么4个
[DllImport("user32.dll")]
public static extern UInt32 RegisterHotKey( IntPtr hWnd, UInt32 id, UInt32 fsModifiers, UInt32 vk);
[DllImport("user32.dll")]
public static extern UInt32 UnregisterHotKey( IntPtr hWnd, UInt32 id);
[DllImport("kernel32.dll")]
public static extern UInt32 GlobalAddAtom( String lpString );
[DllImport("kernel32.dll")]
public static extern UInt32 GlobalDeleteAtom( UInt32 nAtom );baidu一下 满大街都是。我相信楼下会给出搜索结果
string strKeys;
private void Form1_Load(object sender, EventArgs e)
{ RegisterHotKey(Handle, 100, 0, Keys.F10); } [Flags()]
public enum KeyModifiers
{
None = 0,
Alt = 1,
Control = 2,
Shift = 4,
Windows = 8
}
private void ProcessHotkey()//主处理程序
{
button2_Click(null, null);
} protected override void WndProc(ref Message m)//循环监视Windows消息
{
const int WM_HOTKEY = 0x0312;//按快捷键
switch (m.Msg)
{
case WM_HOTKEY:
ProcessHotkey();//调用主处理程序
break;
}
base.WndProc(ref m);
} [DllImport("user32.dll", SetLastError = true)]
public static extern bool RegisterHotKey(IntPtr hWnd,
// handle to window
int id, // hot key identifier
KeyModifiers fsModifiers, // key-modifier options
Keys vk // virtual-key code
); [DllImport("user32.dll", SetLastError = true)]
public static extern bool UnregisterHotKey(IntPtr hWnd,
// handle to window
int id // hot key identifier
);
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("ddd");
}
string strKeys;
private void Form1_Load(object sender, EventArgs e)
{ RegisterHotKey(Handle, 100, 0, Keys.F10); } [Flags()]
public enum KeyModifiers
{
None = 0,
Alt = 1,
Control = 2,
Shift = 4,
Windows = 8
}
private void ProcessHotkey()//主处理程序
{
button2_Click(null, null);
} protected override void WndProc(ref Message m)//循环监视Windows消息
{
const int WM_HOTKEY = 0x0312;//按快捷键
switch (m.Msg)
{
case WM_HOTKEY:
ProcessHotkey();//调用主处理程序
break;
}
base.WndProc(ref m);
} [DllImport("user32.dll", SetLastError = true)]
public static extern bool RegisterHotKey(IntPtr hWnd,
// handle to window
int id, // hot key identifier
KeyModifiers fsModifiers, // key-modifier options
Keys vk // virtual-key code
); [DllImport("user32.dll", SetLastError = true)]
public static extern bool UnregisterHotKey(IntPtr hWnd,
// handle to window
int id // hot key identifier
);
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("ddd");
}
LZ把这个在MSDN上搜一下
或者直接去google搜C#注册系统热键