Listed below is a DNS advanced script for positioning the active window how you would like it on your display. The example script will position the window on the left half of the main display, just change one line of the script as detailed at the end of the post to position the window on the right half of the display. Positioning the windows in top left, bottom left, top right, bottom right quarters of display can easily be implemented also by adjusting just a couple of lines of the script. The names I use for the scripts are as follows but you can choose your own names, just copy and paste the script into an advanced script.
"Left half of display" "right half of display" "top left of display" "bottom left of display" "top right of display" "bottom right of display"
I would suggest copying this complete post into something like DragonPad or Wordpad and maximising the window to make it more readable.
I have put comments in the script to try and explain exactly what each line of code does. Obviously you can then modify and adapt to suit. The script follows, just copy and paste into an advanced script where it will be more readable as it will be displayed with the appropriate colours and syntax.
' Position active window on display ' scripts by Lindsay Adam 2008 ladam@btconnect.com ' www.pcbyvoice.com ' Declare Windows API functions Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As _ Long, ByVal nCmdShow As Long) As Long Declare Function GetForegroundWindow Lib "user32" () As Long Declare Function MoveWindow Lib "user32.dll" (ByVal hwnd As _ Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As _ Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long Declare Function SystemParametersInfo Lib "user32" _ Alias "SystemParametersInfoA" (ByVal uAction As Long, _ ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) _ As Long ' declare RECT structure for window position Option Explicit Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type ' assign constants for SystemParametersInfo & ShowWindow API functions Const SPI_GETWORKAREA = 48 Const SW_RESTORE=9 Sub Main ' window handle, width,height,x-coord of top left-hand corner,y-coord(of window rectangle) Dim hwnd,w,h,x,y As Long ' rectangle representing work area on screen available, taking taskbar, Dragon bar etc into account Dim wRect As RECT ' initialiser rectangle with the current available working area SystemParametersInfo(SPI_GETWORKAREA, vbNull, wRect, 0) ' get a handle of current active window even if it is minimised hwnd = GetForegroundWindow() ' restore the window if it isn't already displayed e.g. it is minimised ShowWindow(hwnd, SW_RESTORE) ' width of work area available w=wRect.Right - wRect.Left ' height of work area available h=wRect.Bottom - wRect.Top ' x-coordinate of top left hand corner of window so that the window is left half display x=wRect.Left ' y-coordinate y=wRect.Top ' position window on the left half of display MoveWindow(hwnd,x,y,w/2,h,1) End Sub
Hopefully Rüdiger can translate the explanation above into German, I don't trust the Google translation. You need to change different lines on the script depending on which window position you want to implement.
For the right half of the display just change the X coordinate line to the following:
x = wRect.Left + w/2
If anyone is interested in positioning windows and top left, bottom left, top right and bottom right quarters of display and you can't work out the maths then let me know and I will post the lines that need to be amended for quarter window sizes.
thanks so much for sharing this with us. I think I'll give a few explanations for our German readers first.
Lindsay Adam hat eine Vielzahl sehr nützlicher Skripte zur erweiterten Bedienung von Anwendungen mittels Sprachbefehlen entwickelt, und wird diese, so weit ich weiß, demnächst in einem größeren Rahmen der Öffentlichkeit zur Verfügung stellen. Das hier vorgestellte Skript entstammt einer Reihe von Befehlen zur Positionierung der Fenster auf dem Desktop. Mit dem Code in der vorliegenden Form wird das aktive Fenster so verschoben, dass es exakt die linke Hälfte des Bildschirms einnimmt und am linken Bildschirmrand angeheftet ist, wobei die Task-Leiste von Windows und ggf. die Dragon-Leiste berücksichtigt werden.
Ich habe den Code in eine TXT-Datei kopiert, die ich unten zum Download beifüge. Im Befehls-Editor kann ein entsprechendes Skript damit erstellt werden. Ich habe es bei mir "Fenster linke Seite" genannt.
Um analoge Befehle wie etwa "Fenster rechte Seite", "Fenster links oben", Fenster rechts unten" usw. zu definieren, müssen einige Code-Zeilen entsprechend umgebaut werden, wie Lindsay angeführt hat. Für Rückfragen steht der Author gerne zur Verfügung.
Viel Spaß damit!
Rüdiger Wilke
_______________________________________
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
Dateianlage:
Aufgrund eingeschränkter Benutzerrechte werden nur die Namen der Dateianhänge angezeigt Jetzt anmelden!
f12t135p580n22.txt