WinMove

首页  后退  前进

WinMove
down2

WinMove

移动窗口位置或(和)调整窗口大小.

 

WinMove ( "title", "text", x, y [, width [, height [, speed]]] )

参数

title

目标窗口标题, 或句柄, 或类名. 参考 窗口标题与文本.

text

目标窗口文本. 默认值为空字符串. 参考 窗口标题与文本.

x

移动到目的位置的 X 坐标.

y

移动到目的位置的 Y 坐标.

width

[可选] 窗口的新宽度.

height

[可选] 窗口的新高度.

speed

[可选] 窗口的移动速度. 范围从 1(最快)到 100(最慢), 如果未指定, 则为最快.

返回值

成功:

返回目标窗口的句柄.

失败:

返回 0, 指定的窗口不存在.

备注

本函数对最小化窗口无效, 但能对隐藏窗口能正常工作.

若指定的宽度和高度过小(或者是负数), 则窗口大小将不会小于 112 x 27(象素).

若宽度和高度过大, 则窗口大小将不会大于 [12+@DesktopWidth] x [12+@DesktopHeight] (像素).

X 坐标 和 Y 坐标可使用负数. 事实上, 您甚至可以把窗口移出屏幕; 以起到关闭窗口的作用

若程序具有"记住上次位置"功能, 则下次运行该程序时, 窗口将出现在屏幕角落(但完全在屏幕上).

若同时有多个窗口符合匹配条件, 则使用最近激活的窗口.

 

如果 X、和 Y 坐标使用关键字 Default 窗口不会移动, 仅修改到所要求的尺寸.

 

"speed"参数用于完成窗口移动到新的大小.

 

函数示例

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 as well as the height and width of the Notepad window. We will use this when we have to move the window back to the original position.
    Local $aPos = WinGetPos($hWnd)
    ; Move the Notepad to the x, y position of 0, 0 and set the height and width at 200, 200.
    WinMove($hWnd, "", 0, 0, 200, 200)
    ; Wait for 2 seconds to display the new position of the Notepad window.
    Sleep(2000)
    ; Move the Notepad window back to the original position by using the array returned by WinGetPos.
    WinMove($hWnd, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3])
    ; Wait for 2 seconds to display the original position of the Notepad window.
    Sleep(2000)
    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example

----------------------------------------

参见:

WinGetPos, WinActivate, WinClose, WinGetClientSize, WinSetState

例子
copy

exect=$var_h=WinGetHandle('[CLASS:TTOTAL_CMD]')||$var_a=WinGetPos(Eval('var_h'))||WinMove(Eval('var_h'),'''',10,10,200,300,20)||Sleep(3000)||WinMove(Eval('var_h'),'''',$var_a[0],$var_a[1],$var_a[2],$var_a[3],20) ;; 要移动Total Commander窗口,在3秒钟内返回窗口

up2

tcimage © Аверин Андрей для Total Commander Image Averin-And@yandex.ru