WinClose

首页  后退  前进

WinClose
down2

WinClose

关闭指定窗口.

 

WinClose ( "title" [, "text"] )

参数

title

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

text

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

返回值

成功:

返回 1.

失败:

返回 0, 窗口不存在.

备注

本函数将发送关闭消息到目标窗口, 效果因窗口不同而不同(可能会询问是否保存数据, 等等).

若要强制关闭目标窗口, 请使用 WinKill() 函数. 若同时有多个窗口符合匹配条件, 则关闭最近激活的窗口.

 

函数示例

Example()
Func Example()
    ; Run Notepad
    Run("notepad.exe")
    ; Wait 10 seconds for the Notepad window to appear.
    WinWait("[CLASS:Notepad]", "", 10)
    ; Wait for 2 seconds to display the Notepad window.
    Sleep(2000)
    ; Close the Notepad window using the classname of Notepad.
    WinClose("[CLASS:Notepad]")
EndFunc   ;==>Example

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

 

该函数可以通过命令 exect 调用

参见:

WinActivate, WinExists, WinKill, WinSetState, WinTitleMatchMode (Опция), ProcessClose, WinMove

例子
copy

exect=WinClose('[CLASS:Notepad]') ;; 关闭记事本窗口

 

exect=Run('notepad.exe')||WinWait('[CLASS:Notepad]')||Sleep(3000)||WinClose('[CLASS:Notepad]') ;; 运行"记事本",等待指定的窗口出现,3秒钟后关闭窗口

 

exect=$var_handle=WinGetHandle('Безымянный~~~~Блокнот')||WinClose(Eval('var_handle')) ;; 通过其标题和关闭来定义窗口句柄

 

exect=Run('notepad.exe')||$var_h=WinWait('[CLASS:Notepad]','''',5)||SendKeepActive(HWnd($var_h)) <FOR> 1 <TO> 10 exect=Send('Hello')||Sleep(500) <NEXT> exect=SendKeepActive('''')||WinClose(HWnd($var_h)) ;; 使用Send()函数运行记事本并保持记事本窗口处于活动状态

up2

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