Sie sind vermutlich noch nicht im Forum angemeldet - Klicken Sie hier um sich kostenlos anzumelden Impressum 
Sie können sich hier anmelden
Dieses Thema hat 1 Antworten
und wurde 141 mal aufgerufen
 Skripte und Zusatzprogramme
monkey8 Offline



Beiträge: 315

23.04.2010 00:20
RE: Position your active window using advanced scripts Zitat · Antworten

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.

Lindsay Adam

R.Wilke Offline



Beiträge: 6.334

23.04.2010 10:58
#2 RE: Position your active window using advanced scripts Zitat · Antworten

Hi Lindsay,

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
Ähnliche Themen Antworten/Neu Letzter Beitrag⁄Zugriffe
15.3 funktioniert nicht mehr richtig, es stört andere Software, es verschluckt sich, vielleicht wg Windows Update
Erstellt im Forum Fragen zur Anwendung von Frank_fragt
3 05.02.2024 16:15
von P.Roch • Zugriffe: 386
Windows 11 23H2 und Journal Playback Hooks
Erstellt im Forum Fragen zur Anwendung von Marius_
4 26.12.2023 18:38
von R.Wilke • Zugriffe: 230
Windows 11
Erstellt im Forum Fragen zur Anwendung von uljoman
4 17.09.2023 18:32
von R.Wilke • Zugriffe: 336
Befehl zur Änderung der Mausposition relativ zur aktuellen Position
Erstellt im Forum Fragen zur Anwendung von
8 25.08.2023 16:29
von • Zugriffe: 702
Word-Makros funktionieren immer wieder einmal nicht.
Erstellt im Forum Skripte und Zusatzprogramme von rc.otto
2 13.03.2023 08:05
von rc.otto • Zugriffe: 168
Dragon Legal 16 – erste Erfahrungen
Erstellt im Forum Berichte und Tipps von Marius_
4 29.03.2023 17:27
von royaltyrant • Zugriffe: 1079
PC mit Dragon unter Windows 11 extrem langsam
Erstellt im Forum Fragen zur Anwendung von CT1956
9 07.10.2023 20:02
von CT1956 • Zugriffe: 1670
Windows 11 und Dragon
Erstellt im Forum Fragen zur Anwendung von Harald
14 20.01.2022 15:08
von Rene • Zugriffe: 4418
Hat irgendjemand Infos/Erfahrungen mit Dragon 13 Premium/15 DPI und Windows 11?
Erstellt im Forum Fragen zur Anwendung von Khaine
1 07.12.2021 15:01
von Falconi • Zugriffe: 1350
NatSpeak 12 und Windows 10
Erstellt im Forum Fragen zur Anwendung von gunnit50
3 18.06.2021 16:52
von Sabine • Zugriffe: 283
 Sprung  
Xobor Ein Kostenloses Forum | Einfach ein Forum erstellen
Datenschutz