本帖最后由 heavenm 于 2020-2-13 23:16 编辑 _androidConsole('adb exec-out /system/bin/uiautomator dump /dev/tty')
Func _androidConsole($__command, $__drives = Null, $__timeout = 9)
Local $__beginTime = TimerInit()
Local $__binary = True
Local $__consolePid, $__consoleStdout
ConsoleWrite(StringFormat('%s ][ %s \n', '_androidConsole', $__command))
If $__drives <> Null Then;如果指定了设备,则加上-s参数
$__drives = StringFormat('-s %s ', $__commandName, $__drives)
$__command = StringRegExpReplace($__command, '^(\w+) ', '\1' & $__drives)
EndIf
;~ If StringRegExp($__command, 'screencap') Then $__binary = True;如果是图片文件,用二进制
;~ If StringRegExp($__command, 'uiautomator') Then $__binary = True ;二进制输出
$__consolePid = Run(@ComSpec & " /c " & $__command, @ScriptDir, @SW_HIDE, 8)
Do
Sleep(300)
If TimerDiff($__beginTime) > $__timeout * 1000 Then Exit;命令超时退出
Until Not ProcessExists($__consolePid)
;~ ProcessWaitClose($__consolePid, $__timeout)
;~ If @error Then MsgBox(0, '', '超时!!!')
$__consoleStdout = StdoutRead($__consolePid, False, $__binary)
If Not StringRegExp($__command, 'screencap') Then $__consoleStdout = BinaryToString($__consoleStdout, 4)
;~ If StringRegExp($__consoleStdout, 'unknown') Then Return -1;华为或者android9 dumpsys window policy 会输出unknown
ConsoleWrite(StringFormat('%s ][ %s ][ %s \n', '_androidConsole', TimerDiff($__beginTime), $__command))
Return $__consoleStdout
EndFunc ;==>_androidConsole
|