ControlCommand

首页  后退  前进

ControlCommand
down2

ControlCommand

发送命令到控件.

 

ControlCommand ( "title", "text", controlID, "command" [, "option"] )

参数

title

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

text

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

controlID

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

command

发送到控件的命令.

option

[可选] 某些命令需要的附加参数.

返回值

返回值取决于命令的结果, 如下表所列. 若发生错误(如命令或窗口/控件无效), 则返回 @error=1.

Command, Option

返回值

"IsVisible", ""

若目标控件可见则返回值 1, 否则返回 0

"IsEnabled", ""

若目标控件激活则返回值 1, 否则返回 0

"ShowDropDown", ""

弹出组合框(ComboBox)的下拉列表

"HideDropDown", ""

隐藏组合框(ComboBox)的下拉列表

"AddString", 'string'

添加字符串到 ListBox 或 ComboBox 下拉列表的后面

"DelString", occurrence

删除 ListBox 或 ComboBox 指定位置的字符串

"FindString", 'string'

返回 ListBox 或 ComboBox 匹配指定字符串的位置

"SetCurrentSelection", occurrence

选择 ListBox 或 ComboBox 指定位置的项目

"SelectString", 'string'

选择 ListBox 或 ComboBox 匹配指定字符串的项目

"IsChecked", ""

返回按钮选择状态. 1 为选中; 0 为未选中

"Check", ""

选中单选框或复选框

"UnCheck", ""

非选中单选框或复选框

"GetCurrentLine", ""

返回编辑框中插入符所在行号

"GetCurrentCol", ""

返回编辑框中插入符所在列号

"GetCurrentSelection", ""

返回 ListBox 或 ComboBox 当前选中的项目名称

"GetLineCount", ""

返回编辑框的总行数

"GetLine", line#

返回编辑框指定行的文本

"GetSelected", ""

返回编辑框选定的文本

"EditPaste", 'string'

粘贴指定字符串到编辑的插入符号位置

"CurrentTab", ""

返回 SysTabControl32 控件中当前显示的标签

"TabRight", ""

切换 SysTabControl32 控件显示下一个(右边)标签

"TabLeft", ""

切换 SysTabControl32 控件显示上一个(左边)标签

"SendCommandID", Command ID

模拟 WM_COMMAND 消息. 通常用于 ToolbarWindow32 控件 - 使用 Au3Info 的工具栏选项卡获取命令 ID

备注

除非控件窗口处于活动状态, 否则控件不会响应这些命令.

使用 ControlCommand() 之前, 必须调用 WinActivate() 函数强制控件窗口激活为顶层窗口.

 

某些命令能工作于正常的 Combo 与 ListBoxes 控件, 但对 "ComboLBox" 控件无效.

 

函数示例

#include <MsgBoxConstants.au3>
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 command to the edit control of Notepad to find the number of lines. The handle returned by WinWait is used for the "title" parameter of ControlCommand.
    Local $iCount = ControlCommand($hWnd, "", "Edit1", "GetLineCount", "")
    ; Display the number of lines.
    MsgBox($MB_SYSTEMMODAL, "", "The number of lines in Notepad are: " & $iCount)
    ; Close the Notepad window using the handle returned by WinWait.
    WinClose($hWnd)
EndFunc   ;==>Example

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

 

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

参见:

ControlClick, ControlDisable, ControlEnable, ControlFocus, ControlGetPos, ControlGetText, ControlHide, ControlMove, ControlSetText, ControlShow, StatusbarGetText, WinActivate, WinMenuSelectItem, WinGetClassList, ControlGetFocus, ControlListView, ControlSend, ControlTreeView

例子
copy

exect=ControlCommand('Безымянный~~~~Блокнот','''','Edit1','EditPaste','Это~~пример~~вставки~~текста'&@CRLF&'с~~переносом~~на~~новую~~строку') ;; 将文本插入记事本的示例(应该启动)

 

exect=ControlCommand('[CLASS:AkelPad4]','''','AkelEditW1','EditPaste','Hello') ;; 在"AkelPad"中插入"hello"

 

exect=$var_i=ControlCommand('[CLASS:AkelPad4]','''','AkelEditW1','GetCurrentLine','''')||_ViewValues($var_i) ;; 在"AkelPad"中插入"hello"

up2

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