Automation

Example of a Keyboard Maestro macro

I use Keyboard Maestro to further enhance my productivity in CafeTran. Here is an example of a generic macro, that can be used in any Mac editor:

Duplicate line

See also: Using Keyboard Maestro macros in CafeTran in the Keyboard Maestro Wiki

Zen or the Art of Automation

Automation is a beautiful hobby. And even better: it's a hobby that pays well. Curious? [Read more]

Intro: http://www.youtube.com/watch?feature=player_embedded&v=tx4FCYDuJXo

Example: http://cafetran.wikidot.com/unpack-transit-projects-automatically

Example:

Mining Google Translate

Macros are great little time-savers.

A great improvement is this new keyboard shortcut:

  • 2014-07-12 New keyboard shortcut: Window > Segment windows > Request focus in target segment window CTRL+SHIFT+F12, important for automation with AutoHotkey (Windows) or Keyboard Maestro (Mac), works in the translation editor, the Add term dialogue, Quick Term Editor and in the Find and Replace dialogue.

We now have:

keys.png

When you want to enhance CafeTran with your own macros, it is important that you can position the caret exactly where the output of your macro has to be inserted. In the past this was difficult to do and it required quite some tricks (finding images of screen elements etc.) to achieve this.

Now CafeTran offers a "real" keyboard shortcut to position the caret directly in the target pane of the translation editor, the Find and Replace dialogue, the Add term dialogue and the Quick Term Editor.

When you switch to another application, e.g. a dictionary, you can make sure that on the return your caret is placed exactly where you want it to be: in the target pane. This target pane will serve as an anchor. With a simple TAB you can switch to the source pane.

  • 2014-09-07 Now there is also a keyboard shortcut to reload a glossary, useful for macros that add term pairs to a glossary.

AutoHotkey scripts for CafeTran

-----------------——*
; Michael Beijer's AHK scripts [See: Beijerdeas.com]

-----------------——*
#IfWinActive, CafeTran
NumpadDel:: ; The delete key on my numper pad (NumpadDel) auto-deletes entry in CafeTran Glossary (if mouse pointer is on it). Basically, this script clicks on the entry in the Glossary pane, tabs through any Glossary metadata fields in the Quick Term editor, past the OK button, and clicks on ‘Delete.

SendInput {Click,Left}
Sleep 5
Send {TAB down}{TAB up}
Sleep 5
Send {TAB down}{TAB up}
Sleep 5
Send {TAB down}{TAB up}
Sleep 5
Send {TAB down}{TAB up}
Sleep 5
Send {TAB down}{TAB up}
Sleep 5
Send {TAB down}{TAB up}
Sleep 5
Send {TAB down}{TAB up}
Sleep 5
Send {TAB down}{TAB up}
Sleep 5
Send {TAB down}{TAB up}
Sleep 5
Send {TAB down}{TAB up}
Sleep 5
Send {TAB down}{TAB up}
Sleep 5
Send {Enter}

Return

-----------------——*
Media_Next:: ; numberpad Media Next inserts current tag in CafeTran
SendInput !9
return

-----------------——*
; https://groups.google.com/forum/?fromgroups=#!topic/cafetranslators/l6pwA3RG570
; add terms to Glossary without selecting anything (obsolte because of new shortcut)

!h::
ClipWait, 1
Send ^a{Tab}^a!g!1
return

-----------------——*
NumpadIns:: ; numberpad Insert (0) to send to gloss#1 (= Glossary.csv)
ClipWait, 1
SendInput !g!1
return

NumpadLeft:: ; numberpad Left arrow (4) to send to gloss#2 (= Project.csv)
ClipWait, 1
SendInput !g!2
ClipWait, 1
return

NumpadClear:: ; numberpad Clear (5) to send to Non-translatables (NTs)
ClipWait, 1
SendInput ^!j{enter}
ClipWait, 1
return

-----------------——*
; Script to delete ‘R’s in CafeTran bilingual files
#!r::
Send {Tab}{Tab}{Delete}
return

-----------------——*
^+d::
Send, {Del}{Space}{Left} ;deletes selection and moves cursor one space to the left (useful when editing your translation and using auto-complete)
return

-----------------——*
^Space::
Send, {Space}{Left} ;Ctrl+Space moves cursor one space to the left (useful when editing your translation and using auto-complete)
return

-----------------——*
;typing the ‘ character sends a right click (useful if your keyboard doesn’t have an Menu key: http://en.wikipedia.org/wiki/Menu_key)

`::
SendInput {Click,Right}
return

-----------------——*
; move your caret to a misspelled word that is underlined and click this to automatically select the correct spelling (it does the following: moves mouse pointer to caret, right-clicks, clicks down, once, and enters) usually, the first option down is the correct one. MIGHT NEED SOME TWEAKING: stoppe dworking for me recently.

#IfWinActive, CafeTran
#Persistent
CoordMode, Caret, Screen

^+#:: ; Ctrl+Shift #
MovePosX:=A_CaretX +550 ; Adjust 5 pixels to the right of A_CaretX position
MovePosY:=A_CaretY -10 ; Adjust 10 Pixels above A_CaretY position
MouseMove, %MovePosX% , %MovePosY%

SendInput {Click,Right}
Send, {Down}{Enter}

Return

-----------------——*
; clone target term in CafeTran's New Term dialogue
; (shortcut triggers: Ctrl+A, Ctrl+C, Right arrow, insert semicolon, paste clipboard)

#IfWinActive, New Term
#Persistent

F10::
Send ^a^c{Right}{;}
Send %clipboard%
return

-----------------——*
; AUTOHOTKEY KEYS AND COMMANDS:
; a ‘;’ comments out a line of code
; ! = Alt
; ^ = Control
; # = windows
; + = shift
; {Right} = Right arrow
; click = left mouse click
; Click Right = right mouse click
; Space - the spacebar
; Tab
; Enter (or Return)
; Escape (or Esc)
; Backspace (or BS)
; Delete (or Del)
; Insert (or Ins)
; Home
; End
; PgUp
; PgDn
; Up
; Down
; Left
; Right

; ScrollLock
; CapsLock
; NumLock

; Numlock ON Numlock OFF
; Numpad0 NumpadIns
; Numpad1 NumpadEnd
; Numpad2 NumpadDown
; Numpad3 NumpadPgDn
; Numpad4 NumpadLeft
; Numpad5 NumpadClear
; Numpad6 NumpadRight
; Numpad7 NumpadHome
; Numpad8 NumpadUp
; Numpad9 NumpadPgUp
; NumpadDot (.) NumpadDel
; NumpadDiv (/) NumpadDiv (/)
; NumpadMult (*) NumpadMult (*)
; NumpadAdd (+) NumpadAdd (+)
; NumpadSub (-) NumpadSub (-)
; NumpadEnter NumpadEnter
;
-------------—-*

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License