这样?
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$GUI = GUICreate("Form1", 300, 200, (@DesktopWidth - 300) / 2, (@DesktopHeight - 200) / 2)
$btn_z = GUICtrlCreateButton("展", 100, 170, 50, 25)
$btn_s = GUICtrlCreateButton("收", 150, 170, 50, 25)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $btn_z
z()
Case $btn_s
s()
EndSwitch
WEnd
Func z()
While 1
$aWinPos = WinGetPos($GUI)
If $aWinPos[2] > (@DesktopWidth + 500) / 2 Then ExitLoop
WinMove($GUI, "", (@DesktopWidth - $aWinPos[2] + 1) / 2, Default, $aWinPos[2] + 20, $aWinPos[3])
Sleep(2)
WEnd
EndFunc ;==>z
Func s()
While 1
$aWinPos = WinGetPos($GUI)
If $aWinPos[2] < 300 Then ExitLoop
WinMove($GUI, "",(@DesktopWidth - $aWinPos[2] - 1) / 2, Default, $aWinPos[2] - 20, $aWinPos[3])
Sleep(2)
WEnd
EndFunc ;==>s
|