OK,又改进了下,不错!3Q
_devicesAttached()
Func _devicesAttached();连接的设备
Local $__sqliteDeviceInfo
$__adbRequest = _adbCommand('devices -l');连接的设备列表
$__listDevice = StringRegExp($__adbRequest, '(?s)List of devices attached\v+(.+)', 3);拆分成行
If Not IsArray($__listDevice) Then
MsgBox(0, '', '无连接的设备!')
Exit
EndIf
$__listDevice = StringRegExp($__listDevice[0], '\V+', 3);拆分成行
$__deviceCount = UBound($__listDevice) - 1;设备数量
For $i = 0 To $__deviceCount
Local $__deviceInfo[9]
$__serial = _StringRegExpEx($__listDevice[$i], '(?i)^(\S+)')
_SQLite_QuerySingleRow($TodoDB, 'SELECT * FROM "default" WHERE serial="' & $__serial & '"', $__sqliteDeviceInfo)
If IsArray($__sqliteDeviceInfo) Then;数据库存在,当前已连接设备信息,则适用数据库信息
Assign($__serial, $__sqliteDeviceInfo, 2)
Else
Assign($__serial, $__deviceInfo, 2)
$__deviceInfo[0] = _StringRegExpEx($__listDevice[$i], '(?i)^(\S+)')
$__deviceInfo[1] = _StringRegExpEx($__listDevice[$i], '(?i)product:(\S+)')
$__deviceInfo[2] = _StringRegExpEx($__listDevice[$i], '(?i)model:(\S+)')
$__deviceInfo[3] = _StringRegExpEx($__listDevice[$i], '(?i)device:(\S+)')
$__deviceInfo[4] = _StringRegExpEx($__listDevice[$i], '(?i)transport_id:(\S+)')
$__sqliteCommand = StringFormat('REPLACE INTO "%s" VALUES ("%s")', 'default', _ArrayToString(Eval($__serial), '","'))
_SQLite_Exec($TodoDB, $__sqliteCommand)
EndIf
Next
_ArrayDisplay(Eval($__serial))
EndFunc ;==>_devicesAttached
Func _StringRegExpEx($__str, $__pattern)
$__result = StringRegExp($__str, $__pattern, 3)
If @error Then Return
Return $__result[0]
EndFunc ;==>_StringRegExpEx
|