程序A通过键盘组合按键运行并显示。现在我想在我的程序里写个按钮,呼出这个程序A。要如何实现??
解决方案 »
- 未能加载文件或程序集“Microsoft.DirectX.DirectSound.dll”或它的某一个依赖项。动态链接库(DLL)初始化例程失败。
- 关于C#timer的精确度,高手请看
- 排序分页的问题?100分 欢迎参与
- DateGrid 列绑定
- 请帮忙解决!请尽量用简单的方法,最好是多点注释!!谢谢!!!
- 用后台asp.net程序按照前台的asp页面动态生成为静态html页面有什么好的方法呢?
- 获取安装程序的安装路径在哪?
- C#新手求助,判断输入的为4位整数
- 请问怎样让鼠标到达指定的坐标?
- 简单的问题,但是我是新手,奈何!!!(关于DataGrid)up者有分
- 服务器上的Excel文件,老是报使用中错误
- 通过IE打开本地程序的问题
程序A使用CTRL+T就可在系统中运行并显示我程序中的按钮就是要实现CTRL+T的功能,让程序A在系统中运行运行并显示也就是说,当我按下按钮,程序A就能在系统中运行,并显示
前者注册IMessageFilter后者使用Api:RegisterHotKey
你确认哪种先。
例:
if (e.KeyCode == Keys.G)
{
Form1 form1=new Form1;
form1.show();
}
http://blog.csdn.net/wangwenzhuang/archive/2010/09/29/5913695.aspx
学习ing
程序A使用CTRL+T就可在系统中运行并显示我程序中的按钮就是要实现CTRL+T的功能,让程序A在系统中运行运行并显示也就是说,当我按下按钮,程序A就能在系统中运行,并显示
程序A使用CTRL+T就可在系统中运行并显示
A是被启动的。被谁启动?那你就要给启动A的程序注册快捷键。如果是凭空的没任何程序干涉的,你直接给A创建快捷方式,在快捷方式属性的第二个标签页设置快捷键就可以了。这个是给系统注册快捷键,系统检测到快捷键就会启动程序。
我程序中的按钮就是要实现CTRL+T的功能,让程序A在系统中运行运行并显示
就是给你的文章介绍的,你捕获到了快捷键,执行Process.Start("A程序.exe")不就行了?自己想法理顺先。
A程序是独立程序,如果双击A程序.exe,它是会运行,但是不会显示,
只有使用快捷键,才能让它显示出来。Process.Start("A程序.exe")
这个方法我已经尝试过,这样只能让程序运行,而不能显示在界面上。我的程序功能主要是让它显示在界面上。
用来模拟键盘输入的。
打开 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.");
}
}
[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);