; Microsoft Publisher #cs This is a modification of my TranZvoo range of scripts, which are a type of pasters. The TranZvoo scripts can't handle non-uniques, but are otherwise quite useful. The variable names refer to "glossary" because the TranZvoo script was originally based on a glossary look-up script. The script assumes that the mini TM is a plain text file in UTF8 with BOM, in which a line break plus {{{BOX:000:BOX}}} (with an ID number instead of 000) plus a line break is the text to be found, followed by the text to be pasted. In other words, a mini TM that was created by the publisher_extract.au3 script. #ce #include #Include Global $fileopenhtml, $glossaryfilecolumns, $glossaryfilelines, $glossaryfileopen, $glossaryfileopendialog, $glossaryfileread, $grabbedtext, $grabbedword, $grabbedwordarray, $htmloutput, $i, $j, $k, $l, $output, $found MsgBox (0, "Publisher Paster v01", "Publisher Paster (a TranZvoo script) looks up strings in a mini-TM." & @CRLF & @CRLF & "Shortcuts:" & @CRLF & @CRLF & "` = find translation and paste it" & @CRLF & "WinKey + Q = Exit the program (or right-click its icon)", 0) HotKeySet("`", "seekandpaste") HotKeySet("#q", "exitty") $glossaryfileopendialog = FileOpenDialog ("Select mini-TM", @ScriptDir, "Text files (*.txt)|All files (*.*)") $glossaryfileopen = FileOpen ($glossaryfileopendialog, 128) ; 128 means UTF8, 32 means UTF16LE $glossaryfileread = FileRead ($glossaryfileopen) $glossaryfilelines = StringSplit ($glossaryfileread, @CRLF & "{{{BOX:", 3) Global $glossaryfilefirstcolumn[UBound ($glossaryfilelines)] Global $glossaryfilesecondcolumn[UBound ($glossaryfilelines)] For $i = 0 to UBound ($glossaryfilelines) - 1 $glossaryfilecolumns = StringSplit ($glossaryfilelines[$i], ":BOX}}}" & @CRLF, 3) If UBound ($glossaryfilecolumns) = 2 Then ; i.e. if there is 2 columns in the line $glossaryfilefirstcolumn[$i] = $glossaryfilecolumns[0] $glossaryfilesecondcolumn[$i] = $glossaryfilecolumns[1] EndIf Next While 1 Sleep ("100") WEnd Func exitty () Exit EndFunc Func seekandpaste () Send ("^a") Sleep ("100") Send ("^c") Sleep ("100") $grabbedtext = ClipGet() Sleep ("200") If NOT StringInStr ($grabbedtext, "{{{BOX:") Then MsgBox (0, "", "Error, can't see ID", 0) Return EndIf $grabbedtext = StringReplace ($grabbedtext, "{{{BOX:", "") $grabbedtext = StringReplace ($grabbedtext, ":BOX}}}", "") $grabbedtext = StringReplace ($grabbedtext, @CRLF, "") $output = "" $found = 0 For $m = 0 to UBound ($glossaryfilelines) - 1 If $found = 0 Then If StringCompare ($grabbedtext, $glossaryfilefirstcolumn[$m], 1) = 0 Then $output = $glossaryfilesecondcolumn[$m] $found = 1 EndIf EndIf Next If $found = 0 Then MsgBox (0, "No translation found!", "Could not find a translation for [" & $grabbedtext & "].", 0) Else ClipPut ($output) Send ("^v") Sleep ("100") EndIf EndFunc