.net随笔-vb.net打开外部程序发送键盘信号(1)
2019-03-27 09:34
239 查看
版权声明:本博客所有文章版权归博主刘兴所有,转载请注意来源 https://blog.csdn.net/AI_LX/article/details/88836740
Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim notepadID As Integer ' 下面可激活一个运行中的程序 'AppActivate("无标题 - 记事本") ' 通过shell函数运行一个新实例 notepadID = Shell("NOTEPAD.EXE", AppWinStyle.NormalFocus) AppActivate(notepadID) My.Computer.Keyboard.SendKeys("您好,世界!", True) End Sub End Class
C#
public void SendKeys (string keys, bool wait);
Parameters
keys
String
A String that defines the keys to send.
wait
Boolean
Optional. A Boolean that specifies whether or not to wait for keystrokes to get processed before the application continues. True by default.
Exceptions
SecurityException
A partial-trust situation exists in which the user lacks necessary permissions
因为没有托管方法来激活另一个应用程序,所以您可以在当前应用程序中使用该类,手动选择要向其发送密钥的窗口,或者使用Windows API方法(如FindWindow和SetForegroundWindow)强制将焦点移动到其他应用程序上
相关文章推荐
- .net随笔-vb.net打开外部程序发送键盘信号(4)
- .net随笔-vb.net打开外部程序发送键盘信号(2)
- .net随笔-vb.net打开外部程序发送键盘信号(3)
- .net随笔-vb.net获取键盘信号
- .net随笔-vb.net发送消息给计算器
- VB中关闭shell打开的外部EXE程序
- 如何给VB.net2008创建发送与接收端程序
- VB.NET启动外部程序
- .net随笔-vb.net下载文件
- [转]VB.NET启动外部程序
- VB.NET启动外部程序
- VB中关闭shell打开的外部EXE程序
- 关于打开外部程序并且发送一个按键消息 (转
- 关于打开外部程序并且发送一个按键消息 (转)
- 在.net安装程序中部署oracle客户端全攻略-.NET教程,VB.Net语言
- VB.NET启动外部程序
- 使用vb.net等待外部程序运行完毕才继续
- VB.NET启动外部程序
- VB.NET启动外部程序
- VB.NET启动外部程序