VERSION 5.00 Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX" Begin VB.Form Form1 BackColor = &H8000000C& Caption = "Serial Mouse Tester" ClientHeight = 6345 ClientLeft = 2265 ClientTop = 1920 ClientWidth = 6795 FillColor = &H000000FF& LinkTopic = "Form1" ScaleHeight = 423 ScaleMode = 3 'Pixel ScaleWidth = 453 Begin VB.PictureBox Picture1 Align = 1 'Align Top Height = 825 Left = 0 ScaleHeight = 765 ScaleWidth = 6735 TabIndex = 0 Top = 0 Width = 6795 Begin VB.CommandButton Command1 Caption = "Open" Height = 285 Left = 90 TabIndex = 3 Top = 90 Width = 870 End Begin VB.CommandButton Command2 Caption = "Close" Enabled = 0 'False Height = 285 Left = 90 TabIndex = 2 Top = 405 Width = 870 End Begin VB.TextBox Text1 Height = 285 Left = 1800 TabIndex = 1 Text = "1" Top = 360 Width = 285 End Begin VB.Label Label2 Caption = "COM" Height = 195 Left = 1395 TabIndex = 5 Top = 405 Width = 420 End Begin VB.Label Label1 Caption = "Mouse Located on:" Height = 195 Left = 1080 TabIndex = 4 Top = 90 Width = 1410 End End Begin MSCommLib.MSComm com Left = 270 Top = 1080 _ExtentX = 1005 _ExtentY = 1005 _Version = 393216 CommPort = 2 DTREnable = -1 'True InputLen = 1 RThreshold = 1 RTSEnable = -1 'True BaudRate = 1200 DataBits = 7 End Begin VB.Shape Shape1 FillStyle = 0 'Solid Height = 150 Left = 3375 Shape = 3 'Circle Top = 3420 Width = 150 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Dim buf(0 To 2) As Byte Dim ptr As Integer Dim running As Boolean Sub ReadData() Dim dy As Integer, dx As Integer Static rightdown As Boolean Static leftdown As Boolean Dim a As String a = com.Input If a <> "" Then buf(ptr) = Asc(a) If ptr = 0 Then If (buf(0) And 64) = 64 Then ptr = ptr + 1 Else ptr = ptr + 1 If ptr > 2 Then ptr = 0 dx = ((buf(0) And &H3) * 64) dx = dx + (buf(1) And &H3F) dy = ((buf(0) And &HC) * 16) dy = dy + (buf(2) And &H3F) If dx > 127 Then dx = dx - 256 If dy > 127 Then dy = dy - 256 If dx <> 0 Then Shape1.Left = Shape1.Left + dx If dy <> 0 Then Shape1.Top = Shape1.Top + dy If (buf(0) And &H30) = &H30 Then Shape1.FillColor = &HFF0000 ElseIf (buf(0) And &H20) = &H20 Then Shape1.FillColor = &HFF00& ElseIf (buf(0) And &H10) = &H10 Then Shape1.FillColor = &HFF& Else Shape1.FillColor = &H0& End If End If End If End If End Sub Private Sub com_OnComm() 'on comm ReadData End Sub Private Sub Command1_Click() ptr = 0 On Error Resume Next If running Then Exit Sub com.CommPort = Text1.Text com.PortOpen = True running = True Command1.Enabled = False Command2.Enabled = True End Sub Private Sub Command2_Click() On Error Resume Next com.PortOpen = False running = False Command1.Enabled = True Command2.Enabled = False End Sub Private Sub Form_Load() running = False End Sub Private Sub Form_Unload(Cancel As Integer) If running Then Command2_Click End Sub