Function Reference

_WinAPI_GetWindowPlacement

ウィンドウの最小化時、最大化時、通常時の位置を取得します。

#Include <WinAPI.au3>
_WinAPI_GetWindowPlacement($hWnd)

 

パラメータ

$hWnd ウィンドウのハンドル

 

返し値

成功: 位置座標を格納した$tagWINDOWPLACEMENT構造体
失敗: 0, @error = 1, @extended = _WinAPI_GetLastError()

 

注意

なし。

 

関連

_WinAPI_SetWindowPlacement, $tagWINDOWPLACEMENT

 

こちらも参照

MSDNライブラリでGetWindowPlacementを検索して下さい。

 


#AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

#include <WinAPI.au3>

Global $hWindow, $stRET, $sMsg, $pStruct, $iRET

; 実行に使用するメモ帳のインスタンスを作成
Run("notepad.exe")
WinWait("[CLASS:Notepad]")
$hWindow = WinGetHandle("[CLASS:Notepad]")
WinMove($hWindow, "", 256, 256, 400, 400)
Sleep(1000)

; 最小化し、_WinAPI_GetWindowPlacement()の返す位置を調べる
WinSetState($hWindow, "", @SW_MINIMIZE)
$stRET = _WinAPI_GetWindowPlacement($hWindow)
If @error = 0 Then
    $sMsg = "$stWindowPlacement:" & @CRLF & @CRLF
    $sMsg &= @TAB & "length = " & DllStructGetData($stRET, "length") & @CRLF
    $sMsg &= @TAB & "flags = " & DllStructGetData($stRET, "flags") & @CRLF
    $sMsg &= @TAB & "showCmd = " & DllStructGetData($stRET, "showCmd") & @CRLF & @CRLF
    $sMsg &= "ptMinPosition:" & @CRLF
    $sMsg &= @TAB & "MinX = " & DllStructGetData($stRET, "ptMinPosition", 1) & @CRLF
    $sMsg &= @TAB & "MinY = " & DllStructGetData($stRET, "ptMinPosition", 2) & @CRLF & @CRLF
    $sMsg &= "ptMaxPosition:" & @CRLF
    $sMsg &= @TAB & "MaxX = " & DllStructGetData($stRET, "ptMaxPosition", 1) & @CRLF
    $sMsg &= @TAB & "MaxY = " & DllStructGetData($stRET, "ptMaxPosition", 2) & @CRLF & @CRLF
    $sMsg &= "rcNormalPosition:" & @CRLF
    $sMsg &= @TAB & "left = " & DllStructGetData($stRET, "rcNormalPosition", 1) & @CRLF
    $sMsg &= @TAB & "top = " & DllStructGetData($stRET, "rcNormalPosition", 2) & @CRLF
    $sMsg &= @TAB & "right = " & DllStructGetData($stRET, "rcNormalPosition", 3) & @CRLF
    $sMsg &= @TAB & "bottom = " & DllStructGetData($stRET, "rcNormalPosition", 4)
    MsgBox(64, "Success", $sMsg)

    ; _WinAPI_SetWindowPlacement()で通常の長方形を変更、その後復元
    DllStructSetData($stRET, "rcNormalPosition", 128, 1); 左
    DllStructSetData($stRET, "rcNormalPosition", 128, 2); 上
    DllStructSetData($stRET, "rcNormalPosition", @DesktopWidth - 128, 3); 右
    DllStructSetData($stRET, "rcNormalPosition", @DesktopHeight - 128, 4); 下
    $pStruct = DllStructGetPtr($stRET); 変更された構造体へのポインタを取得
    $iRET = _WinAPI_SetWindowPlacement($hWindow, $pStruct)
    If @error = 0 Then
        WinSetState($hWindow, "", @SW_RESTORE)
        ControlSetText($hWindow, "", "Edit1", "_WinAPI_SetWindowPlacement() succeeded!")
    Else
        MsgBox(16, "Error", "_WinAPI_SetWindowPlacement() failed!" & @CRLF & _
                "$iRET = " & $iRET & @CRLF & _
                "@error = " & @error & @CRLF & _
                "@extended = " & @extended)
    EndIf
Else
    MsgBox(16, "Error", "_WinAPI_GetWindowPlacement() failed!" & @CRLF & _
            "$stRET = " & $stRET & @CRLF & _
            "@error = " & @error & @CRLF & _
            "@extended = " & @extended)
EndIf