串口通信最终都是用二进制传输的,你用代码把二进制转化成十六进制就可以了。不需要额外设置。
创新互联建站专业为企业提供江汉网站建设、江汉做网站、江汉网站设计、江汉网站制作等企业网站建设、网页设计与制作、江汉企业网站模板建站服务,10年江汉做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
用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的实例,各个按键对应的虚拟键码,要到网上查
很有意思。
原文数据全为:“00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ”
加密后变成了:“09 51 55 F4 FB 10 6F A4 D3 E8 87 46 F8 2F 49 CD ; ”
得出这样的结果是有很多方法都可以实现的:
比如每个原数上加上个常数就可以了。
00+09=09;得出第一组加密后的数值
00+51=51;得出第二组加密后的数值
...
00+CD=CD;得出第16组加密后的数值.
加密的方法还有很多,不过这种最简单。
还有就是你给的原文太单一了,不能够更好的分析数据的规律。
如果你能把原文改为如下这段代码再去加密一下,再把加密结果贴上来看一下就好多了。
00000140h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ;
00000150h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ;
00000160h: 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 ; 00000170h: 00 10 20 30 40 50 60 70 80 90 A0 B0 C0 D0 E0 F0 ;
00000180h: 11 11 11 11 11 22 22 22 22 22 22 EE EE EE FF FF ;
以上是单片机高手团为您解答。
如果还没解决你的问题,可以加我百度HI账号。
看了很多这方便的解决方案,很多都是一大段代码,版本也有差别,既然有可能别人用得起我也用不起。
我用一种最简单的方法,只要思路对所有人都能用得起。
其实非常简单,就是获取键值,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
源内容出处: