Below is an advanced script that holds down the Windows key, try it with Windows 7 e.g. "Windows key down" and then for example try commands like "press tab". This will display all your applications currently running and if you continue with "press tab" it will move through the tasks.
' Script by 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 Windows key Const VK_LWIN = 91 Sub Main ' hold Windows key down keybd_event(VK_LWIN,0,0,0) End Sub
To release the Windows key e.g. "Windows key up" it is an identical script except you change the one line to:
keybd_event(VK_LWIN,0,2,0)
The third parameter (0 or 2) dictates whether the keyboard event is a key down command or a key up (release key) command. The principle used above can obviously be used to hold down any keys and the scripts can be adapted to display tasks from the taskbar directly etc.
Lindsay: Interesting input, thanks a lot! Just one stupid question from a non-script-kid: What if the command browser returns a syntax error (undeterminated block statement) and highlights the Declare... Line and the following line - which it does in my case after copying your script into the advanced scripting window
Regards, Marius
Dragon NaturallySpeaking 11.5 Legal Windows 7 Prof. 64-Bit, Office 2010, Jarte Plus Philips SpeechMike II Pro Plus, SpeechMike III, SpeechMike Air, PDCC 2.8 Intel Core2 Quad Q9550, 2,83 GHz, 2x6MB L-2, 8 GB RAM
wenn das Skript wie unten aussieht, wird damit die Win-Taste runter gedrückt:
Mit gedrückter Win-Taste können dann weitere Tasten per Sprachbefehl gedrückt werden, z.B. "drück r", um den "Ausführen"-Dialog zu starten, oder Cursortasten. Wie Lindsay schon erklärt hat, muss die letzte Code-Zeile umgeschrieben werden, um analog einen Befehl wie "Win-Taste rauf" zu definieren.
Dass die Win-Taste und prinzipiell jede beliebige Taste mittels Zugriff über die Windows API und per Sprachbefehl angesteuert werden kann, ist übrigens Lindsay's Entdeckung. Er ist eben ein Programmierer.
Danke dafür an den Author!
Rüdiger
_______________________________________
Dragon Professional 16 auf Windows 10 Pro und Windows 11 SpeechMike Premium (LFH3500); Office 2019 Pro + Office 365 (monatliches Abo) HP ZBook Fury 17 G8 - i7-11800H - 24 MB SmartCache - 32 GB RAM - 1 TB SSD
Yes Rüdiger has showed how it should be displayed in the advance script dialogue. Once you have added this, and and called it e.g. window key down. Then try these voice commands for example:
press tab press tab ... (this is just an example of scrolling through the tasks)
with Windows 7 the Windows key is now very useful, check the following link for other things you can do holding down the Windows key and pushing the Windows key and combinations. If you need further information on how to script windows key with combinations then let me know.
thanks a lot again. I truly like the new functions of the Win-Keys in Win 7, but, being dumb when it comes to coding, I used AutoHotkey to generate the necessary keystrokes and then DNS again to call the AutoHotkey-scripts. Your approach is, needless to say, far more elegant, but would have been totally out of reach for me had it not been for your kind knowledge-sharing (and Rüdigers's help).
Your invention even provides a spin-off solution for another problem of mine, namely, calling the NatSpeak-feature of "voice notations" in Word by voice command. As you will certainly know, you need to keep the Escape-Key pressed while dictating into a word window, which can by achieved by voice command like that:
Command name "begin voice notation" (in German: "Sprachkommentar beginnen")
' Big Thankyou to 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 Sub Main ' hold Escape key down keybd_event(27,0,0,0) End Sub
By a corresponding command "end voice notation" you can do what it says
' Big Thankyou to 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 Sub Main ' release Escape key keybd_event(27,0,2,0) End Sub
The possibilities are endless...
Marius
Dragon NaturallySpeaking 11.5 Legal Windows 7 Prof. 64-Bit, Office 2010, Jarte Plus Philips SpeechMike II Pro Plus, SpeechMike III, SpeechMike Air, PDCC 2.8 Intel Core2 Quad Q9550, 2,83 GHz, 2x6MB L-2, 8 GB RAM
Glad you have found the technique useful, like you say the possibilities are endless for holding down various keys. The other very useful one is holding down the control key.
... even I (vB-illiterate) was able to reckon how to integrate more keys into a single script so you can say a single voice command e.g. to snap-in the active window on the left half of the screen (using Windows 7, of course - whereas the more sophisticated scripts you provided in an earlier thread work independently from the Windows 7-snap-in-feature and offer a greater variety of positions) :
' Original Script by Lindsay Adam 2010 www.pcbyvoice.com , altered by MR, hope you don't mind ' 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 Windows key Const VK_LWIN = 91 ' Add-on by MR: declare constant for left arrow key Const VK_LEFT = &H25 Sub Main ' hold Windows key down keybd_event(VK_LWIN,0,0,0) ' Add-on: first press, then release left arrow key keybd_event(VK_LEFT,0,0,0) keybd_event(VK_LEFT,0,2,0) ' release Windows key keybd_event(VK_LWIN,0,2,0) End Sub
.... makes me feel like Jean-Luc Picard, although the computer still keeps me waiting for my Earl Grey
Marius
Dragon NaturallySpeaking 11.5 Legal Windows 7 Prof. 64-Bit, Office 2010, Jarte Plus Philips SpeechMike II Pro Plus, SpeechMike III, SpeechMike Air, PDCC 2.8 Intel Core2 Quad Q9550, 2,83 GHz, 2x6MB L-2, 8 GB RAM
Hallo zusammen! Bei mir funktioniert das runterdrücken von Tasten irgendwie nicht. Habe schon verschiedene Tasten ausprobiert, jedes Mal wird die Taste nur genau einmal gedrückt, aber nicht gehalten. Als Beispiel habe ich hier ein Skript eingefügt, das über Windows- Taste+d den Desktop anzeigen soll.(ich weiß, dafür gibt es auch einen Dragon-Befehl, aber das soll ja nur ein Beispiel sein.) 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 Windows key Const VK_LWIN = 91 Sub Main ' hold Windows key down keybd_event(VK_LWIN,0,0,0) SendKeys"d" keybd_event(VK_LWIN,0,2,0) End Sub
bei Ausführung dieses Skripts wird aber nicht der Desktop angezeigt, sondern lediglich das Startmenü. Die Windows-Taste wird also nur einmal kurz angedrückt und nicht gehalten. Was mache ich da falsch?die Tastendrück-Befehle sind nämlich echt praktisch, ich könnte die an so vielen Stellen brauchen, wenn sie funktionieren würden:-) vielen Dank schon mal!
Hallo zusammen! Vielen Dank nochmal für eure Hilfe! Heute habe ich das in der Arbeit ausprobiert, aber leider ohne Erfolg. Sowohl SendSystemKeys, als auch SendDragonKeys hat nicht funktioniert:-( Hier ist mein Beispielskript: 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
Const VK_SHIFT = 16 Sub Main
diramt = ListVar1 ' this is the unit number of {arrow} movements sndkeystr$ = "{Down}" keybd_event(VK_SHIFT,0,0,0) For i = 1 To diramt
SendDragonKeys "{Down}"
Next i ' press "{arrow}" key(s) "diramt" times Wait 0.5 keybd_event(VK_SHIFT,0,2,0)
End Sub
das müsste doch eigentlich funktionieren, oder? Die Pfeiltasten werden nach unten gedrückt, das klappt soweit. Aber die Shift-Taste wird nicht gehalten. Ich weiß, es gibt diesen Befehl auch bei Dragon, aber da funktioniert er nur für circa 20 Zeilen. Wenn ich zum Beispiel sage" 71 Zeilen nach unten markieren", markiert er mir nur immer circa 19 Zeilen. Drum wollte ich mir einen eigenen Befehl mit einer Variablen schreiben. Ich muss nämlich zurzeit ziemlich viel markieren und kopieren, und mit den Befehlen von Dragon klappt es nur sehr schlecht. Wäre total nett, wenn mir jemand weiterhelfen könnte!