Jump to content

TEst for input to begin


Recommended Posts

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

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)

NEWHeader1.png

Link to comment
Share on other sites

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

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

...

#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)

NEWHeader1.png

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...