![]() |
KnowBrainer Speech Recognition | ![]() |
Topic Title: Problem with the heardword command Topic Summary: Created On: 05/25/2022 08:12 AM Status: Post and Reply |
|
![]() |
![]() |
- wheels496 | - 05/25/2022 08:12 AM |
![]() |
![]() |
- GarethR | - 05/25/2022 12:42 PM |
![]() |
![]() |
- wheels496 | - 05/25/2022 02:54 PM |
![]() |
![]() |
- wheels496 | - 06/08/2022 05:46 AM |
![]() |
![]() |
- Edgar | - 06/08/2022 10:14 AM |
![]() |
![]() |
- wheels496 | - 06/08/2022 10:44 AM |
![]() |
![]() |
- Alan Cantor | - 06/08/2022 12:25 PM |
![]() |
![]() |
- wheels496 | - 06/08/2022 02:56 PM |
![]() |
![]() |
- Alan Cantor | - 06/08/2022 07:43 PM |
![]() |
![]() |
- wheels496 | - 06/09/2022 05:14 AM |
![]() |
![]() |
- Alan Cantor | - 06/09/2022 07:19 AM |
![]() |
![]() |
- wheels496 | - 06/09/2022 07:30 AM |
![]() |
![]() |
- Alan Cantor | - 06/09/2022 12:17 PM |
![]() |
![]() |
- R. Wilke | - 06/09/2022 02:14 PM |
![]() |
![]() |
- wheels496 | - 06/15/2022 04:27 AM |
![]() |
![]() |
- Mav | - 06/15/2022 06:19 AM |
![]() |
![]() |
- wheels496 | - 06/15/2022 07:02 AM |
![]() |
![]() |
- Mav | - 06/15/2022 09:29 AM |
![]() |
![]() |
- Alan Cantor | - 06/15/2022 09:25 AM |
![]() |
|
Hello 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). ------------------------- DPI 15.6.1 |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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} |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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.] |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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] ... |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
I aim to get rid of wait statements. It's an element of my scripting aesthetic. |
|
|
|
![]() |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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
|
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
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 |
|
|
|
![]() |
|
Try substituting the executable for "management studio":
SendKeys "^{escape}" Wait 0.2 SendKeys "Ssms.exe" Might this work? ShellExecute "ssms.exe" |
|
|
FuseTalk Standard Edition v4.0 - © 1999-2023 FuseTalk™ Inc. All rights reserved.