重温AutoIt

2018-06-28  本文已影响0人  ww4u

steps

一键自动下载 一键程序下载

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

附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
上一篇下一篇

猜你喜欢

热点阅读