Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MaxSigns = 20 ; заменить на нужное
- watchfolder = %A_Desktop%\watchfolder ; заменить на истинный путь к папке с файлами титров
- prtlPath = %A_Desktop%\1.prtl ; заменить на истинный путь к исходному файлу 1.ptrl
- FontName = Arial ; заменить на нужный
- FontSize = 10 ; заменить на нужный
- FileEncoding, UTF-16
- FileRead, prtl, %prtlPath%
- Return
- F11::
- i := n := PrevEndPos := 1
- FileRemoveDir, %watchfolder%, 1
- FileCreateDir, %watchfolder%
- ClipBoard =
- SendInput, ^{vk43} ; Ctrl + C
- ClipWait, 2
- if ErrorLevel
- {
- MsgBox, Буфер обмена пуст!
- Return
- }
- Clipboard := RegExReplace(Clipboard, "\R+", "`n")
- Length := StrLen(Clipboard)
- Loop, parse, ClipBoard
- {
- if (A_Index = Length)
- EndPos := A_Index + 1
- if (A_LoopField = " " || A_LoopField = "`n")
- EndPos := A_Index
- if (A_Index = Length || A_LoopField = "`n" || i = MaxSigns + 1)
- {
- if !EndPos
- EndPos := A_Index + 1, Modifier := 1
- String%n% := SubStr(ClipBoard, PrevEndPos, EndPos - PrevEndPos)
- if Modifier
- PrevEndPos := EndPos, Modifier := ""
- Else
- PrevEndPos := EndPos + 1
- i := A_Index - EndPos, n++, EndPos := ""
- }
- i++
- }
- Loop % n - 1
- {
- ; MsgBox, % "String" A_Index " = |" String%A_Index% "|"
- String := String%A_Index%
- StrLength := StrLen(String) + 1
- nSise := GetTextExtentPoint(String, FontName, FontSize)
- StrWidth := nSise & 0xFFFFFFFF
- Pos := Round((720 - StrWidth)/2)
- prtl%A_Index% := RegExReplace(prtl, "<CharacterAttributes RunCount="".*?"""
- , "<CharacterAttributes RunCount=""" StrLength """")
- prtl%A_Index% := RegExReplace(prtl%A_Index%, "<TRString>.*?</TRString>"
- , "<TRString>" String "</TRString>")
- prtl%A_Index% := RegExReplace(prtl%A_Index%, "<XPos>.*?</XPos>"
- , "<XPos>" Pos "</XPos>")
- FileName := "title" . SubStr("000", 1, -(StrLen(A_Index))) . A_Index . ".prtl"
- FileAppend, % prtl%A_Index%, %watchfolder%\%FileName%
- }
- MsgBox, Сделано!
- Return
- GetTextExtentPoint(sString, sFaceName, nHeight = 9
- , bBold = False, bItalic = False, bUnderline = False, bStrikeOut = False, nCharSet = 0)
- {
- hDC := DllCall("GetDC", "Uint", 0)
- nHeight := -DllCall("MulDiv", "int", nHeight
- , "int", DllCall("GetDeviceCaps", "Uint", hDC, "int", 90)
- , "int", 72)
- hFont := DllCall("CreateFont", "int", nHeight, "int", 0, "int", 0, "int", 0
- , "int", 400 + 300 * bBold, "Uint", bItalic
- , "Uint", bUnderline, "Uint", bStrikeOut, "Uint", nCharSet
- , "Uint", 0, "Uint", 0, "Uint", 0, "Uint", 0, "str", sFaceName)
- hFold := DllCall("SelectObject", "Uint", hDC, "Uint", hFont)
- DllCall("GetTextExtentPoint32", "Uint", hDC, "str", sString, "int", StrLen(sString), "int64P", nSize)
- DllCall("SelectObject", "Uint", hDC, "Uint", hFold)
- DllCall("DeleteObject", "Uint", hFont)
- DllCall("ReleaseDC", "Uint", 0, "Uint", hDC)
- Return nSize
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement