KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: wait time in script seems executed at the wrong time
Topic Summary:
Created On: 09/08/2020 01:23 AM
Status: Post and Reply
Linear : Threading : Single : Branch
 wait time in script seems executed at the wrong time   - Anandits - 09/08/2020 01:23 AM  
 wait time in script seems executed at the wrong time   - dicdoc - 09/08/2020 05:33 AM  
 wait time in script seems executed at the wrong time   - Lunis Orcutt - 09/08/2020 04:41 PM  
 wait time in script seems executed at the wrong time   - Anandits - 09/08/2020 11:18 PM  
 wait time in script seems executed at the wrong time   - R. Wilke - 09/09/2020 01:56 AM  
 wait time in script seems executed at the wrong time   - Anandits - 09/09/2020 11:20 AM  
 wait time in script seems executed at the wrong time   - Lunis Orcutt - 09/09/2020 03:24 PM  
Keyword
 09/08/2020 01:23 AM
User is offline View Users Profile Print this message

Author Icon
Anandits
Senior Member

Posts: 115
Joined: 03/25/2019

I have a script in a certain application that goes like this: 

 

Sub Main
SendKeys "%e"
SendKeys "{Right}"
SendKeys "{Down}{Down}"
SendKeys "{Enter}"
HeardWord "Open Google Translate"
SendKeys "^v"
End Sub

The 'paste' at the end never works, so I have tried to add a wait time before that to give Google translate a chance to load.

Because that didn't seem to help, I kept increasing the wait time.
But what I noticed was that the wait time was executed at the beginning of the script instead of at the right place. Rather than opening Google translate and then waiting, the script would wait, and then open Google translate.
I've timed this and it was really obvious. If the wait time was five, then it would take five seconds before Google translate opened. If there was no wait time, then Google translate was  opened immediately.

And still, nothing got pasted.

I had noticed exactly the same thing with another command in which I added the wait time.

What am I doing wrong, and how can I get the script to wait at the right time?

 09/08/2020 05:33 AM
User is offline View Users Profile Print this message

Author Icon
dicdoc
Top-Tier Member

Posts: 268
Joined: 07/31/2014

I had a similar problem in another context in outlook message:

- calling a Dragon boiler plate

- sending a series of key press to select dragon field

- pasting a variable in keyboard in the selescte field

with waits in between, but it would alway end the pasting occured before the wait. So I did like this, may it helps you :

En Sub Main

Dim WaitSend1 as Double, DateSimple, DateDay as String

Dim engine As New DgnEngineControl

 

WaitSend1 = 0.4

DateSimple = Clipboard

DateDay = Format (DateSimple, "dddd dd.mm.yyyy hh:mm")

Clipboard DateDay

sendkeys "^{home}", 1

wait .3

 

 

engine.Register

engine.RecognitionMimic("my boiler  plate")

engine.UnRegister(False)

 

'wait 1 ' with recognition mimic I could delet wait times between each phase

 

 

engine.Register

engine.RecognitionMimic("previous variable")

engine.UnRegister(False)

 

' with recognition mimic I could delet wait times between each phase

 

engine.Register

engine.RecognitionMimic("paste this") ' instead of sendkleys "^v",1

engine.UnRegister(False)

 

Set engine = Nothing

 



-------------------------

Memory: 16GB Microphone Brand and Model: LFH 4000 & Flexy Mike  Operating System: win 10, latest update; Surface Book 2, Processor (CPU) Type & Speed: I7 8650 Soundcard Brand and Model: none Speech Software: Dragon Medical Practice Edition, french version: 4.2 Using KnowBrainer?:Yes

 09/08/2020 04:41 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 37985
Joined: 10/01/2006

We prefer a short wait time between movements but if you don't need wait times, you can string all of your SendKeys together in a single line and double up on keys. Also note that you need to surround every word in HeardWord scripts with quotes and separate each word with a comma. You can only get away with the way you wrote your original HeardWord script in KnowBrainer (because it's smarter). You might try the following:


 

Sub Main
SendKeys "%e{Right}{Down 2}{Enter}"
Wait 0.2
HeardWord "Open","Google","Translate"
End Sub


or  (our preference)


Sub Main
SendKeys "%e"
Wait 0.1
SendKeys "{Right}{Down 2}{Enter}"
Wait 0.2
HeardWord "Open","Google","Translate"

End Sub



-------------------------

Forum Mission Statement
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ext 1



 09/08/2020 11:18 PM
User is offline View Users Profile Print this message

Author Icon
Anandits
Senior Member

Posts: 115
Joined: 03/25/2019

Just to clarify, I made the script in KnowBrainer.


Lunis, my script is working perfectly fine up to opening Google Translate. My issue is that once it is open I want to paste what is in the clipboard. But the "paste" should not be executed until Google translate is open. You would assume that adding a wait time after the "HeardWord Open Google Translate" will take care of that, but it doesn't seem to be the case.

Maybe I am misunderstanding something?
 09/09/2020 01:56 AM
User is offline View Users Profile Print this message

Author Icon
R. Wilke
Top-Tier Member

Posts: 7227
Joined: 03/04/2007

Wait times in scripting are hit or miss, and keep in mind that scripting instructions using SendKeys may be exeuted asynchronously. You can attempt to avoid this by rewriting them and appending ",1" (without the quotes), as in:

SendKeys "%e",1

That should make them wait and not move on to the next instruction until the current one is sent. Do note, though, that "sent" doesn't necessarily equate to "executed".



-------------------------



No need to buy if all you want to do is try ...

DragonCapture KB Download (Latest)
DragonCapture Homepage

 09/09/2020 11:20 AM
User is offline View Users Profile Print this message

Author Icon
Anandits
Senior Member

Posts: 115
Joined: 03/25/2019

It must be something within KnowBrainer, I could create the script in Dragon Advanced Scripting, and there the waiting time worked out at the right place.
 09/09/2020 03:24 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 37985
Joined: 10/01/2006

Consider creating all of your personal commands in Dragon until KnowBrainer 2021 is released. This will make it considerably easier to to overwrite your current KnowBrainer collection when we release new Builds. Note that VerbalBasic II now supports Dragon; not just KnowBrainer. Unfortunately, Dragon DPI 15.3 command deployment can be somewhat slow at the moment but the current sluggish behavior will be taken care of when Nuance releases DPI 15.6. However, if you can't wait... Support@KnowBrainer.com



-------------------------

Forum Mission Statement
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ext 1

Statistics
31789 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 3 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 739 guests browsing this forum, which makes a total of 742 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2020 FuseTalk™ Inc. All rights reserved.