函数参考


ControlGetPos

获取指定控件相对其窗口的坐标位置和大小等信息.

ControlGetPos ( "窗口标题", "窗口文本", 控件ID )

参数

窗口标题 目标窗口标题.
窗口文本 目标窗口文本.
控件ID 要进行交互的控件. 请查看关于控件的说明.

返回值

成功: 返回一个储存着指定控件相对其窗口的位置及大小等信息的数组:
$array[0] = X 坐标
$array[1] = Y 坐标
$array[2] = 宽度
$array[3] = 高度
失败: 把 @error 设为 1.

注意/说明

窗口标题/文本会涉及到父窗口,请小心的使用("","")定义参数.

相关

ControlCommand, ControlMove

示例/演示


Example()

Func Example()
    ; Run Notepad
    Run("notepad.exe")

    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)

    ; Retrieve the position x, y and size (width and height) of the edit control in Notepad. The handle returned by WinWait is used for the "title" parameter of ControlGetPos.
    Local $aPos = ControlGetPos($hWnd, "", "Edit1")

    ; Display the position and size of the edit control.
    MsgBox(4096, "窗口状态:", "坐标: " & $aPos[0] & "," & $aPos[1] & @CRLF & "大小: " & $aPos[2] & "," & $aPos[3] )

    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example