Sean Wenzel
Home Mouse Grid Password Manager Advanced Scripting Dictation Box HTML by voice Hippocampus




Positioning and Resizing a Window
Advanced Scripting Macro for Dragon NaturallySpeaking®

In order to use these macros you must download and place the following file into your Windows/system32 directory. Actually anywhere on the path would most likely work as well.

swDragon.dll

The DLL file contains precompiled functions to support the macros. This makes the macros exceptionally fast and powerful. It also allows you to quickly and easily extend and add functionality by calling the functions directly from your own scripts. All this and you won't even have to learn any of those nasty Windows API calls that tend to scare the heck out of most people.

Check out the AVI video demonstration using dual monitors using the following link. The file is 6MB, 1600 by 600 resolution and includes sound.

Download Dragon NaturallySpeaking video demonstration







MyCommand Name: <window> <swpositions>
Description Reposition the active window on the desktop in a variety of ways
Group swWindowManip
Command Type Advanced Scripting

Here is one of the scripts:

' swWindowManip
'
' Window repositioning and sizing support for Dragon
' NaturallySpeaking professional with dual monitor support
'
' ©Sean Wenzel 2005 All rights reserved. http://sean.wenzel.net/
'
' This software and supporting dll is licensed under the 
' following license agreement:
' http://www.gnu.org/copyleft/gpl.html
'
' Supporting swDragon.dll and documentation available from 
' http://sean.wenzel.net/voicerecognition/
'
Declare Function swWindowSnapResize Lib "swDragon" _
  ( ByVal hwnd As Long, ByVal direction As String, _
  ByVal size As Long) As Long

Sub Main
  Dim s As String
  Dim r As Long
  s = ListVar2
  r = swWindowSnapResize( 0, s, 0 )
End Sub








You will need to create the following lists:

<window>

window
win

and

<swpositions>

bottom
bottom left
bottom left center
bottom right
bottom right center
center
center left
center right
left
left center
right
right center
top
top left
top left center
top right
top right center

You may wish to create alternate macros with the same code such as "move <window> to <swpositions>".








The following script allows you to position and resize the active window on your desktop with a single utterance. Very nifty indeed.

MyCommand Name: <window> <swpositions> <1to100> percent
Description Reposition the active window on the desktop in a variety of ways
Group swWindowManip
Command Type Advanced Scripting

Here is the script:

' swWindowManip
'
' Window repositioning and sizing support for Dragon
' NaturallySpeaking professional with dual monitor support
'
' ©Sean Wenzel 2005 All rights reserved. http://sean.wenzel.net/
'
' This software and supporting dll is licensed under the 
' following license agreement:
' http://www.gnu.org/copyleft/gpl.html
'
' Supporting swDragon.dll and documentation available from 
' http://sean.wenzel.net/voicerecognition/
'
Declare Function swWindowSnapResize Lib "swDragon" _
  ( ByVal hwnd As Long, ByVal direction As String, _
  ByVal size As Long) As Long

Sub Main
  Dim sz As String
  Dim s As String
  Dim r As Long
  s = ListVar2
  sz = ListVar3
  
  r = swWindowSnapResize( 0, s, CInt(sz) )
End Sub

Some notes about dual monitor support.

Both displays are assumed to be of equal resolution. In addition the monitors are assumed to be side-by-side and the right hand side monitor has been set as the primary monitor in the Windows control panel.