KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: command to move window to other screen
Topic Summary: need command help
Created On: 04/03/2018 12:10 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 command to move window to other screen   - davetreas - 04/03/2018 12:10 PM  
 command to move window to other screen   - Mphillipson - 04/03/2018 12:47 PM  
 command to move window to other screen   - davetreas - 04/03/2018 03:18 PM  
 command to move window to other screen   - Lunis Orcutt - 04/03/2018 04:13 PM  
 command to move window to other screen   - Mphillipson - 04/04/2018 09:25 AM  
 command to move window to other screen   - davetreas - 04/03/2018 09:08 PM  
 command to move window to other screen   - Edgar - 04/03/2018 10:19 PM  
 command to move window to other screen   - davetreas - 04/04/2018 12:59 AM  
 command to move window to other screen   - Mphillipson - 04/04/2018 09:49 AM  
 command to move window to other screen   - davetreas - 04/04/2018 10:38 AM  
 command to move window to other screen   - Edgar - 04/04/2018 11:43 AM  
 command to move window to other screen   - Mphillipson - 04/04/2018 12:45 PM  
 command to move window to other screen   - davetreas - 04/04/2018 04:49 PM  
 command to move window to other screen   - Edgar - 04/04/2018 05:21 PM  
 command to move window to other screen   - davetreas - 04/04/2018 09:21 PM  
 command to move window to other screen   - Edgar - 04/05/2018 11:33 AM  
 command to move window to other screen   - Lunis Orcutt - 04/05/2018 12:48 PM  
 command to move window to other screen   - MDH - 04/05/2018 02:11 PM  
 command to move window to other screen   - IceRafter - 11/22/2021 04:58 AM  
Keyword
 04/03/2018 12:10 PM
User is offline View Users Profile Print this message

Author Icon
davetreas
New Member

Posts: 7
Joined: 04/03/2018

Hi - if you have two monitors on your computer, the Windows keystroke to move a particular application from left monitor to the right monitor is {Windows + shift + right}.  This would be extremely helpful to do by voice. But I can't figure out how to script this (Advanced Scripting).  Windows key = {ctrl+esc}, but this does not work in combination with SHIFT and RIGHT (or left). Advanced scripting?  Shell script?  Other?  Thanks

 04/03/2018 12:47 PM
User is offline View Users Profile Print this message

Author Icon
Mphillipson
Top-Tier Member

Posts: 297
Joined: 09/22/2014

 04/03/2018 03:18 PM
User is offline View Users Profile Print this message

Author Icon
davetreas
New Member

Posts: 7
Joined: 04/03/2018

Hi - thanks -- how to import that as a command - do I copy a specific range of lines from your script into an advanced scripting window? Lines 17-35? Or do I need more than that?
 04/03/2018 04:13 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 40100
Joined: 10/01/2006

You would have to know how to edit an XML script which we can destroy your command file unless you are familiar with the process. We recommend copying the following KnowBrainer 2017 script, or something similar, as a Dragon Advanced-Scripting command. Note that you would also have to define the <Direction> and <1to1000> lists. It might be easier to just use KnowBrainer 2017. You'll find a 30 day trial in our signature tag. The following script should work in Dragon or KnowBrainer which utilize the same VB scripting language.

Sub Main
value = CInt (ListVar2)
If  value > 99 Then
For i = 1 To value/50
If ListVar1 = "Left" Then SendKeys"{Left 50}"
If ListVar1 = "Right" Then SendKeys"{Right 50}"
If ListVar1 = "Up" Then SendKeys"{Up 50}"
If ListVar1 = "Down" Then SendKeys"{Down 50}"
Next
Else
If ListVar1 = "Left" Then SendKeys "{Left "+ListVar2+"}"
If ListVar1 = "Right" Then SendKeys "{Right "+ListVar2+"}"
If ListVar1 = "Up" Then SendKeys "{Up "+ListVar2+"}"
If ListVar1 = "Down" Then SendKeys "{Down "+ListVar2+"}"
End If

End Sub




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

Change "No" to "Know" w/KnowBrainer 2020
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ex 1



 04/04/2018 09:25 AM
User is offline View Users Profile Print this message

Author Icon
Mphillipson
Top-Tier Member

Posts: 297
Joined: 09/22/2014

Information on how to import an XML file directly into the Command Browser:

 

Please click here



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

Thanks Mark


 


Dragon Professional Advanced Scripting/KnowBrainer Scripts
Video Examples of Coding by Voice

 04/03/2018 09:08 PM
User is offline View Users Profile Print this message

Author Icon
davetreas
New Member

Posts: 7
Joined: 04/03/2018

Thanks, but this does not appear to answer the question. The keystrokes in question, {Windows + shift + right/left} simply shunt the active window to the other monitor, instantly, and in its entirety. There is no need to specify a certain number of pixels or mouse movements. My simple question is how do we script {Windows + shift + right/left}

Thanks
 04/03/2018 10:19 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1284
Joined: 04/03/2009

SendKeys "+{WindowsHold}{Right}", 1

May not work on all OSes. {Left} for the other arrow key; try {Up} & {Down} if Windows thinks your monitors are stacked vertically <shrug>. Having the "secondary" monitor to the left also can cause confusion.



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

-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

 04/04/2018 12:59 AM
User is offline View Users Profile Print this message

Author Icon
davetreas
New Member

Posts: 7
Joined: 04/03/2018

How about:

SendKeys "+{WindowsHold}{Shift+Right}", 1"

(I don't have two monitors to test this on, but am trying to help someone who does.....)

Many Thx!
 04/04/2018 09:49 AM
User is offline View Users Profile Print this message

Author Icon
Mphillipson
Top-Tier Member

Posts: 297
Joined: 09/22/2014

I have created a new script for moving to the second monitor at the following link:

Click Here



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

Thanks Mark


 


Dragon Professional Advanced Scripting/KnowBrainer Scripts
Video Examples of Coding by Voice

 04/04/2018 10:38 AM
User is offline View Users Profile Print this message

Author Icon
davetreas
New Member

Posts: 7
Joined: 04/03/2018

Thanks.

Did file save as .xml, to local computer. File name was WindowsKeyDirection.xml.

On trying to import to Dragon Command Browser as XML file, got the following error:

Invalid MyCommands data encountered while parsing. A name contained an invalid character.
A name contained an invalid character.
 04/04/2018 11:43 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1284
Joined: 04/03/2009

If you're still struggling with XML this is what this looks like in text form:

 

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_LWIN = 91

Sub Main

keybd_event(VK_LWIN,0,0,0)

Dim stringDirection As String

Select Case UtilityProvider.ContextValue(0)

Case "left"

stringDirection="Left"

Case "right"

stringDirection="Right"

Case "down"

stringDirection="Down"

Case "up"

stringDirection="Up"

End Select

Wait 0.1

SendSystemKeys "{Shift+" & stringDirection  & "}"

Wait 0.1

keybd_event(VK_LWIN,0,2 ,0)

End Sub

 

Open your Command Editor (Dragon or KnowBrainer), name the command:

Move Window <Direction>

or anything else you choose as long as it contains a list with, at least, the four entries:

left

right

down

up

(you might very well already have an existing list which would be suitable otherwise, create a new list). Note, I'm pretty sure that the test is case-significant so make sure your list contains "left", "right" etc. or that you change the script to reflect the case of your list.

Make sure that the line "Declare Function…As Long" is all on one line (there's a special trick to split the line but it just makes for problems in the future). Make sure that both the "Declare Function" and "Const VK_LWIN = 91" lines are both above "Sub Main".

I couldn't get the above script to compile with KnowBrainer but it compiles just fine as a Dragon Advanced Script. Unfortunately, it doesn't seem to work on Windows 7. I will continue to rely on the script I wrote a while back which works reliably in Windows 7, 8 & 10.

 



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

-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

 04/04/2018 12:45 PM
User is offline View Users Profile Print this message

Author Icon
Mphillipson
Top-Tier Member

Posts: 297
Joined: 09/22/2014

This is what it should look like in advanced scripting:

Screenshot



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

Thanks Mark


 


Dragon Professional Advanced Scripting/KnowBrainer Scripts
Video Examples of Coding by Voice

 04/04/2018 04:49 PM
User is offline View Users Profile Print this message

Author Icon
davetreas
New Member

Posts: 7
Joined: 04/03/2018

Thanks - that worked - the solution from Mark,

Wondering if the simple one line command from Edgar is an alternate method --
he sent:
SendKeys "+{WindowsHold}{Right}", 1

It looked to me that it was lacking a left/right option, and I was unclear what the ",1" was doing outside the quotes. I asked if the following was what was meant:

SendKeys "+{WindowsHold}{Shift+Right}", 1"

Can try this one as well.....
 04/04/2018 05:21 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1284
Joined: 04/03/2009

Originally posted by: davetreas Thanks - that worked - the solution from Mark, Wondering if the simple one line command from Edgar is an alternate method -- he sent: SendKeys "+{WindowsHold}{Right}", 1 It looked to me that it was lacking a left/right option, and I was unclear what the ",1" was doing outside the quotes. I asked if the following was what was meant: SendKeys "+{WindowsHold}{Shift+Right}", 1" Can try this one as well.....

First, SendKeys has an optional parameter (that ", 1") is which I would recommend you get in the habit of using. Using that option tells SendKeys not to allow scripts to continue until the entire string is sent to the application. Otherwise, SendKeys can (sometimes slowly) send keystrokes to the application while the balance of the script's statements are executing.

The command as I wrote it would need to be part of a complete script which would need a list. The script would include some kind of a conditional statement based on ListVar1:
Move Window <Direction>

Sub Main

If ListVar1 = "Right" Then

SendKeys "+{WindowsHold}{Right}", 1

Else If ListVar1 = "Left"

SendKeys "+{WindowsHold}{Left}", 1

End If

End Sub

Again, I can't test this on Windows 7 as it does not respond to the Windows key for this use.



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

-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

 04/04/2018 09:21 PM
User is offline View Users Profile Print this message

Author Icon
davetreas
New Member

Posts: 7
Joined: 04/03/2018

Edgar ; Thanks for the quick and thorough reply. Will try it on a Win 10 machine and see how it goes....

I suppose one could simplify and make two commands - one for right, one for left, with no lists required?

SendKeys "+{WindowsHold}{Right}", 1

Would you use SendDragonKeys, or not?

Thanks to both of you for this. I've got a very happy friend right now!
 04/05/2018 11:33 AM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 1284
Joined: 04/03/2009

The choice between SendKeys, SendSystemKeys & SendDragonKeys is somewhat situational. Personally, I have found that when using KnowBrainer the only one that I can use is SendKeys. When using Dragon it varies by application. I generally try SendKeys first and if it has problems SendSystemKeys is my go to (I never use SendDragonKeys).

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

-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

 04/05/2018 12:48 PM
User is offline View Users Profile Print this message

Author Icon
Lunis Orcutt
Top-Tier Member

Posts: 40100
Joined: 10/01/2006

SendDragonKeys is exclusive to Dragon; hence the name. Unfortunately, it is even slower than SendKeys but SendSystemKeys is even slower but usually bulletproof. You can also use SendSystemKeys in KnowBrainer but only when constructing DVC commands. KnowBrainer allows you to create VB, DVC and .NET commands.



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

Change "No" to "Know" w/KnowBrainer 2020
Trial Downloads
Dragon/Sales@KnowBrainer.com 
(615) 884-4558 ex 1



 04/05/2018 02:11 PM
User is offline View Users Profile Print this message

Author Icon
MDH
Top-Tier Member

Posts: 2271
Joined: 04/02/2008

"I never use SendDragonKeys"

If you use Citrix, one should preferentially use SendDragonKeys, as it is the most reliable in that case.

MDH



-------------------------
 11/22/2021 04:58 AM
User is offline View Users Profile Print this message

Author Icon
IceRafter
Junior Member

Posts: 21
Joined: 01/11/2019

As noted on another thread, besides being slower than grinding rocks into dirt, a very subtle difference between SendSystemKeys and two alternatives is that it RESPECTS THE STATE OF THE CAPS-LOCK KEY, which CAN be problematic. Verified as much with 15.611.200.010 Dragon build. Swear that sometime in the past, SendDragonKeys also respected the caps lock key, but such is not the case today.

Caps lock off Test
SendKeys: this should be all lowercase
SendDragonKeys: this should be all lowercase
SendSystemKeys: this should be all lowercase
SendSystemKeys: THIS SHOULD BE ALL UPPERCASE

Caps lock on Test
SendKeys: this should be all lowercase
SendDragonKeys: this should be all lowercase
SendSystemKeys: THIS SHOULD BE ALL LOWERCASE
SendSystemKeys: this should be all uppercase


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

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