'Created in Visual Basic 6.0 'FORM1.frm Function Playnumber(Number) Dim Playpath As String 'Play the right mediafile Playpath = Number 'See if the file exist If Dir(App.Path & "\Media\" + Playpath + ".mp3") <> "" Then 'Audiofile exist Playpath = App.Path + "\Media\" + Playpath Playpath = Playpath + ".mp3" WindowsMediaPlayer1.URL = Playpath WindowsMediaPlayer1.Controls.play Else 'Audiofile don't exist Timer1.Enabled = True End If End Function Function Add2List() Dim temp2 As String If List1.ListCount > 1000 Then List1.RemoveItem (0) End If List1.AddItem ("Nummer lagrade i minnet:") List1.Selected(List1.ListCount - 1) = True ' Skriver ut minnet Do If Left(MemInput, 1) = "A" Then temp2 = "" ElseIf Left(MemInput, 1) = "Z" Then If List1.ListCount > 1000 Then List1.RemoveItem (0) End If If temp2 = "10" Then temp2 = "Skyddat nummer" End If List1.AddItem (temp2) List1.Selected(List1.ListCount - 1) = True ElseIf Left(MemInput, 1) = "D" Then Exit Do ElseIf Len(MemInput) = 1 Then Exit Do Else temp2 = temp2 + Left(MemInput, 1) End If MemInput = Right(MemInput, Len(MemInput) - 1) Loop MemInput = "" SoundStat = "On" End Function Private Sub GoSystemTray() VBGTray.cbSize = Len(VBGTray) VBGTray.hwnd = Me.hwnd VBGTray.uId = vbNull VBGTray.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE VBGTray.ucallbackMessage = WM_MOUSEMOVE VBGTray.hIcon = Me.Icon ' 'tooltiptext VBGTray.szTip = Me.Caption & vbNullChar Call Shell_NotifyIcon(NIM_ADD, VBGTray) App.TaskVisible = False 'remove application from taskbar Me.Hide End Sub Private Sub aterstall_Click() Form1.Show End Sub Private Sub avsluta_Click() End End Sub Private Sub Command2_Click() SoundStat = "Off" ' Stänga av ljudet MSComm1.Output = "T" 'Tömma minnet End Sub Private Sub Command3_Click() MSComm1.PortOpen = False MSComm1.CommPort = (Combo1.ListIndex + 1) 'Changing Comport MSComm1.PortOpen = True Open (CommandPath + "\settings.ini") For Output As #1 ' Saving settings X = "COMP = " + Str(Combo1.ListIndex + 1) Print #1, X X = "VOLM = " + Str(HScroll1.Value) Print #1, X Close #1 Label5.Caption = "Ej ansluten" MSComm1.Output = "?" End Sub Private Sub Command1_Click() GoSystemTray End Sub Private Sub Command4_Click() Dim temp As String temp = Text1.Text Text2.Text = Text2.Text + temp If temp = "A" Then InCom = "" InState = "01" 'Normal number is incoming Exit Sub ElseIf temp = "S" Then InCom = "" InState = "10" ' Hidden number ElseIf temp = "Z" Then If (InState = "10") Then List1.AddItem ("Hidden number") 'Add hidden number to list Playnumber ("Hidden") Exit Sub End If InState = "00" 'Number is done List1.AddItem (InCom) 'Add the number to list Playnumber (InCom) 'Play the number Exit Sub End If If (InState = "01") Then ' If number is coming, add it to global variabel InCom = InCom + temp End If End Sub Private Sub Form_Load() InState = "00" ' Numberdetection system SoundStat = "On" 'Sound is on. Timeri = 0 'Wait variabel for timer CommandPath = App.Path Combo1.AddItem ("Com1") Combo1.AddItem ("Com2") Combo1.AddItem ("Com3") Combo1.AddItem ("Com4") 'Ladda ComPort Open (CommandPath + "\settings.ini") For Input As #1 ' Open file for input. Do While Not EOF(1) ' Loop until end of file. Input #1, ReadData ' Read data into two variables. 'Debug.Print ReadData ' Print data to Debug window. If Left(ReadData, 4) = "COMP" Then Combo1.ListIndex = Right(ReadData, 1) - 1 MSComm1.CommPort = Right(ReadData, 1) 'Sätter Comporten End If If Left(ReadData, 4) = "VOLM" Then WindowsMediaPlayer1.settings.volume = Right(ReadData, 3) HScroll1.Value = Right(ReadData, 3) End If Loop Close #1 ' Close file. 'Öppna port Dim Instring As String ' Use COM1. 'MSComm1.CommPort = 1 ' 9600 baud, no parity, 8 data, and 1 stop bit. MSComm1.settings = "9600,N,8,1" ' Tell the control to read entire buffer when Input ' is used. MSComm1.InputLen = 0 ' Open the port. MSComm1.PortOpen = True MSComm1.Output = "?" End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Static lngMsg As Long Static blnFlag As Boolean Dim result As Long lngMsg = X / Screen.TwipsPerPixelX If blnFlag = False Then blnFlag = True Select Case lngMsg ' 'doubleclick Case WM_LBUTTONDBLCLICK Me.Show ' 'right-click Case WM_RBUTTONUP result = SetForegroundWindow(Me.hwnd) Me.PopupMenu mnuSystemTray End Select blnFlag = False End If End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) VBGTray.cbSize = Len(VBGTray) VBGTray.hwnd = Me.hwnd VBGTray.uId = vbNull Call Shell_NotifyIcon(NIM_DELETE, VBGTray) End Sub Private Sub Form_Terminate() VBGTray.cbSize = Len(VBGTray) VBGTray.hwnd = Me.hwnd VBGTray.uId = vbNull Call Shell_NotifyIcon(NIM_DELETE, VBGTray) End Sub Private Sub Form_Unload(Cancel As Integer) MSComm1.PortOpen = False End Sub Private Sub HScroll1_Change() WindowsMediaPlayer1.settings.volume = HScroll1.Value End Sub Private Sub MSComm1_OnComm() Dim temp As String temp = MSComm1.Input Text2.Text = Text2.Text + temp If SoundStat = "Off" Then MemInput = MemInput + temp If Right(MemInput, 1) = "D" Then Add2List End If Exit Sub End If If temp = "A" Then InCom = "" InState = "01" 'Normal number is incoming Exit Sub ElseIf temp = "S" Then InCom = "" InState = "10" ' Hidden number ElseIf temp = "Z" Then If (InState = "10") Then 'Display the number If List1.ListCount > 1000 Then List1.RemoveItem (0) End If If SoundStat = "On" Then List1.AddItem (Date & " " & Time & ": Skyddat nummer") List1.Selected(List1.ListCount - 1) = True Playnumber ("Hidden") End If Command2.Enabled = False ' Prevent from empty mem Timer2.Enabled = True ' Confirm number Exit Sub End If InState = "00" 'Number is done If List1.ListCount > 1000 Then List1.RemoveItem (0) End If If SoundStat = "On" Then List1.AddItem (Date & " " & Time & ": " & InCom) List1.Selected(List1.ListCount - 1) = True Playnumber (InCom) End If Command2.Enabled = False ' Prevent from empty mem Timer2.Enabled = True ' Confirm number Exit Sub ElseIf temp = "D" Then ' Empty the memory is done SoundStat = "On" ElseIf temp = ">" Then ' Hello msg incoming If List1.ListCount > 1000 Then List1.RemoveItem (0) End If List1.AddItem (Date & " " & Time & ": Hello") List1.Selected(List1.ListCount - 1) = True ElseIf temp = "!" Then Label5.Caption = "Ansluten" End If If (InState = "01") Then ' If number is coming, add it to global variabel InCom = InCom + temp End If End Sub Private Sub Timer1_Timer() 'Audiofile exist Dim Playpath As String 'is it done? If WindowsMediaPlayer1.playState = 3 Then Exit Sub End If Playpath = App.Path + "\Media\" + Left(InCom, 1) + ".wav" WindowsMediaPlayer1.URL = Playpath WindowsMediaPlayer1.Controls.play InCom = Right(InCom, Len(InCom) - 1) 'Remove spoken number If InCom = "" Then Timer1.Enabled = False End If End Sub Private Sub Timer2_Timer() If Timeri = 0 Then Timeri = 1 Exit Sub Else Timeri = 0 MSComm1.Output = "U" 'Confirm that the number is recivied Command2.Enabled = True Timer2.Enabled = False End If End Sub 'Module1.bas Attribute VB_Name = "Module1" Global CommandPath As String Global InCom, InState As String Global SoundStat As String Global MemInput As String Global Timeri As Integer '**************************************************************** 'Windows API/Global Declarations for :Windows 95 System Tray '**************************************************************** Public Const WM_LBUTTONDBLCLICK = &H203 Public Const WM_RBUTTONUP = &H205 Public Const WM_MOUSEMOVE = &H200 Public Const NIM_ADD = &H0 Public Const NIM_MODIFY = &H1 Public Const NIM_DELETE = &H2 Public Const NIF_MESSAGE = &H1 Public Const NIF_ICON = &H2 Public Const NIF_TIP = &H4 Public Type NOTIFYICONDATA cbSize As Long hwnd As Long uId As Long uFlags As Long ucallbackMessage As Long hIcon As Long szTip As String * 64 End Type Public VBGTray As NOTIFYICONDATA Declare Function Shell_NotifyIcon Lib "shell32" Alias _ "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long