📄 frmkeyboard.frm
字号:
VERSION 5.00
Begin VB.Form frmKeyboard
BorderStyle = 4 'Fixed ToolWindow
Caption = "串口键盘"
ClientHeight = 2580
ClientLeft = 45
ClientTop = 285
ClientWidth = 2160
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2580
ScaleWidth = 2160
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton cmd
Caption = "关闭"
Height = 255
Left = 720
TabIndex = 16
Top = 1560
Width = 615
End
Begin VB.CommandButton cmdKey
Appearance = 0 'Flat
Caption = "7"
Height = 375
Index = 7
Left = 0
Style = 1 'Graphical
TabIndex = 15
TabStop = 0 'False
Top = 0
Width = 375
End
Begin VB.CommandButton cmdKey
Appearance = 0 'Flat
Caption = "8"
Height = 375
Index = 8
Left = 360
Style = 1 'Graphical
TabIndex = 14
TabStop = 0 'False
Top = 0
Width = 375
End
Begin VB.CommandButton cmdKey
Appearance = 0 'Flat
Caption = "9"
Height = 375
Index = 9
Left = 720
Style = 1 'Graphical
TabIndex = 13
TabStop = 0 'False
Top = 0
Width = 375
End
Begin VB.CommandButton cmdKey
Appearance = 0 'Flat
Caption = "4"
Height = 375
Index = 4
Left = 0
Style = 1 'Graphical
TabIndex = 12
TabStop = 0 'False
Top = 360
Width = 375
End
Begin VB.CommandButton cmdKey
Appearance = 0 'Flat
Caption = "5"
Height = 375
Index = 5
Left = 360
Style = 1 'Graphical
TabIndex = 11
TabStop = 0 'False
Top = 360
Width = 375
End
Begin VB.CommandButton cmdKey
Appearance = 0 'Flat
Caption = "6"
Height = 375
Index = 6
Left = 720
Style = 1 'Graphical
TabIndex = 10
TabStop = 0 'False
Top = 360
Width = 375
End
Begin VB.CommandButton cmdKey
Appearance = 0 'Flat
Caption = "1"
Height = 375
Index = 1
Left = 0
Style = 1 'Graphical
TabIndex = 9
TabStop = 0 'False
Top = 720
Width = 375
End
Begin VB.CommandButton cmdKey
Appearance = 0 'Flat
Caption = "2"
Height = 375
Index = 2
Left = 360
Style = 1 'Graphical
TabIndex = 8
TabStop = 0 'False
Top = 720
Width = 375
End
Begin VB.CommandButton cmdKey
Appearance = 0 'Flat
Caption = "3"
Height = 375
Index = 3
Left = 720
Style = 1 'Graphical
TabIndex = 7
TabStop = 0 'False
Top = 720
Width = 375
End
Begin VB.CommandButton cmdKey
Appearance = 0 'Flat
Caption = "0"
Height = 375
Index = 0
Left = 0
Style = 1 'Graphical
TabIndex = 6
TabStop = 0 'False
Top = 1080
Width = 375
End
Begin VB.CommandButton cmdKey
Appearance = 0 'Flat
Caption = ">"
Height = 375
Index = 10
Left = 720
Style = 1 'Graphical
TabIndex = 5
TabStop = 0 'False
Top = 1080
Width = 375
End
Begin VB.CommandButton cmdKey
Appearance = 0 'Flat
Caption = "<"
Height = 375
Index = 11
Left = 360
Style = 1 'Graphical
TabIndex = 4
TabStop = 0 'False
Top = 1080
Width = 375
End
Begin VB.CommandButton cmdKey
Appearance = 0 'Flat
Caption = "En"
Height = 375
Index = 12
Left = 1080
Style = 1 'Graphical
TabIndex = 3
TabStop = 0 'False
Top = 0
Width = 375
End
Begin VB.CommandButton cmdKey
Appearance = 0 'Flat
Caption = "C"
Height = 375
Index = 13
Left = 1080
Style = 1 'Graphical
TabIndex = 2
TabStop = 0 'False
Top = 360
Width = 375
End
Begin VB.CommandButton cmdKey
Appearance = 0 'Flat
Caption = "L"
Height = 375
Index = 14
Left = 1080
Style = 1 'Graphical
TabIndex = 1
TabStop = 0 'False
Top = 720
Width = 375
End
Begin VB.CommandButton cmdKey
Appearance = 0 'Flat
Caption = "S"
Height = 375
Index = 15
Left = 1080
Style = 1 'Graphical
TabIndex = 0
TabStop = 0 'False
Top = 1080
Width = 375
End
Begin VB.Timer timerKey
Left = 240
Top = 1680
End
End
Attribute VB_Name = "frmKeyboard"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim key_timer As Integer
Dim key_index As Integer
Dim color As Long
Const key_1 As Integer = 7
Const key_2 As Integer = 10
Private Sub cmdKey_Click(Index As Integer)
cmd.SetFocus
End Sub
Private Sub Form_Load()
timerKey.Interval = 100
timerKey.Enabled = False
color = cmdKey(0).BackColor
End Sub
'发送键值
Private Sub ComSendKey(ti As enum_ComSendType, v1 As Integer)
cmdKey(key_index).BackColor = vbRed
Call ComSendAnalize(ti, v1, 0)
End Sub
'按下
Private Sub cmdKey_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
key_index = Index
Call ComSendKey(SendIs_SerialKey, Index)
timerKey.Enabled = True
key_timer = 0
End Sub
'松开
Private Sub cmdKey_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
timerKey.Enabled = False
cmdKey(key_index).BackColor = color
End Sub
Private Sub timerkey_timer() '定时
If key_timer >= key_2 Then
Call ComSendKey(SendIs_SerialKey, key_index + &H80)
key_timer = key_1
Else
cmdKey(key_index).BackColor = color
End If
key_timer = key_timer + 1
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -