denvar Posted May 23, 2008 Share Posted May 23, 2008 How can I monitor for input to begin (in a GuiCtrlCreateInput) Basically I am working on a voice input control, as the user speaks commands our voice recognition software types it into the input Then to avoid needing to say 'Ok' at the end of each command I want to try and use a timer so that once voice input has stopped (if timer of second or two runs out without any further input assume input is finished) So the only way I can think of doing this is to start a timer when input begins, and reset the timer whenever anything is typed into the input, if the timer reaches 0 the function that handles the commands is executed. Anyone know how to test if anything is being typed into an input? I was looking at _IsPressed however it only checks a specific key if I read it right. Or perhaps I am going the long way round and there is a simpler alternative? Thanks in advance Link to comment Share on other sites More sharing options...
Developers Jos Posted May 23, 2008 Developers Share Posted May 23, 2008 Why not do a GUICtrlRead() to check the content and see if anything was typed ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Valuater Posted May 23, 2008 Share Posted May 23, 2008 Maybe... #include <GUIConstantsEx.au3> Dim $begin = TimerInit(), $wait = 10 ; seconds GUICreate(" My GUI ", 320, 120) $file = GUICtrlCreateInput("Type info here", 10, 5, 300, 20) $label = GUICtrlCreateLabel("Spoken/typed text goes here", 10, 40, 300, 20) $btn = GUICtrlCreateButton("Ok", 40, 75, 60, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $btn Textit() Case $msg = $GUI_EVENT_CLOSE Exit EndSelect $dif = Int(TimerDiff($begin)/1000) If $dif > $wait Then Textit() WEnd Func Textit() $info = GUICtrlRead($file) GUICtrlSetData($label, $info) GUICtrlSetData($file, "") $begin = TimerInit() EndFunc 8) Link to comment Share on other sites More sharing options...
denvar Posted May 23, 2008 Author Share Posted May 23, 2008 Maybe... #include <GUIConstantsEx.au3> Dim $begin = TimerInit(), $wait = 10 ; seconds GUICreate(" My GUI ", 320, 120) $file = GUICtrlCreateInput("Type info here", 10, 5, 300, 20) $label = GUICtrlCreateLabel("Spoken/typed text goes here", 10, 40, 300, 20) $btn = GUICtrlCreateButton("Ok", 40, 75, 60, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $btn Textit() Case $msg = $GUI_EVENT_CLOSE Exit EndSelect $dif = Int(TimerDiff($begin)/1000) If $dif > $wait Then Textit() WEnd Func Textit() $info = GUICtrlRead($file) GUICtrlSetData($label, $info) GUICtrlSetData($file, "") $begin = TimerInit() EndFunc 8) Wouldnt this stil lrequire the user to say 'ok' at the end of each command? Im hoping to avoid for the need to say/click on 'ok' and to simply check for a pause in input then call another function Link to comment Share on other sites More sharing options...
Valuater Posted May 23, 2008 Share Posted May 23, 2008 Wouldnt this stil lrequire the user to say 'ok' at the end of each command?No, Its on a timer... did you test it???8) Link to comment Share on other sites More sharing options...
denvar Posted May 23, 2008 Author Share Posted May 23, 2008 Lol my bad, that reply was meant for someone who pm'ed me, and I sent him my reply to you Anyway thanks for the code, certainly got me close to what I was aiming for, any idea how I can only start the timer when input begins (so that it's not working away when idle) and also is there an easy way to reset the timer every time a character is typed (so rather then giving the user 10 seconds to enter input, it allows 10 seconds after the user stops input) Thanks for the help so far guys Link to comment Share on other sites More sharing options...
Valuater Posted May 23, 2008 Share Posted May 23, 2008 ... expandcollapse popup#include <GUIConstantsEx.au3> Dim $begin = TimerInit(), $Length_hold = 0, $wait = 10 ; seconds GUICreate(" My GUI ", 320, 120) $file = GUICtrlCreateInput("", 10, 5, 300, 20) $label = GUICtrlCreateLabel("Spoken/typed text goes here", 10, 40, 300, 20) $btn = GUICtrlCreateButton("Ok", 40, 75, 60, 20) $clock = GUICtrlCreateLabel("", 10, 100, 20, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $btn Textit() Case $msg = $GUI_EVENT_CLOSE Exit EndSelect $Length = StringLen(GUICtrlRead($file)) $dif = Int(TimerDiff($begin)/1000) GUICtrlSetData($clock, $dif) If $dif > $wait Then If $Length > $Length_hold Then $Length_hold = $Length $begin = TimerInit() Else $Length_hold = 0 Textit() EndIf EndIf WEnd Func Textit() $info = GUICtrlRead($file) GUICtrlSetData($label, $info) GUICtrlSetData($file, "") $begin = TimerInit() EndFunc 8) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now