Что нового

Как из буфера обмена получить определенные данные?

Math

Новичок
Сообщения
85
Репутация
1
Как из буфера обмена получить определенные данные?

Например, в буфере есть текст:
General
Complete name : D:\Users\Temp-AlexS\Downloads\lang\zzz\002_001_Vid.wmv
Format : Windows Media
File size : 651 MiB
Duration : 11mn 11s
Overall bit rate mode : Constant
Overall bit rate : 8 129 Kbps
Maximum Overall bit rate : 8 303 Kbps
Encoded date : UTC 2011-06-25 19:50:53.674

Video
ID : 2
Format : VC-1
Format profile : MP@HL
Codec ID : WMV3
Codec ID/Info : Windows Media Video 9
Codec ID/Hint : WMV3
Description of the codec : Windows Media Video 9 - Professional
Duration : 11mn 11s
Bit rate mode : Constant
Bit rate : 8 000 Kbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate : 50.000 fps
Bit depth : 8 bits
Scan type : Progressive
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.174
Stream size : 641 MiB (98%)
NumberOfFrames : 33570

Audio
ID : 1
Format : WMA
Format profile : Pro
Codec ID : 162
Codec ID/Info : Windows Media Audio
Description of the codec : Windows Media Audio 10 Professional - 256 kbps, 44 kHz, 2 channel 24 bit 2-pass CBR
Duration : 11mn 11s
Bit rate mode : Constant
Bit rate : 256 Kbps
Channel(s) : 2 channels
Sampling rate : 44.1 KHz
Bit depth : 24 bits
Stream size : 20.5 MiB (3%)
NumberOfFrames : 1811

Как из него получить значения Duration, Width и Height, и записать их ввиде переменных?
Код:
$Duration = "11mn 11s"
$Width = "1 280 pixels"
$Height = "720 pixels"
 

CreatoR

Must AutoIt!
Команда форума
Администратор
Сообщения
8,671
Репутация
2,481
Код:
$sData = ClipGet()

$Duration = _GetData($sData, "Duration")
$Width = _GetData($sData, "Width")
$Height = _GetData($sData, "Height")

ConsoleWrite("Duration: " & $Duration & @LF)
ConsoleWrite("Width: " & $Width & @LF)
ConsoleWrite("Height: " & $Height & @LF)

Func _GetData($sData, $sKey)
	Return StringRegExpReplace($sData, '(?is).*' & $sKey & '\s*: ([^\r\n]*).*', '\1')
EndFunc
 

AZJIO

Меценат
Меценат
Сообщения
2,874
Репутация
1,194
Math
Код:
$html = FileRead(@ScriptDir&'\file.txt')
; ClipPut($html)

$Duration=StringRegExpReplace($html, '(?s)(?:.*?Duration\s+?: )(\d[\d mns]*)(?:.*)', '\1')
$Width=StringRegExpReplace($html, '(?s)(?:.*?Width\s+?: )(\d[\d ]* pixels)(?:.*)', '\1')
$Height=StringRegExpReplace($html, '(?s)(?:.*?Height\s+?: )(\d[\d ]* pixels)(?:.*)', '\1')

MsgBox(0, 'Сообщение', $Duration &@CRLF& $Width &@CRLF&$Height)
 

CreatoR

Must AutoIt!
Команда форума
Администратор
Сообщения
8,671
Репутация
2,481
AZJIO
А зачем 3 группы, 1-ую и 3-юю не обязательно делать группой, в них нет никаких условий.
 
Верх