ControlClick

首页  后退  前进

ControlClick
down2

ControlClick

发送鼠标点击命令到指定控件.

 

ControlClick ( "title", "text", controlID [, button = "left" [, clicks = 1 [, x [, y]]]] )

参数

title

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

text

目标窗口文本. 参见 窗口标题与文本.

controlID

控件标识符. 相关说明见 控件.

button

[可选] 点击使用的按钮,

"left" = 左键

"right" = 右键

"middle" = 中键

"main" = 主要

"menu" = 菜单

"primary" = 主键

"secondary" = 次键

默认使用 left(左键).

clicks

[可选] 鼠标点击的次数. 默认为 1 次.

x

[可选] 点击控件的 X 坐标位置. 默认为控件中心.

y

[可选] 点击控件的 Y 坐标位置. 默认为控件中心.

返回值

成功:

返回 1.

失败:

返回 0.

备注

除非是活动窗口, 否则某些控件不会响应点击. 使用 ControlClick() 前, 调用 WinActivate() 函数激活控件的窗口.

两次点击将发送双击消息到控件 - 这个事件可以在资源管理器控件中启动程序!

 

如果用户在控制面板中交换了鼠标左键和右键, 按钮的行为将会不同.

但无论按钮是否被交换,以下状态不变:

"Left"(左键) 和 "right"(右键) 总是点击操作;

"primary"(主键) 或 "main"(主要) 将是主点击;

"secondary"(次键) 或 "menu"(菜单) 按钮通常会带出上下文菜单.

 

Button

Normal

Swapped

""

左键

左键

"left"

左键

左键

"middle"

中键

中键

"right"

右键

右键

"primary"

左键

右键

"main"

左键

右键

"secondary"

右键

左键

"menu"

右键

左键

 

函数示例

Example()
Func Example()
    ; Run Notepad
    Run("notepad.exe")
    ; Wait 10 seconds for the Notepad window to appear.
    Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)
    ; Send a mouse click to the edit control of Notepad using the handle returned by WinWait.
    ControlClick($hWnd, "", "Edit1")
    ; Wait for 2 seconds.
    Sleep(2000)
    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example

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

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

参见:

ControlCommand, MouseClick, WinActivate

例子
copy

exect=ControlClick('Калькулятор','''','[ID:139]') ;; 模拟鼠标点击指定的元素

 

start=%%COMMANDER_PATH%%\PK\PK.exe exect=$var_h=WinWaitActive('[CLASS:ThunderRT6FormDC]')||ControlSetText(Eval('var_h'),'''','ThunderRT6TextBox1','пароль')||ControlClick(Eval('var_h'),'''','ThunderRT6CommandButton3') ;; 启动程序,等待窗口打开,并在指定的字段中输入文本"密码",然后单击确定按钮

up2

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