关于vb.net+点对点发送的信息

vb.net 组合键Ctrl+Enter怎样发送

看了很多这方便的解决方案,很多都是一大段代码,版本也有差别,既然有可能别人用得起我也用不起。

创新互联建站主要从事网站建设、网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务察哈尔右翼前,十余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:13518219792

我用一种最简单的方法,只要思路对所有人都能用得起。

其实非常简单,就是获取键值,Ctrl+Enter的健值是10,是不是思路一下就通了。以下是源码:

Private Sub 聊天输入框_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles 聊天输入框.KeyPress

If Asc(e.KeyChar) = 发送快捷键值 Then

发送消息过程()

End If

End Sub

源内容出处:

vbnet向指定窗口发送指令

控制台程序直接往 standardinput 里面写对应的键码就可以了。

应用程序需要使用 SendKeys() 函数,或者 API 发送消息。

VB.net 怎么制作按键连发功能

用API函数,以下代码Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As LongPrivate Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As LongPrivate Const WS_EX_LAYERED = H80000

Private Const GWL_EXSTYLE = (-20)

Private Const LWA_ALPHA = H2

Private Const LWA_COLORKEY = H1Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Const HWND_TOPMosT = -1

Private Const SWP_NOMOVE = H2

Private Const SWP_NosIZE = H1

Private Declare Function GetForegroundWindow Lib "user32" () As Long

Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Const WM_KEYDOWN = H100

Const WM_KEYUP = H101

Const WM_CHAR = H102

Const VK_F1 = H70

Private Sub SendF1(hwnd) '调用这个过程即可对目标窗体发送F1键

Call PostMessage(hwnd, WM_KEYDOWN, VK_F1, 0)

Call PostMessage(hwnd, WM_KEYUP, VK_F1, 0)

End Sub这里是发送F1的实例,各个按键对应的虚拟键码,要到网上查

VB.net 串口发送数据

你可以这样操作:

Form1.BeginInvoke(Sub()

'一些操作

End Sub)

这样主线程就会放下手里的事情并执行Sub里的操作了


网站栏目:关于vb.net+点对点发送的信息
链接分享:http://azwzsj.com/article/phsdjj.html