Created
August 2, 2013 10:32
-
-
Save oiva/6138959 to your computer and use it in GitHub Desktop.
AppleScript for Hazel, that runs given PDF's through ABBYY FineReader Sprint 8.0 and stores the resulting text as a .txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on do_menu(app_name, menu_name, menu_item) | |
try | |
-- bring the target application to the front | |
tell application app_name | |
activate | |
end tell | |
tell application "System Events" | |
tell process app_name | |
tell menu bar 1 | |
tell menu bar item menu_name | |
tell menu menu_name | |
click menu item menu_item | |
end tell | |
end tell | |
end tell | |
end tell | |
end tell | |
return true | |
on error error_message | |
return false | |
end try | |
end do_menu | |
on hazelProcessFile(theFile) | |
tell application "TextEdit" to quit | |
tell application "ABBYY FineReader Sprint 8.0" | |
activate | |
end tell | |
do_menu("ABBYY FineReader Sprint 8.0", "File", "Close") | |
tell application "System Events" | |
tell process "ABBYY FineReader Sprint 8.0" | |
set posixpath to POSIX path of theFile | |
set default_location to "~/Dropbox/inbox" | |
click menu item "Convert to Text Document" of menu 1 of menu bar item "File" of menu bar 1 | |
keystroke "g" using {shift down, command down} | |
delay 1 | |
keystroke posixpath | |
delay 1 | |
keystroke return | |
delay 1 | |
keystroke return | |
delay 5 | |
repeat until exists window 2 | |
delay 1 | |
end repeat | |
click button "Save" of window 1 | |
end tell | |
end tell | |
repeat until application "TextEdit" is running | |
delay 1 | |
end repeat | |
do_menu("TextEdit", "Format", "Make Plain Text") | |
tell application "System Events" | |
tell process "TextEdit" | |
tell window 1 | |
if exists sheet 1 then | |
tell sheet 1 | |
click button "ok" | |
end tell | |
end if | |
end tell | |
end tell | |
end tell | |
do_menu("TextEdit", "File", "Save") | |
do_menu("TextEdit", "TextEdit", "Quit TextEdit") | |
end hazelProcessFile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment