Tag auch,
da ich schon länger nach einer Funktion gesucht habe, die es ermöglicht ein beliebiges Fenster an den Bildschirmrand andocken zu lassen, sobald man dieses Fenster nahe genug daran schiebt, aber nichts gefunden habe, habe ich mir schnell selbst so eine geschrieben und möchte sie hier mal anbieten
Spoiler anzeigen
Func windock($win, $padding = 25)
$windockpos = WinGetPos($win, "")
If IsArray($windockpos) Then
If $windockpos[0] <= $padding Then
If $windockpos[0] <= $padding And $windockpos[1] <= $padding Then
WinMove($win, "", 0, 0)
ElseIf $windockpos[0] <= $padding And $windockpos[1] >= @DesktopHeight - $windockpos[3] - $padding Then
WinMove($win, "", 0, @DesktopHeight - $windockpos[3])
Else
WinMove($win, "", 0, $windockpos[1])
EndIf
ElseIf $windockpos[0] >= @DesktopWidth - $windockpos[2] - $padding Then
If $windockpos[0] >= @DesktopWidth - $windockpos[2] - $padding And $windockpos[1] <= $padding Then
WinMove($win, "", @DesktopWidth - $windockpos[2], 0)
ElseIf $windockpos[0] >= @DesktopWidth - $windockpos[2] - $padding And $windockpos[1] >= @DesktopHeight - $windockpos[3] - $padding Then
WinMove($win, "", @DesktopWidth - $windockpos[2], @DesktopHeight - $windockpos[3])
Else
WinMove($win, "", @DesktopWidth - $windockpos[2], $windockpos[1])
EndIf
ElseIf $windockpos[1] <= $padding Then
WinMove($win, "", $windockpos[0], 0)
ElseIf $windockpos[1] >= @DesktopHeight - $windockpos[3] - $padding Then
WinMove($win, "", $windockpos[0], @DesktopHeight - $windockpos[3])
EndIf
EndIf
EndFunc
Sie ist zwar nichts besonderes, aber ich finde sie recht nützlich
Kurzer Hinweis zur Verwendung: Einfach in einer While Schleife die Funktion aufrufen. Der erste Parameter muss das Handle / den Fensternamen des zu steuernden Fensters beinhalten, der zweite ist optional und gibt die Pixelbreite an jeder Randseite des Bildschirms, in welcher das Docking vollzogen werden soll.
Hier ein Beispiel zur Anwendung:
Spoiler anzeigen
#include <GUIConstants.au3>
[/autoit] [autoit][/autoit] [autoit]$gui = GUICreate("Testfenster", 400, 300, -1, 20, Default, $WS_EX_TOPMOST)
GUISetState()
Sleep(1000)
[/autoit] [autoit][/autoit] [autoit]While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
windock($gui, 30)
WEnd
Func windock($win, $padding = 25)
$windockpos = WinGetPos($win, "")
If IsArray($windockpos) Then
If $windockpos[0] <= $padding Then
If $windockpos[0] <= $padding And $windockpos[1] <= $padding Then
WinMove($win, "", 0, 0)
ElseIf $windockpos[0] <= $padding And $windockpos[1] >= @DesktopHeight - $windockpos[3] - $padding Then
WinMove($win, "", 0, @DesktopHeight - $windockpos[3])
Else
WinMove($win, "", 0, $windockpos[1])
EndIf
ElseIf $windockpos[0] >= @DesktopWidth - $windockpos[2] - $padding Then
If $windockpos[0] >= @DesktopWidth - $windockpos[2] - $padding And $windockpos[1] <= $padding Then
WinMove($win, "", @DesktopWidth - $windockpos[2], 0)
ElseIf $windockpos[0] >= @DesktopWidth - $windockpos[2] - $padding And $windockpos[1] >= @DesktopHeight - $windockpos[3] - $padding Then
WinMove($win, "", @DesktopWidth - $windockpos[2], @DesktopHeight - $windockpos[3])
Else
WinMove($win, "", @DesktopWidth - $windockpos[2], $windockpos[1])
EndIf
ElseIf $windockpos[1] <= $padding Then
WinMove($win, "", $windockpos[0], 0)
ElseIf $windockpos[1] >= @DesktopHeight - $windockpos[3] - $padding Then
WinMove($win, "", $windockpos[0], @DesktopHeight - $windockpos[3])
EndIf
EndIf
EndFunc
Für meine Zwecke reicht es vollkommen aus, auch wenn man noch ein paar Dinge ändern könnte
Viel Spass damit =)
PS: Hoffentlich ist das der richtige Bereich dafür "O.o