Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MaxSigns = 20 ; заменить на нужное
- watchfolder = %A_Desktop%\watchfolder ; заменить на истинный путь к папке с файлами титров
- prtlPath = %A_Desktop% ; указать путь к папке с исходными файлами
- FontName = Arial ; заменить на нужный
- FontSize = 10 ; заменить на нужный
- Bold = 1 ; оставить как есть, если bold, 0 — если обычный
- SetBatchLines, -1
- FileEncoding, UTF-16
- Return
- F11::
- i := n := PrevEndPos := 1
- FileRemoveDir, %watchfolder%, 1
- FileCreateDir, %watchfolder%
- ClipBoard =
- SendInput, ^{vk43} ; Ctrl + C
- ClipWait, 2
- if ErrorLevel
- {
- MsgBox, Буфер обмена пуст!
- Return
- }
- Sleep, 200
- 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++
- }
- k = n - 1
- FileRead, prtl, %prtlPath%\%k%.prtl
- XPos := 0, MinPos := 10000
- Loop % k
- {
- ; MsgBox, % "String" A_Index " = |" String%A_Index% "|"
- String := String%A_Index%
- StrLength := StrLen(String) + 1
- nSise := GetTextExtentPoint(String, FontName, FontSize, Bold)
- StrWidth := nSise & 0xFFFFFFFF
- Pos := Round((720 - StrWidth*3/4)/2)
- if (Pos < MinPos)
- MinPos := Pos
- MsgBox, % XPos := RegExMatch(prtl, "<XPos>", "", XPos + 1)
- prtl := RegExReplace(prtl, "<XPos>.*?</XPos>", "<XPos>" Pos "</XPos>", "", 1, XPos - 1)
- prtl := RegExReplace(prtl, "<CharacterAttributes RunCount="".*?"""
- , "<CharacterAttributes RunCount=""" StrLength """"
- , "", 1, XPos - 1)
- if (A_Index != k)
- prtl := RegExReplace(prtl, "<TRString TXMarker=""Booyah"">.*?</TRString>"
- , "<TRString TXMarker=""Booyah"">" String "</TRString>"
- , "", 1, XPos - 1)
- Else
- prtl := RegExReplace(prtl, "<TRString>.*?</TRString>"
- , "<TRString>" String "</TRString>")
- }
- prtl := RegExReplace(prtl, "<Position><x>.*?</x>", "<Position><x>" MinPos "</x>")
- FileAppend, %prtl%, %watchfolder%\reklama%k%.prtl
- 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)
- /*
- nWidth := nSize & 0xFFFFFFFF
- nHeight := nSize >> 32 & 0xFFFFFFFF
- */
- Return nSize
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement