Obtient la position d'une fen�tre, Min, Max, et normale
#include <WinAPISysWin.au3>
_WinAPI_GetWindowPlacement ( $hWnd )
$hWnd | Handle de la fen�tre |
Succ�s: | Retourne la structure $tagWINDOWPLACEMENT avec les coordonn�es de position |
�chec: | D�finit @error <>0, appelez _WinAPI_GetLastError() pour obtenir des informations sur l'erreur. |
$tagWINDOWPLACEMENT, _WinAPI_SetWindowPlacement
Consultez GetWindowPlacement dans la librairie MSDN.
#include <MsgBoxConstants.au3> #include <WinAPISysWin.au3> Local $hWnd, $iRET, $sMsg, $tRET ; Cr�e une instance de bloc-notes pour jouer avec Run("notepad.exe") $hWnd = WinWait("[CLASS:Notepad]") WinMove($hWnd, "", 256, 256, 400, 400) Sleep(1000) ; Minimise puis contr�le les valeurs de placement retourn�es par _WinAPI_GetWindowPlacement() WinSetState($hWnd, "", @SW_MINIMIZE) $tRET = _WinAPI_GetWindowPlacement($hWnd) If @error = 0 Then $sMsg = "$stWindowPlacement:" & @CRLF & @CRLF $sMsg &= @TAB & "length = " & DllStructGetData($tRET, "length") & @CRLF $sMsg &= @TAB & "flags = " & DllStructGetData($tRET, "flags") & @CRLF $sMsg &= @TAB & "showCmd = " & DllStructGetData($tRET, "showCmd") & @CRLF & @CRLF $sMsg &= "ptMinPosition:" & @CRLF $sMsg &= @TAB & "MinX = " & DllStructGetData($tRET, "ptMinPosition", 1) & @CRLF $sMsg &= @TAB & "MinY = " & DllStructGetData($tRET, "ptMinPosition", 2) & @CRLF & @CRLF $sMsg &= "ptMaxPosition:" & @CRLF $sMsg &= @TAB & "MaxX = " & DllStructGetData($tRET, "ptMaxPosition", 1) & @CRLF $sMsg &= @TAB & "MaxY = " & DllStructGetData($tRET, "ptMaxPosition", 2) & @CRLF & @CRLF $sMsg &= "rcNormalPosition:" & @CRLF $sMsg &= @TAB & "left = " & DllStructGetData($tRET, "rcNormalPosition", 1) & @CRLF $sMsg &= @TAB & "top = " & DllStructGetData($tRET, "rcNormalPosition", 2) & @CRLF $sMsg &= @TAB & "right = " & DllStructGetData($tRET, "rcNormalPosition", 3) & @CRLF $sMsg &= @TAB & "bottom = " & DllStructGetData($tRET, "rcNormalPosition", 4) MsgBox($MB_SYSTEMMODAL, "Succ�s", $sMsg) ; Modifie le rectangle normalis� avec _WinAPI_SetWindowPlacement() et puis restaure DllStructSetData($tRET, "rcNormalPosition", 128, 1); gauche DllStructSetData($tRET, "rcNormalPosition", 128, 2); haut DllStructSetData($tRET, "rcNormalPosition", @DesktopWidth - 128, 3); droite DllStructSetData($tRET, "rcNormalPosition", @DesktopHeight - 128, 4); bas $iRET = _WinAPI_SetWindowPlacement($hWnd, $tRET) If @error = 0 Then WinSetState($hWnd, "", @SW_RESTORE) ControlSetText($hWnd, "", "Edit1", "_WinAPI_SetWindowPlacement() a r�ussi!") Else MsgBox($MB_SYSTEMMODAL, "Error", "_WinAPI_SetWindowPlacement() a �chou�!" & @CRLF & _ "$tRET = " & $tRET & @CRLF & _ "@error = " & @error & @CRLF & _ "@extended = " & @extended) EndIf Else MsgBox($MB_SYSTEMMODAL, "Error", "_WinAPI_GetWindowPlacement() failed!" & @CRLF & _ "$tRET = " & $tRET & @CRLF & _ "@error = " & @error & @CRLF & _ "@extended = " & @extended) EndIf