Hey, hatte das hier für AutoIt.at geschrieben, und dachte mir, dass es auch hier nicht fehl am Platze wäre.
Die Funktionen _SlideWin() und _WinIsHovered sind natürlich ohne anpassung übernehmbar.
/EDIT: Daraus ist auch vor ewiger Zeit mal eine UDF enstanden:
https://autoit.de/index.php?page=Thread&postID=145125
Spoiler anzeigen
#include <Array.au3>
#include <WindowsConstants.au3>
HotKeySet("{ESC}", "_Exit") ; Set the Hotkey to exit.
$hDLL = DllOpen("user32.dll") ; Open the DLL for _WinIsHovered() (faster with DLL-handle)
$h_Left = GUICreate("SlideGUI left", 155, 350, -1, -1, -1, $WS_EX_TOPMOST)
$_Button1 = GUICtrlCreateButton("Example Button", 40, 40, 100, 30)
GUICtrlCreateEdit("Sample Edit...", 20, 90, 120, 200)
$h_Right = GUICreate("SlideGUI Right", 155, 350, -1, -1, -1, $WS_EX_TOPMOST)
GUICtrlCreateEdit("Sample Edit...", 20, 20, 150, 300)
$h_Bottom = GUICreate("SlideGUI Bottom", 350, 155, -1, -1, -1, $WS_EX_TOPMOST)
GUICtrlCreateCheckbox("Sample Checkbox", 40, 30)
GUICtrlCreateCombo("Combo", 140, 50)
$h_Top = GUICreate("SlideGUI Top", 350, 155, -1, -1, -1, $WS_EX_TOPMOST)
$_ListView = GUICtrlCreateListView("Columnd 1|Column 2", 5, 5, 340, 145)
GUICtrlCreateListViewItem("Item 1_1|Item 1_2",$_ListView)
GUICtrlCreateListViewItem("Item 2_1|Item 2_2",$_ListView)
GUICtrlCreateListViewItem("Item 3_1|Item 3_2",$_ListView)
; Move GUI's to the right place and set the Variables State to False
Global $LEFT_IN = False, $RIGHT_IN = False, $BOTTOM_IN = False, $TOP_IN = False
_SlideWin($h_Left, "out", "left")
_SlideWin($h_Right, "out", "right")
_SlideWin($h_Bottom, "out", "bottom")
_SlideWin($h_Top, "out", "top")
; Show GUI's
GUISetState(@SW_SHOWNOACTIVATE, $h_Left)
GUISetState(@SW_SHOWNOACTIVATE, $h_Right)
GUISetState(@SW_SHOWNOACTIVATE, $h_Bottom)
GUISetState(@SW_SHOWNOACTIVATE, $h_Top)
While 1 * Sleep(10)
$nMsg = GUIGetMsg(1)
Select
Case $nMsg[0] = -3
_Exit()
Case $nMsg[0] = $_Button1
MsgBox(0, "", "Example Button clicked.")
Case _WinIsHovered($h_Left, $hDLL) ; Check if we need to Slide in a GUI.
If Not $LEFT_IN Then ; If not already slide-in,
_SlideWin($h_Left, "in", "left") ; Slide in GUI
$LEFT_IN = True ; Set var to True.
EndIf
Case _WinIsHovered($h_Right, $hDLL)
If Not $RIGHT_IN Then
_SlideWin($h_Right, "in", "right")
$RIGHT_IN = True
EndIf
Case _WinIsHovered($h_Bottom, $hDLL)
If Not $BOTTOM_IN Then
_SlideWin($h_Bottom, "in", "bottom")
$BOTTOM_IN = True
EndIf
Case _WinIsHovered($h_Top, $hDLL)
If Not $TOP_IN Then
_SlideWin($h_Top, "in", "top")
$TOP_IN = True
EndIf
Case Else ; No window is hovered. Check if we need to Slide out a GUI.
Select
Case $LEFT_IN
_SlideWin($h_Left, "out", "left")
$LEFT_IN = False
Case $RIGHT_IN
_SlideWin($h_Right, "out", "right")
$RIGHT_IN = False
Case $TOP_IN
_SlideWin($h_Top, "out", "top")
$TOP_IN = False
Case $BOTTOM_IN
_SlideWin($h_Bottom, "out", "bottom")
$BOTTOM_IN = False
EndSelect
EndSelect
WEnd
Func _SlideWin($hWnd, $sMode, $sSide)
;$hWnd = Window to slide.
;$sMode = Slide-In or -out (in|out)
;$sSide = Side where you want the GUI to slide. (left|right|top|bottom)
Local $aScreen_Res = WinGetPos(WinGetHandle("Program Manager"))
Local $aWPos = WinGetPos($hWnd), $m = 0 - ($sMode = "in") + ($sMode = "out")
Local $h = 0 - ($sSide = "left") + ($sSide = "right"), $v = 0 - ($sSide = "top") + ($sSide = "bottom")
WinMove($hWnd, "", _ ; Move GUI according to $sMode and $sSide.
$aScreen_Res[0] - (($h = -1) * ($m = -1) * ($aWPos[2] - 10)) _
+ (($h = 1) * (($h = 1) * $aScreen_Res[2] - (10 * ($m = -1)) - ($m <> -1) * $aWPos[2])) _
+ (($h = 0) * (($h = 0) * ($aScreen_Res[2] / 2) - ($aWPos[2] / 2))) _
, _
$aScreen_Res[1] - (($v = -1) * ($m = -1) * ($aWPos[3] - 10)) _
+ (($v = 1) * (($v = 1) * $aScreen_Res[3] - (10 * ($m = -1)) - ($m <> -1) * $aWPos[3])) _
+ (($v = 0) * (($v = 0) * ($aScreen_Res[3] / 2) - ($aWPos[3] / 2))) _
)
$aWPos = WinGetPos($hWnd)
; Slide GUI.
Switch $sSide
Case "left", "right"
Local $STEP = (((($h = 1) And ($m = 1)) Or (($h = -1) And ($m = -1))) - ((($h = -1) And ($m = 1)) Or (($h = 1) And ($m = -1)))) * 10
Local $FROM = $aWPos[0], $TO = $aWPos[0] _
+ (((($h = 1) And ($m = 1)) Or (($h = -1) And ($m = -1))) * ($aWPos[2])) _
- (((($h = 1) And ($m = -1)) Or (($h = -1) And ($m = 1))) * ($aWPos[2])) - $STEP
For $i = $aWPos[0] To $TO Step $STEP
WinMove($hWnd, "", $i, $aWPos[1])
Sleep(10)
Next
Case "top", "bottom"
Local $STEP = (((($v = 1) And ($m = 1)) Or (($v = -1) And ($m = -1))) - ((($v = -1) And ($m = 1)) Or (($v = 1) And ($m = -1)))) * 10
Local $FROM = $aWPos[1], $TO = $aWPos[1] _
+ (((($v = 1) And ($m = 1)) Or (($v = -1) And ($m = -1))) * ($aWPos[3])) _
- (((($v = 1) And ($m = -1)) Or (($v = -1) And ($m = 1))) * ($aWPos[3])) - $STEP
For $i = $aWPos[1] To $TO Step $STEP
WinMove($hWnd, "", $aWPos[0], $i)
Sleep(10)
Next
EndSwitch
EndFunc ;==>_SlideWin
Func _WinIsHovered($hWnd, $vDLL = "User32.dll")
Local $aResult, $aWPos = WinGetPos($hWnd), $aMPos = MouseGetPos()
Local $tRect = DllStructCreate("int Left;int Top;int Right;int Bottom")
Local $iLeft = $aWPos[0], $iTop = $aWPos[1], $iWidth = $aWPos[2], $iHeight = $aWPos[3]
Local $iX = $aMPos[0], $iY = $aMPos[1]
DllStructSetData($tRect, "Left", $iLeft)
DllStructSetData($tRect, "Top", $iTop)
DllStructSetData($tRect, "Right", $iLeft + $iWidth)
DllStructSetData($tRect, "Bottom", $iTop + $iHeight)
$aResult = DllCall($vDLL, "int", "PtInRect", "ptr", DllStructGetPtr($tRect), "int", $iX, "int", $iY)
If @error Then Return SetError(@error, 0, False)
Return $aResult[0] <> 0
EndFunc ;==>_WinIsHovered
Func _Exit()
DllClose($hDLL) ; Dont forget to close your DLL-Handle
Exit
EndFunc ;==>_Exit