Created
March 22, 2018 08:57
-
-
Save OKsign/eac136d4417d7020aa1e375247d51b63 to your computer and use it in GitHub Desktop.
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
tell application "System Events" | |
keystroke "c" using command down | |
delay 0.5 | |
set CopT to (the clipboard as text) | |
end tell | |
set AppleScript's text item delimiters to the {" ", ".",",",";","(",")"} | |
set x to every text item of CopT | |
addr(x) | |
to addr(l) | |
script foo | |
property foo2 : l | |
property okAddresses : {} | |
end script | |
repeat with i from 1 to count (foo's foo2) | |
set x to ((foo's foo2)'s item i) | |
if x is in foo's okAddresses then | |
else | |
set end of foo's okAddresses to x | |
end if | |
end repeat | |
-- user input (word, atleast or doc) | If you choose to open document (set doc), copied text will not be pasted. | |
-- word1 | |
set word1 to {{"item1", "item2"}, {"app"}} | |
set atleast_word1 to 0 | |
set doc_word1 to "" | |
-- word2 | |
set word2 to {{"item1", "item2"}, {"app"}} | |
set atleast_word2 to 0 | |
set doc_word2 to "" | |
-- word3 | |
set word3 to {{"item1", "item2"}, {"app"}} | |
set atleast_word3 to 0 | |
set doc_word3 to "" | |
-- word4 | |
set word4 to {{"item1", "item2"}, {"app"}} | |
set atleast_word4 to 0 | |
set doc_word4 to "" | |
-- word5 | |
set word5 to {{"item1", "item2"}, {"app"}} | |
set atleast_word5 to 0 | |
set doc_word5 to "" | |
-- end of user input | |
-- word1 | |
set ans to 0 | |
repeat with N from 1 to (count item of foo's okAddresses) | |
if (item N of foo's okAddresses) is in (item 1 of word1) then | |
set y to 1 | |
set ans to ans + y | |
if ans is equal to atleast_word1 then | |
if doc_word1 is not "" then | |
set y to POSIX file doc_word1 | |
tell application "Finder" | |
open y | |
end tell | |
end if | |
delay 0.02 | |
if doc_word1 is "" then | |
if (item 1 of item 2 of word1) is "TextEdit" then | |
delay 0.02 | |
if application "TextEdit" is not running then | |
tell application (item 1 of item 2 of word1) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word1) | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
delay 1 | |
tell application "System Events" | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
else -- textedit is running | |
tell application (item 1 of item 2 of word1) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word1) | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end if | |
end if | |
if (item 1 of item 2 of word1) is "OpenOffice.org" then | |
if application "OpenOffice.org" is not running then | |
tell application (item 1 of item 2 of word1) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is "soffice" | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
delay 1 | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
else | |
tell application (item 1 of item 2 of word1) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is "soffice" | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
delay 1 | |
tell application "System Events" | |
tell process "soffice" | |
if menu bar item "Window" of menu bar 1 exists then | |
delay 0.4 | |
click menu bar item "File" of menu bar 1 | |
delay 1 | |
tell application "System Events" | |
delay 0.03 | |
key code 125 | |
delay 0.03 | |
key code 124 | |
delay 0.03 | |
key code 36 | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
else | |
tell application "System Events" | |
keystroke "t" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
end if | |
end tell | |
end tell | |
exit repeat | |
end if -- application "OpenOffice.org" is not running | |
end if | |
if (item 1 of item 2 of word1) is "Atom" then | |
if application "Atom Helper" is not running then | |
set atomFile to "/Applications/Atom.app" | |
set x to POSIX file atomFile | |
tell application "Finder" | |
open x | |
end tell | |
try | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word1) | |
delay 0.02 | |
tell application "System Events" | |
tell process "Atom" | |
set frontmost to true | |
end tell | |
end tell | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
end try | |
try | |
tell application "System Events" | |
repeat 9 times | |
delay 1 | |
tell process "Atom" | |
set frontmost to true | |
end tell | |
end repeat | |
keystroke "n" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end try | |
else -- atom is running | |
tell application "System Events" | |
tell process "Atom" | |
set frontmost to true | |
end tell | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 3 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end if -- atom is not running | |
end if | |
if (item 1 of item 2 of word1) is not "TextEdit" then | |
delay 0.2 | |
if (item 1 of item 2 of word1) is not "Atom" then | |
delay 0.2 | |
if (item 1 of item 2 of word1) is not "OpenOffice.org" then | |
tell application (item 1 of item 2 of word1) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word1) | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 0.7 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end if | |
end if | |
end if | |
end if | |
end if -- ans is equal to atleast | |
end if | |
end repeat | |
-- end of word1 | |
-- word2 | |
set ans to 0 | |
repeat with N from 1 to (count item of foo's okAddresses) | |
if (item N of foo's okAddresses) is in (item 1 of word2) then | |
set y to 1 | |
set ans to ans + y | |
if ans is equal to atleast_word2 then | |
if doc_word2 is not "" then | |
set y to POSIX file doc_word2 | |
tell application "Finder" | |
open y | |
end tell | |
end if | |
delay 0.02 | |
if doc_word2 is "" then | |
if (item 1 of item 2 of word2) is "TextEdit" then | |
delay 0.02 | |
if application "TextEdit" is not running then | |
tell application (item 1 of item 2 of word2) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word2) | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
delay 1 | |
tell application "System Events" | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
else -- textedit is running | |
tell application (item 1 of item 2 of word2) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word2) | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end if | |
end if | |
if (item 1 of item 2 of word2) is "OpenOffice.org" then | |
if application "OpenOffice.org" is not running then | |
tell application (item 1 of item 2 of word2) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is "soffice" | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
delay 1 | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
else | |
tell application (item 1 of item 2 of word2) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is "soffice" | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
delay 1 | |
tell application "System Events" | |
tell process "soffice" | |
if menu bar item "Window" of menu bar 1 exists then | |
delay 0.4 | |
click menu bar item "File" of menu bar 1 | |
delay 1 | |
tell application "System Events" | |
delay 0.03 | |
key code 125 | |
delay 0.03 | |
key code 124 | |
delay 0.03 | |
key code 36 | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
else | |
tell application "System Events" | |
keystroke "t" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
end if | |
end tell | |
end tell | |
exit repeat | |
end if -- application "OpenOffice.org" is not running | |
end if | |
if (item 1 of item 2 of word2) is "Atom" then | |
if application "Atom Helper" is not running then | |
set atomFile to "/Applications/Atom.app" | |
set x to POSIX file atomFile | |
tell application "Finder" | |
open x | |
end tell | |
try | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word2) | |
delay 0.02 | |
tell application "System Events" | |
tell process "Atom" | |
set frontmost to true | |
end tell | |
end tell | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
end try | |
try | |
tell application "System Events" | |
repeat 9 times | |
delay 1 | |
tell process "Atom" | |
set frontmost to true | |
end tell | |
end repeat | |
keystroke "n" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end try | |
else -- atom is running | |
tell application "System Events" | |
tell process "Atom" | |
set frontmost to true | |
end tell | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 3 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end if -- atom is not running | |
end if | |
if (item 1 of item 2 of word2) is not "TextEdit" then | |
delay 0.2 | |
if (item 1 of item 2 of word2) is not "Atom" then | |
delay 0.2 | |
if (item 1 of item 2 of word2) is not "OpenOffice.org" then | |
tell application (item 1 of item 2 of word2) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word2) | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 0.7 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end if | |
end if | |
end if | |
end if | |
end if -- ans is equal to atleast | |
end if | |
end repeat | |
-- end of word2 | |
-- word3 | |
set ans to 0 | |
repeat with N from 1 to (count item of foo's okAddresses) | |
if (item N of foo's okAddresses) is in (item 1 of word3) then | |
set y to 1 | |
set ans to ans + y | |
if ans is equal to atleast_word3 then | |
if doc_word3 is not "" then | |
set y to POSIX file doc_word3 | |
tell application "Finder" | |
open y | |
end tell | |
end if | |
delay 0.02 | |
if doc_word3 is "" then | |
if (item 1 of item 2 of word3) is "TextEdit" then | |
delay 0.02 | |
if application "TextEdit" is not running then | |
tell application (item 1 of item 2 of word3) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word3) | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
delay 1 | |
tell application "System Events" | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
else -- textedit is running | |
tell application (item 1 of item 2 of word3) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word3) | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end if | |
end if | |
if (item 1 of item 2 of word3) is "OpenOffice.org" then | |
if application "OpenOffice.org" is not running then | |
tell application (item 1 of item 2 of word3) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is "soffice" | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
delay 1 | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
else | |
tell application (item 1 of item 2 of word3) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is "soffice" | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
delay 1 | |
tell application "System Events" | |
tell process "soffice" | |
if menu bar item "Window" of menu bar 1 exists then | |
delay 0.4 | |
click menu bar item "File" of menu bar 1 | |
delay 1 | |
tell application "System Events" | |
delay 0.03 | |
key code 125 | |
delay 0.03 | |
key code 124 | |
delay 0.03 | |
key code 36 | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
else | |
tell application "System Events" | |
keystroke "t" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
end if | |
end tell | |
end tell | |
exit repeat | |
end if -- application "OpenOffice.org" is not running | |
end if | |
if (item 1 of item 2 of word3) is "Atom" then | |
if application "Atom Helper" is not running then | |
set atomFile to "/Applications/Atom.app" | |
set x to POSIX file atomFile | |
tell application "Finder" | |
open x | |
end tell | |
try | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word3) | |
delay 0.02 | |
tell application "System Events" | |
tell process "Atom" | |
set frontmost to true | |
end tell | |
end tell | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
end try | |
try | |
tell application "System Events" | |
repeat 9 times | |
delay 1 | |
tell process "Atom" | |
set frontmost to true | |
end tell | |
end repeat | |
keystroke "n" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end try | |
else -- atom is running | |
tell application "System Events" | |
tell process "Atom" | |
set frontmost to true | |
end tell | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 3 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end if -- atom is not running | |
end if | |
if (item 1 of item 2 of word3) is not "TextEdit" then | |
delay 0.2 | |
if (item 1 of item 2 of word3) is not "Atom" then | |
delay 0.2 | |
if (item 1 of item 2 of word3) is not "OpenOffice.org" then | |
tell application (item 1 of item 2 of word3) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word3) | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 0.7 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end if | |
end if | |
end if | |
end if | |
end if -- ans is equal to atleast | |
end if | |
end repeat | |
-- end of word3 | |
-- word4 | |
set ans to 0 | |
repeat with N from 1 to (count item of foo's okAddresses) | |
if (item N of foo's okAddresses) is in (item 1 of word4) then | |
set y to 1 | |
set ans to ans + y | |
if ans is equal to atleast_word4 then | |
if doc_word4 is not "" then | |
set y to POSIX file doc_word4 | |
tell application "Finder" | |
open y | |
end tell | |
end if | |
delay 0.02 | |
if doc_word4 is "" then | |
if (item 1 of item 2 of word4) is "TextEdit" then | |
delay 0.02 | |
if application "TextEdit" is not running then | |
tell application (item 1 of item 2 of word4) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word4) | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
delay 1 | |
tell application "System Events" | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
else -- textedit is running | |
tell application (item 1 of item 2 of word4) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word4) | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end if | |
end if | |
if (item 1 of item 2 of word4) is "OpenOffice.org" then | |
if application "OpenOffice.org" is not running then | |
tell application (item 1 of item 2 of word4) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is "soffice" | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
delay 1 | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
else | |
tell application (item 1 of item 2 of word4) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is "soffice" | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
delay 1 | |
tell application "System Events" | |
tell process "soffice" | |
if menu bar item "Window" of menu bar 1 exists then | |
delay 0.4 | |
click menu bar item "File" of menu bar 1 | |
delay 1 | |
tell application "System Events" | |
delay 0.03 | |
key code 125 | |
delay 0.03 | |
key code 124 | |
delay 0.03 | |
key code 36 | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
else | |
tell application "System Events" | |
keystroke "t" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
end if | |
end tell | |
end tell | |
exit repeat | |
end if -- application "OpenOffice.org" is not running | |
end if | |
if (item 1 of item 2 of word4) is "Atom" then | |
if application "Atom Helper" is not running then | |
set atomFile to "/Applications/Atom.app" | |
set x to POSIX file atomFile | |
tell application "Finder" | |
open x | |
end tell | |
try | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word4) | |
delay 0.02 | |
tell application "System Events" | |
tell process "Atom" | |
set frontmost to true | |
end tell | |
end tell | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
end try | |
try | |
tell application "System Events" | |
repeat 9 times | |
delay 1 | |
tell process "Atom" | |
set frontmost to true | |
end tell | |
end repeat | |
keystroke "n" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end try | |
else -- atom is running | |
tell application "System Events" | |
tell process "Atom" | |
set frontmost to true | |
end tell | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 3 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end if -- atom is not running | |
end if | |
if (item 1 of item 2 of word4) is not "TextEdit" then | |
delay 0.2 | |
if (item 1 of item 2 of word4) is not "Atom" then | |
delay 0.2 | |
if (item 1 of item 2 of word4) is not "OpenOffice.org" then | |
tell application (item 1 of item 2 of word4) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word4) | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 0.7 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end if | |
end if | |
end if | |
end if | |
end if -- ans is equal to atleast | |
end if | |
end repeat | |
-- end of word4 | |
-- word5 | |
set ans to 0 | |
repeat with N from 1 to (count item of foo's okAddresses) | |
if (item N of foo's okAddresses) is in (item 1 of word5) then | |
set y to 1 | |
set ans to ans + y | |
if ans is equal to atleast_word5 then | |
if doc_word5 is not "" then | |
set y to POSIX file doc_word5 | |
tell application "Finder" | |
open y | |
end tell | |
end if | |
delay 0.02 | |
if doc_word5 is "" then | |
if (item 1 of item 2 of word5) is "TextEdit" then | |
delay 0.02 | |
if application "TextEdit" is not running then | |
tell application (item 1 of item 2 of word5) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word5) | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
delay 1 | |
tell application "System Events" | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
else -- textedit is running | |
tell application (item 1 of item 2 of word5) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word5) | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end if | |
end if | |
if (item 1 of item 2 of word5) is "OpenOffice.org" then | |
if application "OpenOffice.org" is not running then | |
tell application (item 1 of item 2 of word5) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is "soffice" | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
delay 1 | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
else | |
tell application (item 1 of item 2 of word5) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is "soffice" | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
delay 1 | |
tell application "System Events" | |
tell process "soffice" | |
if menu bar item "Window" of menu bar 1 exists then | |
delay 0.4 | |
click menu bar item "File" of menu bar 1 | |
delay 1 | |
tell application "System Events" | |
delay 0.03 | |
key code 125 | |
delay 0.03 | |
key code 124 | |
delay 0.03 | |
key code 36 | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
else | |
tell application "System Events" | |
keystroke "t" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
end if | |
end tell | |
end tell | |
exit repeat | |
end if -- application "OpenOffice.org" is not running | |
end if | |
if (item 1 of item 2 of word5) is "Atom" then | |
if application "Atom Helper" is not running then | |
set atomFile to "/Applications/Atom.app" | |
set x to POSIX file atomFile | |
tell application "Finder" | |
open x | |
end tell | |
try | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word5) | |
delay 0.02 | |
tell application "System Events" | |
tell process "Atom" | |
set frontmost to true | |
end tell | |
end tell | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
end try | |
try | |
tell application "System Events" | |
repeat 9 times | |
delay 1 | |
tell process "Atom" | |
set frontmost to true | |
end tell | |
end repeat | |
keystroke "n" using command down | |
delay 1 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end try | |
else -- atom is running | |
tell application "System Events" | |
tell process "Atom" | |
set frontmost to true | |
end tell | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 3 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end if -- atom is not running | |
end if | |
if (item 1 of item 2 of word5) is not "TextEdit" then | |
delay 0.2 | |
if (item 1 of item 2 of word5) is not "Atom" then | |
delay 0.2 | |
if (item 1 of item 2 of word5) is not "OpenOffice.org" then | |
tell application (item 1 of item 2 of word5) | |
activate | |
end tell | |
delay 0.2 | |
tell application "System Events" | |
set activeApp to (get name of first process where it is frontmost) | |
repeat until activeApp is (item 1 of item 2 of word5) | |
delay 0.02 | |
set activeApp to (get name of first process where it is frontmost) | |
end repeat | |
end tell | |
tell application "System Events" | |
keystroke "n" using command down | |
delay 0.7 | |
keystroke "v" using command down | |
end tell | |
exit repeat | |
end if | |
end if | |
end if | |
end if | |
end if -- ans is equal to atleast | |
end if | |
end repeat | |
-- end of word5 | |
end addr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment