AutoItLibrary测试Windows GUI

AutoItLibrary库关键字

 AutoItLibrary 的对象操作大体上有几大主要部分,Window 操作、Control 操作、Mouse 操作、Process操作、Run 操作、Reg 操作还有一些其他的操作。下面列出常用的关键字例子:

1、运行程序

Run     D:\\soft\\Assistant_V0.20.6.29\\Setup.exe

2、关闭程序

Win Close关键字用于关闭程序

Win Close    计算器    #是指打开窗口的标题

3、控制点击

Control Click关键字发送控制命令给鼠标点击

Control Click  计算器   ${EMPTY}   Button3

4、发送

Send  !{F4}  #键盘输入Alt+F4
Send  ^{SPACE}   #键盘输入Ctrl+Space
Send  {LWINDOWN}d{LWINUP}   #键盘输入Win+d
Send  {LWINDOWN}r{LWINUP}    #键盘输入Win+r

其它键盘操作,请参考:
键盘输入
    [Arguments]    ${keys}  ${flag}=0
    [Documentation]  模拟键盘输入,需要两个参数:
    ...  第一个参数: 需要输入的键盘按键
    ...  第二个参数: 标记变量,可选值,默认为0,
    ...               0:  代表第一个参数${keys}中的!+^#代表特殊按键
    ...               1:  代表第一个参数${keys}中的所有字符都是普通字符串
    ...  举例:
    ...  ^a^c^v!{F4}      代表:Ctrl+a Ctrl+c Ctrl+v Alt+F4
    ...  关于特殊按键的说明:
    ...      如果${flag}为0,则:
    ...     !  代表ALT按键
    ...     +  代表SHIFT按键
    ...     ^  代表CTRL按键
    ...     #  代表WIN按键
    ...  比如:!+a  代表:ALT+SHIFT+a
    ...  其他特殊按键:
    ...  ${flags}为0的时候,还支持下述特殊按键:
    ...     输入  最终的键盘按键
    ...     {!}                     !
    ...     {#}                     #
    ...     {+}                     +
    ...     {^}                     ^
    ...     {{}                     {
    ...     {}}                     }
    ...     {SPACE}                 SPACE
    ...     {ENTER}                 ENTER key on the main keyboard
    ...     {ALT}                   ALT
    ...     {BACKSPACE} or {BS}     BACKSPACE
    ...     {DELETE} or {DEL}       DELETE
    ...     {UP}                    Cursor up
    ...     {DOWN}                  Cursor down
    ...     {LEFT}                  Cursor left
    ...     {RIGHT}                 Cursor right
    ...     {HOME}                  HOME
    ...     {END}                   END
    ...     {ESCAPE} or {ESC}       ESCAPE
    ...     {INSERT} or {INS}       INS
    ...     {PGUP}                  PageUp
    ...     {PGDN}                  PageDown
    ...     {F1} - {F12}            Function keys
    ...     {TAB}                   TAB
    ...     {PRINTSCREEN}           Print Screen key
    ...     {LWIN}                  Left Windows key
    ...     {RWIN}                  Right Windows key
    ...     {NUMLOCK on}            NUMLOCK (on/off/toggle)
    ...     {CAPSLOCK off}          CAPSLOCK (on/off/toggle)
    ...     {SCROLLLOCK toggle}     SCROLLLOCK (on/off/toggle)
    ...     {BREAK}                 for Ctrl+Break processing
    ...     {PAUSE}                  PAUSE
    ...     {NUMPAD0} - {NUMPAD9}    Numpad digits
    ...     {NUMPADMULT}             Numpad Multiply
    ...     {NUMPADADD}              Numpad Add
    ...     {NUMPADSUB}              Numpad Subtract
    ...     {NUMPADDIV}              Numpad Divide
    ...     {NUMPADDOT}              Numpad period
    ...     {NUMPADENTER}            Enter key on the numpad
    ...     {APPSKEY}                Windows App key
    ...     {LALT}                   Left ALT key
    ...     {RALT}                   Right ALT key
    ...     {LCTRL}                  Left CTRL key
    ...     {RCTRL}                  Right CTRL key
    ...     {LSHIFT}                 Left Shift key
    ...     {RSHIFT}                 Right Shift key
    ...     {ALTDOWN}                Holds the ALT key down until {ALTUP} is sent
    ...     {SHIFTDOWN}              Holds the SHIFT key down until {SHIFTUP} is sent
    ...     {CTRLDOWN}               Holds the CTRL key down until {CTRLUP} is sent
    ...     {LWINDOWN}               Holds the left Windows key down until {LWINUP} is sent
    ...     {RWINDOWN}               Holds the right Windows key down until {RWINUP} is sent

5、等待活动窗口

Wait For Active Window 关键字会等待窗口显示出来

Wait For Active Windows   计算器

6、鼠标点击

Mouse Click  ${EMPTY}  1508  338  #点击操作

7、关闭程序进程

Process Close   D:\\Program Files (x86)\\COM\\Controller\\Controller.exe

8、窗口标题

Win Get Title 用于获取窗口标题

Win Get Title 用于获取窗口标题

Run    calc.exe
Win Set Title   计算器  ${EMPTY}  世界您好
${tile}    Win Get Title  
log  ${tile}

9、文本框输入

Control Set Text    ${EMPTY}    ${EMPTY}    Edit40    CPE6V8.0

指定文本框输入CPE6V8.0

10、下拉框选择

Control Command    ${EMPTY}   ${EMPTY}   ComboBox8   SelectString   无线模式

以下获取下拉框当前值

${ret}    Control GET Text    ${EMPTY}    ${EMPTY}    ComboBox8

 

AutoItLibrary测试Windows GUI

上一篇:iOS6和iOS7代码的适配(1)


下一篇:Model-View-ViewModel for iOS [译]