Tuesday, June 24, 2008
Voice controlled Mouse
Main title Name: “Voice Interface”
Project title Name: “Voice controlled Mouse”
Developer: Md. Redwanur Rahman
Location: Dhaka, Bangladesh.
Date: 15 September, 2007
I am here to share knowledge with other. I am writing about voice interface project. The people who are computer engineer will get help from this project.
Aim of this project:
Using your voice you can control your mouse
Code Details
‘Voice Command Form code……………………………
‘Put this code in Voice command Form that named Main_1.
Private Const VK_Return = &HD
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Sub Form_Load()
Form1.Show
Dim FileN As String
FileN = App.Path & "\command.txt"
SR.Deactivate
SR.GrammarFromFile FileN
SR.Activate
SR.AutoGain = 99
CMD_List
End Sub
Private Sub SR_PhraseFinish(ByVal flags As Long, ByVal beginhi As Long, ByVal beginlo As Long, ByVal endhi As Long, ByVal endlo As Long, ByVal Phrase As String, ByVal parsed As String, ByVal results As Long)
Debug.Print Phrase
If Trim(Phrase) = "" Then
Exit Sub
Else
Text2.Text = Trim(Phrase)
SelMSG (Phrase)
Process_Message (Trim(Phrase))
End If
End Sub
Function Process_Message(Msg As String)
Select Case (UCase(Msg))
Case ("UP")
Form1.Command2_Click
Case ("DOWN")
Form1.Command5_Click
Case ("LEFT")
Form1.Command4_Click
Case ("RIGHT")
Form1.Command1_Click
Case ("NORMAL")
Form1.Command3_Click
Case ("Click")
keybd_event VK_Return, 0, 0, 0
keybd_event VK_Return, 0, KEYEVENTF_KEYUP, 0
Case ("EXIT")
End
End Select
End Function
Function CMD_List()
Dim TxT As String, Temp As String
Open App.Path & "\commands.txt" For Input As #1
Do Until EOF(1)
Line Input #1, TxT
Temp = Left(TxT, 8)
If Temp = "S=" Then
TxT = Mid(TxT, 9, Len(TxT))
List1.AddItem TxT
End If
Loop
Close #1
End Function
Function SelMSG(Msg As String)
Dim Temp As String
Dim i As Integer
For i = 0 To List1.ListCount
Temp = List1.List(i)
If Trim(UCase(Temp)) = Trim(UCase(Msg)) Then
List1.ListIndex = i
Exit Function
End If
Next
End Function
‘Cursor controller Form code……..
‘Put this code in Cursor Form that named Form1.
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Dim X, Y As Integer
Dim goRight, goUp, goDown, goLeft As Boolean
Public Sub Command1_Click()
Timer1.Enabled = True
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
End Sub
Public Sub Command2_Click()
Timer2.Enabled = True
Timer1.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
End Sub
Public Sub Command3_Click()
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
End Sub
Public Sub Command4_Click()
Timer3.Enabled = True
Timer1.Enabled = False
Timer2.Enabled = False
Timer4.Enabled = False
End Sub
Public Sub Command5_Click()
Timer4.Enabled = True
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
End Sub
Private Sub Form_Load()
X = Form1.Width / 8 - 0.25
Text1.Text = X
Y = Form1.Height / 8
Text2.Text = Y
SetCursorPos X, Y
End Sub
Private Sub Timer1_Timer()
'If X <= 0 Then goLeft = True
'If goLeft Then
X = X + 1
Text1.Text = X
'End If
SetCursorPos X, Y
End Sub
Private Sub Timer2_Timer()
'If Y <= 0 Then goUp = False
'If goUp Then
Y = Y - 1
Text2.Text = Y
'End If
SetCursorPos X, Y
End Sub
Private Sub Timer3_Timer()
'If X >= 1024 Then goRight = True
'If goRight Then
X = X - 1
Text1.Text = X
'End If
SetCursorPos X, Y
End Sub
Private Sub Timer4_Timer()
'If Y >= 786 Then goDown = True
'If goDown Then
Y = Y + 1
Text2.Text = Y
'End If
SetCursorPos X, Y
End Sub
‘Command.txt file………… save as a text file and put in program root directory.
[Grammer]
Type=Cfg
[S]
S=Left
S=Right
S=Up
S=Down
S=Normal
S=Click
S=Exit
Download this Project: www.geocities.com/redu0007/Cnews
Conclusion:
I developed this software that published in Cnews in Bangladesh. I am regular writer of Cnews, Computer Jagat and Computer tomorrow that’s monthly computer journal of Bangladesh.
Subscribe to:
Posts (Atom)