KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Problem with the heardword command
Topic Summary:
Created On: 05/25/2022 08:12 AM
Status: Post and Reply
Linear : Threading : Single : Branch
 Problem with the heardword command   - wheels496 - 05/25/2022 08:12 AM  
 Problem with the heardword command   - GarethR - 05/25/2022 12:42 PM  
 Problem with the heardword command   - wheels496 - 05/25/2022 02:54 PM  
 Problem with the heardword command   - wheels496 - 06/08/2022 05:46 AM  
 Problem with the heardword command   - Edgar - 06/08/2022 10:14 AM  
 Problem with the heardword command   - wheels496 - 06/08/2022 10:44 AM  
 Problem with the heardword command   - Alan Cantor - 06/08/2022 12:25 PM  
 Problem with the heardword command   - wheels496 - 06/08/2022 02:56 PM  
 Problem with the heardword command   - Alan Cantor - 06/08/2022 07:43 PM  
 Problem with the heardword command   - wheels496 - 06/09/2022 05:14 AM  
 Problem with the heardword command   - Alan Cantor - 06/09/2022 07:19 AM  
 Problem with the heardword command   - wheels496 - 06/09/2022 07:30 AM  
 Problem with the heardword command   - Alan Cantor - 06/09/2022 12:17 PM  
 Problem with the heardword command   - R. Wilke - 06/09/2022 02:14 PM  
 Problem with the heardword command   - wheels496 - 06/15/2022 04:27 AM  
 Problem with the heardword command   - Mav - 06/15/2022 06:19 AM  
 Problem with the heardword command   - wheels496 - 06/15/2022 07:02 AM  
 Problem with the heardword command   - Mav - 06/15/2022 09:29 AM  
 Problem with the heardword command   - Alan Cantor - 06/15/2022 09:25 AM  
Keyword
 05/25/2022 08:12 AM
User is offline View Users Profile Print this message


wheels496
Advanced Member

Posts: 180
Joined: 10/01/2008

Hello

I am trouble using a command, within another command.

Let me explain…

I have a command [developer password]. The script has one line, sendDragonkeys "***". (SendDragonkeys because sendkeys do not work, in this context, in a remote desktop).

This morning I have managed to create a command, which will run an application as a different user. The last thing this command needs to do is to enter my developer credentials (user name and password).

I could easily end this command with SendKeys " my password". However, that means every six weeks, when I have to change this password, I would then have two commands (and possibly more in the future), to update.

Alternatively, if I could use the head word command, then I only have two update the password once.

Any ideas?



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

DPI 15.6.1

 05/25/2022 12:42 PM
User is offline View Users Profile Print this message

Author Icon
GarethR
Junior Member

Posts: 21
Joined: 05/27/2021

HeardWord "developer", "password"
OR
EngineControl.RecognitionMimic("developer password")

Personally I prefer the second these days.

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

DPI 15.61 | Plantronics D100 | Windows 10 Home | Intel(R) Core(TM) i5-10210U CPU 1.60GHz

"Confidence isn't walking into a room thinking you are better than everyone; it's walking in not having to compare yourself at all."

 05/25/2022 02:54 PM
User is offline View Users Profile Print this message


wheels496
Advanced Member

Posts: 180
Joined: 10/01/2008

Thanks for that. I am actually on leave now, so will not be on that PC for about 11 days.

Gareth I tried your 1st suggestion and that's the problem-for some reason it did not work. When I'm back at work I will try and remember to try out your 2nd option.

Thanks

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

DPI 15.6.1

 06/08/2022 05:46 AM
User is offline View Users Profile Print this message


wheels496
Advanced Member

Posts: 180
Joined: 10/01/2008

The engine control command works but it causes problems... At the end of this message I have pasted the contents of my script. In summary, it does the following:-
click start menu and find the program I am looking for
opens the file location for the shortcut
hold down the shift key and right click
run as different user
enter my credentials

For my password, I am using the RecognitionMimic command but that appears to mess up the surrounding SendKeys commands. For example, if I end the script with the recognitionmimic command, I can let the command run and then say "Press Enter" to submit my credentials. However, if I include that as a SendKeys command, I end up with the password, in the username box. It's as if the recognitionmimic command alters the logical flow.

Any ideas?

Thanks

'#Language "WWB-COM"

Option Explicit

' Script Lindsay Adam 2010 www.pcbyvoice.com
' Declare keyboard events Windows API function
Declare Function keybd_event Lib "user32.dll" (ByVal vKey As _
Long, bScan As Long, ByVal Flag As Long, ByVal exInfo As Long) As Long
' declare virtual key constant for the left Windows key,
' control key, shift key and alt key
Const VK_LWIN = &h5B
Const VK_CTRL = &h11
Const VK_SHIFT = &h10
Const VK_ALT = &h12

Sub Main
SendKeys "^{escape}"
Wait 0.2
SendKeys "management studio"
Wait 0.2
SendKeys "+{F10}"
Wait 0.2
SendKeys "{Down}{Down}{Enter}"
Wait 0.2
SendKeys "+{Tab}"
Wait 0.2
keybd_event(VK_SHIFT,0,0,0)
Wait 0.2
SendKeys "+{F10}"
Wait 0.2
'SendDragonKeys "{Shift+F10}"
Wait 0.2
keybd_event(VK_SHIFT,0,2,0)
Wait 0.2
SendKeys "f"
Wait 0.2
SendKeys "***{Tab}"
Wait 0.2
EngineControl.RecognitionMimic("developer password")
Wait 0.2


'SendKeys "{Enter}"


End Sub



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

DPI 15.6.1

 06/08/2022 10:14 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1293
Joined: 04/03/2009

Two thoughts - you need to use the "SendKeys wait" version of the command:
SendKeys "", 1
otherwise your script goes on to the next statement before SendKeys finishes its work.
You are probably right that your logic flow is not actually equal to your statement flow. One thing that I have found is that the delay after (generally) anything involving a combination of text and speech (TTSPlayString, RecognitionMimic, HeardWord etc.) must be a bit longer than the time that it takes to actually physically utter the phrase. "Developer password" takes at least 1 second to utter so the delay after it should be "Wait 1".

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

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Office 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card with 3 1920x1080 monitors

 06/08/2022 10:44 AM
User is offline View Users Profile Print this message


wheels496
Advanced Member

Posts: 180
Joined: 10/01/2008

Thanks Edgar but unfortunately I have already tried both suggestions-I had a two second wait after the engine control command and yes I also tried the additional parameter on SendKeys.

Not quite ready to give up but the fallback position is that I use SendKeys to type the password-meaning every six weeks, when I have to change the password, I need to update every macro with that password.

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

DPI 15.6.1

 06/08/2022 12:25 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4404
Joined: 12/08/2007


hold down the shift key and right click

...

keybd_event(VK_SHIFT,0,0,0)
Wait 0.2
SendKeys "+{F10}"




I'm a bit suspicious about this. The Shift key is held down, but then the script outputs the keyboard equivalent way of right clicking, which is Shift + F10. Not sure this will work.

Maybe this, which doesn't involve the Shift key to achieve a right click?



keybd_event(VK_SHIFT,0,0,0)
Wait 0.2
SendKeys {APPS}


 06/08/2022 02:56 PM
User is offline View Users Profile Print this message


wheels496
Advanced Member

Posts: 180
Joined: 10/01/2008

The shift right click does actually work. The only part that fails is the final press enter! Personally I think the SendKeys and the recognition engine commands, might operate on different threads? As I type this I am wondering whether it's worth changing all the SendKeys recognition mimic?

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

DPI 15.6.1

 06/08/2022 07:43 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4404
Joined: 12/08/2007

When I have combined HeardWord and non-HeardWord instructions in Dragon commands, the interactions have been quite mysterious!

I wonder whether this might work:

EngineControl.RecognitionMimic("developer password")
Wait 0.2 [or longer]
EngineControl.RecognitionMimic("press Enter") [or "new line"] [I don't remember if "Enter" must be uppercase or lowercase.]
 06/09/2022 05:14 AM
User is offline View Users Profile Print this message


wheels496
Advanced Member

Posts: 180
Joined: 10/01/2008

Alan thanks for that idea-I now have it working with the following commands:-
EngineControl.RecognitionMimic("developer password")
Wait 0.2
EngineControl.RecognitionMimic("press enter")
EngineControl.RecognitionMimic("close window")

The last command, which I was unsure it would work, but it does, closes the Windows Explorer that the command opened to do the run as different user command.

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

DPI 15.6.1

 06/09/2022 07:19 AM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4404
Joined: 12/08/2007

Good to know!

Now that you've ironed out that problem, will your macro run reliably if you remove the "wait" instructions, except to wait for a menu to appear?

...

keybd_event(VK_SHIFT,0,0,0)
' Wait 0.2 ' [We're not waiting for a menu to appear]

SendKeys "+{F10}"
Wait 0.2 ' [Wait for a menu to appear]

keybd_event(VK_SHIFT,0,2,0)
' Wait 0.2 ' [We're not waiting for a menu to appear]

...
 06/09/2022 07:30 AM
User is offline View Users Profile Print this message


wheels496
Advanced Member

Posts: 180
Joined: 10/01/2008

I was able to remove the wait, after releasing the shift key. However when I removed the wait, after pressing the shift key-it messed everything up!

I should have added that between the last SendKeys and the first recognition mimic,I needed to increase the wait to 0.5,from 0.2,for it to work.



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

DPI 15.6.1



 06/09/2022 12:17 PM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4404
Joined: 12/08/2007

I aim to get rid of wait statements. It's an element of my scripting aesthetic.

But sometimes delays are unavoidable, and the shortest possible delay may not become clear until a macro has been used and tweaked over days, weeks, or months. Even more so when developing Dragon scripts for web-based applications. The internet is a very effective bottleneck!



 06/09/2022 02:14 PM
User is offline View Users Profile Print this message

Author Icon
R. Wilke
Top-Tier Member

Posts: 7921
Joined: 03/04/2007

It's an element of my scripting aesthetic.


Ha, that is a good joke actually. By any means, scripting has never been meant seriously, and to that end, there is no such thing as an "aesthetic" as regards scripting.

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



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

DragonCapture KB Download (Latest)
DragonCapture Homepage

 06/15/2022 04:27 AM
User is offline View Users Profile Print this message


wheels496
Advanced Member

Posts: 180
Joined: 10/01/2008

Okay can anybody help me explain or solve the strange behaviour? So as I mentioned in my last post my macro was working, well until Monday afternoon.

The issue now is the first couple of commands:-
SendKeys "^{escape}"
Wait 0.2
SendKeys "management studio"

Now before Monday afternoon, this would highlight the program "management studio" (so I could open file location and then run the shortcut as a different user). Then, after I reboot on Monday afternoon, my PC now shows web results, instead of application results? Initially I wondered if my organisation had implemented a change in policy, which is causing this behaviour but none of my colleagues are experiencing this.

Worse still, if I type "management studio" into the search box, it works (although when I type the "d" it does temporarily switch to web results) but when Dragon types "management studio" it gets web results first!

I did google it and found a fix but it only resolved the problem for one minute and then reverted back to the behaviour which I do not want.

Any ideas?

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

DPI 15.6.1

 06/15/2022 06:19 AM
User is offline View Users Profile Print this message

Author Icon
Mav
Top-Tier Member

Posts: 567
Joined: 10/02/2008

I think it would be more robust not to rely on Windows choosing between web search and locally installed applications.

If you want a voice command to start an application, you can use the WScript.Shell object for this:

Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "cmd.exe"

In case the executable is not found, you have to add its directory to your PATH (or give the full path and not just the executable).

 

hth

mav

 

 06/15/2022 07:02 AM
User is offline View Users Profile Print this message


wheels496
Advanced Member

Posts: 180
Joined: 10/01/2008

Remember though, the whole point of this is that I need to execute the applications as a different user.

I am currently looking at whether this can be done using shell.

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

DPI 15.6.1

 06/15/2022 09:29 AM
User is offline View Users Profile Print this message

Author Icon
Mav
Top-Tier Member

Posts: 567
Joined: 10/02/2008

You can execute a program as a different user using "runas" and if you specify the /savecred parameter you only need to enter the password during the very first run.

 

hth

mav

 06/15/2022 09:25 AM
User is offline View Users Profile Print this message


Alan Cantor
Top-Tier Member

Posts: 4404
Joined: 12/08/2007

Try substituting the executable for "management studio":

SendKeys "^{escape}"
Wait 0.2
SendKeys "Ssms.exe"

Might this work?

ShellExecute "ssms.exe"
KnowBrainer Speech Recognition » Dragon Speech Recognition » Problem with the heardword command

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

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