AU3控件操作

来源:互联网 发布:惯性坐标系知乎 编辑:程序博客网 时间:2024/05/20 13:09
1、控件识别
ID - The internal control ID
TEXT - The text on a control, for example "Next" on a button 
CLASS - The internal control classname such as "Edit" or "Button" 
CLASSNN - The ClassnameNN value as used in previous versions of AutoIt, such as "Edit1" 
NAME - The internal .NET Framework WinForms name (if available) 
REGEXPCLASS - Control classname using a regular expression 
X \ Y \ W \ H - The position and size of a control. 
INSTANCE - The 1-based instance when all given properties match. 

controlID parameter:[PROPERTY1 Value1;PROPERTY2:Value2] 
用AU3 Info获取控件信息,推荐使用advanced mode,ID不可靠
用ControlGetHandle获取控件句柄,结合相应UDF可以实现较复杂的控件操作
2、控件操作
Sends a mouse click command to a given control:
ControlClick ( "title", "text", controlID [, button = "left" [, clicks = 1 [, x [, y]]]] )

Sets input focus to a given control on a window:
ControlFocus ( "title", "text", controlID )

Retrieves the internal handle of a control:
ControlGetHandle ( "title", "text", controlID )

Retrieves text from a control:
ControlGetText ( "title", "text", controlID )

Sends a string of characters to a control(add to the end):
ControlSend ( "title", "text", controlID, "string" [, flag = 0] )

Sets text of a control(replace):
ControlSetText ( "title", "text", controlID, "new text" [, flag = 0] )

Sends a command to a control:
ControlCommand ( "title", "text", controlID, "command" [, "option"] 
e.g. ControlCommand($hWnd, "", "Radio1", "Check")

Sends a command to a TreeView32 control:
ControlTreeView ( "title", "text", controlID, "command" [, option1] )
e.g. ControlTreeView($hWnd, "", "Treeview1", "Expand","#0")
ControlTreeView($hWnd, "", "Treeview1", "Select","#0")

用 ControlGetHandle获取控件句柄e.g.
Local $hCombo=ControlGetHandle ( $hWnd, "", "Combo1")
_GUICtrlComboBox_SetCurSel ( $hCombo ,1)

如果控件不能识别,还可以模拟键盘和鼠标操作
MouseClick ( "button" [, x, y [, clicks = 1 [, speed = 10]]] )
MouseClickDrag ( "button", x1, y1, x2, y2 [, speed = 10] )
Send ( "keys" [, flag = 0] )