按钮实现快捷键

Ray_15 2010-11-16 11:10:10
程序A通过键盘组合按键运行并显示。

现在我想在我的程序里写个按钮,呼出这个程序A。

要如何实现??
...全文
460 24 打赏 收藏 转发到动态 举报
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
bluefirea 2011-10-11
  • 打赏
  • 举报
回复
可以考虑用Windows快捷键注册API
[DllImport("user32.dll")]
private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vlc);

[DllImport("user32.dll")]
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
兔子-顾问 2010-11-16
  • 打赏
  • 举报
回复
http://blog.csdn.net/cryeyes/archive/2007/04/09/1557723.aspx
by_封爱 版主 2010-11-16
  • 打赏
  • 举报
回复
我懂你的

比如我快捷键呼出QQ 是吧 我以前也想做这个东西了

类似游戏喊话的东西 但是我没做出来 顶你..


学习ing
wangwenzhuang 2010-11-16
  • 打赏
  • 举报
回复
用钩子可以实现
http://blog.csdn.net/wangwenzhuang/archive/2010/09/29/5913695.aspx
Ray_15 2010-11-16
  • 打赏
  • 举报
回复
操作系统内有效的快捷键
fanxingya2012 2010-11-16
  • 打赏
  • 举报
回复
在OnKeyDown事件里面去设置
例:
if (e.KeyCode == Keys.G)
{
Form1 form1=new Form1;
form1.show();
}
兔子-顾问 2010-11-16
  • 打赏
  • 举报
回复
你想实现程序内有效的快捷键还是操作系统内有效的快捷键?
前者注册IMessageFilter后者使用Api:RegisterHotKey
你确认哪种先。
Ray_15 2010-11-16
  • 打赏
  • 举报
回复
钩子函数怎么使用??
有没有实例代码?
cdglynn 2010-11-16
  • 打赏
  • 举报
回复
系统级的快捷键用钩子函数
Ray_15 2010-11-16
  • 打赏
  • 举报
回复
各位可能误会了,我不是要获取按键

例如:
程序A使用CTRL+T就可在系统中运行并显示

我程序中的按钮就是要实现CTRL+T的功能,让程序A在系统中运行运行并显示

也就是说,当我按下按钮,程序A就能在系统中运行,并显示
sardineany 2010-11-16
  • 打赏
  • 举报
回复
如果是英文的 还是那个属性里,例如: &cancel 这样c就是快捷键了。
colorall 2010-11-16
  • 打赏
  • 举报
回复
KeyDown事件里做判断按下哪个键了
sardineany 2010-11-16
  • 打赏
  • 举报
回复
text属性里,也就是这个按钮的显示名字的位置 Text=按钮(&B) 那个就是快捷键了- - 当然可以自己改别的
herty 2010-11-16
  • 打赏
  • 举报
回复
确定(&O) 或者在 KeyDown 事件下判断
herty 2010-11-16
  • 打赏
  • 举报
回复
WINFORM 有自带的....
snowfirelove 2010-11-16
  • 打赏
  • 举报
回复
若要验证在同一时间中按下 ALT 键和 F 键,请按照下列步骤操作:
打开 Visual Studio.net。
创建一个新 Visual C# Windows 应用程序项目。
添加到窗体的文本框。
该形式键入下面的代码:

private void Form1_Load(object sender, System.EventArgs e)
{
// Set these when the form loads:
// Have the form capture keyboard events first.
this.KeyPreview = true;
// Assign the event handler to the form.
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);
// Assign the event handler to the text box.
this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyDown);
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Alt && e.KeyCode.ToString() == "F")
{
// When the user presses both the 'Alt' key and 'F' key,
// KeyPreview is set to False, and a message appears.
// This message is only displayed when KeyPreview is set to True.
this.KeyPreview = false;
MessageBox.Show("KeyPreview is True, and this is from the FORM.");
}
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Alt && e.KeyCode.ToString() == "F")
{
// When the user presses both the 'Alt' key and 'F' key,
// KeyPreview is set to False, and a message appears.
// This message is only displayed when KeyPreview is set to False.
this.KeyPreview = true;
MessageBox.Show("KeyPreview is False, and this is from the CONTROL.");
}
}
兔子-顾问 2010-11-16
  • 打赏
  • 举报
回复
搜索keybd_event
用来模拟键盘输入的。
sunlongchina 2010-11-16
  • 打赏
  • 举报
回复
sunlongchina@sina.com 是我的邮箱 需要的好个暗号
sunlongchina 2010-11-16
  • 打赏
  • 举报
回复
我有一个例子 不知道是不是楼主 想要的
Ray_15 2010-11-16
  • 打赏
  • 举报
回复
是的!!

你终于知道我的意思了!
加载更多回复(4)

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧