美文网首页
重温AutoIt

重温AutoIt

作者: ww4u | 来源:发表于2018-06-28 12:28 被阅读0次
    • 好几年前出于利用现有GUI进行测试的目的,接触了AutoIt
    • 最近再次遇到相同的需求
      • 整合现有的GUI工具进行自动化操作
    • 对于支持console的工具,直接集成就好了
    • 对于GUI,由于其带有UI交互,需要利用其它工具自动化UI流程操作
    • 而这正是AutoIt的初衷(AutoIt最初的目的是为了能够自动化操作系统部署后的软件安装过程)


      autoit

    steps

    • 根据GUI的过程确定后台自动化流程设计


      step1
      step2
      step3
      step4
      step5
      step5.1
    一键自动下载 一键程序下载

    工具要小而美,只做好一件事

    附au3脚本

    
    ; [1]: app
    ; [2]: can device
    ; [3]: upd
    
    
    Global $winName="MegaRobo_Update (01.06)"
    
    ; get app name
    Local $appName= "D:\Program Files (x86)\MegaRobo\MegaUpdate_01.05\UpdateFile.exe"
    Local $deviceName = "DEV_USBCAN2"
    Local $updName="C:\Users\wangzhiyan\Desktop\Sinanju(SOFT)_04.00.01.23.upd"
    
    if $CmdLine[0] >= 3 Then
       $appName=$cmdLine[1]
       $deviceName = $cmdLine[2]
       $updName=$cmdLine[3]
    else
    
    Endif
    
    ; start app
    ShellExecute( $appName )
    if ( 0 = WinWaitActive( $winName, "", 1 ) ) Then
       ConsoleWrite("No App")
       Exit
    endif
    
    ; to update
    ControlCommand($winName, "", "[NAME:tabControl1]", "TabRight","" )
    if 0 = WinWaitActive( $winName, "Node1", 1 ) Then
       exitApp( "Fail page" )
       Exit
    EndIf
    
    ; set device
    ControlSetText( $winName, "","[CLASS:Edit; INSTANCE:3]", $deviceName )
    
    ; open
    ControlClick( $winName, "", "[NAME:button_open]")
    
    Local $openTxt
    $openTxt = ControlGetText( $winName, "", "[NAME:button_open]" )
    ;ConsoleWrite($openTxt)
    if $openTxt = "打开设备" Then
       exitApp( "Fail open" )
    EndIf
    
    ; search
    ControlClick( $winName, "", "[NAME:button_reseach]");
    
    Local $deviceNum
    $deviceNum = ControlGetText( $winName, "", "[NAME:textBox_node_number]" )
    if ( $deviceNum <> 1 ) Then
       exitApp("No Device")
       Exit
    EndIf
    
    ; set file name
    ControlSetText( $winName,"","[NAME:textBox_update_file_can]", $updName)
    Sleep( 1000 )
    
    ; program
    ControlClick( $winName, "", "[NAME:button_start_can]")
    
    if ( 0 == WinWaitActive( $winName, "升级完成!", 600 ) ) Then
          exitApp("Fail program")
    EndIf
    
    ; completed
    exitApp( "OK" )
    
    
    Func exitApp( $str )
       ConsoleWrite($str)
       WinClose( $winName )
       Exit
    EndFunc
    

    相关文章

      网友评论

          本文标题:重温AutoIt

          本文链接:https://www.haomeiwen.com/subject/eknwyftx.html