Skip to content

Instantly share code, notes, and snippets.

@OKsign
Created April 10, 2018 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OKsign/a7074670c0cb219cc2ecb171d9676237 to your computer and use it in GitHub Desktop.
Save OKsign/a7074670c0cb219cc2ecb171d9676237 to your computer and use it in GitHub Desktop.
<?xml version="1.0"?>
<root>
<vkopenurldef>
<name>KeyCode::VK_OPEN_URL_91</name>
<url type="shell">
osascript -e '
set sName to "91"
tell application "System Events"
tell process "SystemUIServer"
click (menu bar item 1 of menu bar 1 whose description is "AppleScript")
end tell
delay 0.2
tell application "System Events"
keystroke sName
delay 0.2
key code 36
end tell
end tell
'
</url>
</vkopenurldef>
<item>
<name>My Key 91: Copy Text from Web Browser to Specific App Based on Word and Window Name_Hold T</name>
<identifier>Copy Text from Web Browser to Specific App Based on Word and Window Name_Hold T</identifier>
<only>FIREFOX,SAFARI,GOOGLE_CHROME,OPERA</only>
<autogen>
--HoldingKeyToKey--
KeyCode::T, ModifierFlag::NONE,
@begin
KeyCode::T,
@end
@begin
<!-- run via script menu -->
KeyCode::VK_OPEN_URL_91,
@end
Option::NOREPEAT,
</autogen>
</item>
</root>
<!-- script-Copy Text from Web Browser to Specific App Based on Word and Window Name:
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 (to disable 'atleast', set it to 0)
-- group1
set word1 to {"item1", "item2"}
set atleast_word1 to 0
set winName1 to {"item1", "item2"}
set atleast_winName1 to 0
set app1 to "app"
-- group2
set word2 to {"item1", "item2"}
set atleast_word2 to 0
set winName2 to {"item1", "item2"}
set atleast_winName2 to 0
set app2 to "app"
-- group3
set word3 to {"item1", "item2"}
set atleast_word3 to 0
set winName3 to {"item1", "item2"}
set atleast_winName3 to 0
set app3 to "app"
-- end of user input
tell application "System Events"
set activeApp to (get name of first process where it is frontmost)
end tell
-- cal def group1
if atleast_word1 = 0 then
set w1 to 0
else
set w1 to 1
end if
if atleast_winName1 = 0 then
set n1 to 0
else
set n1 to 1
end if
set def1 to w1 + n1
-- end of cal def group1
-- cal def group2
if atleast_word2 = 0 then
set w2 to 0
else
set w2 to 1
end if
if atleast_winName2 = 0 then
set n2 to 0
else
set n2 to 1
end if
set def2 to w2 + n2
-- end of cal def group2
-- cal def group3
if atleast_word3 = 0 then
set w3 to 0
else
set w3 to 1
end if
if atleast_winName3 = 0 then
set n3 to 0
else
set n3 to 1
end if
set def3 to w3 + n3
-- end of cal def group3
set exList to {"TextEdit", "Atom", "OpenOffice.org"}
if activeApp is "Opera" then
tell application "Opera"
set winName to (get title of front window)
end tell
end if
if activeApp is "Google Chrome" then
tell application "Google Chrome"
set winName to (get title of front window)
end tell
end if
if activeApp is "Safari" then
tell application "Safari"
set winName to (get name of front window)
end tell
end if
if activeApp is "Firefox" then
tell application "Firefox"
set winName to (get name of front window)
end tell
end if
delay 0.02
-- group1
if def1 = 2 then
set ansW to 0
set ansN to 0
repeat with n from 1 to (count item of foo's okAddresses)
if (item n of foo's okAddresses) is in word1 then
set y to 1
set ansW to ansW + y
if ansW is equal to atleast_word1 then
delay 0.02
set meetWord to 1
repeat with j in winName1
if winName contains j then
set y to 1
set ansN to ansN + y
if ansN is equal to atleast_winName1 then
set meetName to 1
set meetGroup1 to meetWord + meetName
if meetGroup1 = 2 then
delay 0.02
if app1 is "TextEdit" then
if application "TextEdit" is not running then
tell application app1
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 app1
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 app1
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 app1
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 app1 is "OpenOffice.org" then
if application "OpenOffice.org" is not running then
tell application app1
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 app1
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 app1 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 app1
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 app1 is not in exList then
tell application app1
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 app1
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
end if -- app1 is not in exList
end if -- meetGroup1 = 2
end if -- ans is equal to atleast_winName1
end if -- wURL contains j in winName1
end repeat
end if -- ans is equal to atleast_word1
end if -- if (item n of foo's okAddresses) is in word1
end repeat
end if -- def1 = 2
-- def1 = 1
if def1 = 1 then
delay 0.02
set ansW to 0
set ansN to 0
repeat with n from 1 to (count item of foo's okAddresses)
if (item n of foo's okAddresses) is in word1 then
set y to 1
set ansW to ansW + y
if ansW is equal to atleast_word1 then
delay 0.02
if app1 is "TextEdit" then
if application "TextEdit" is not running then
tell application app1
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 app1
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 app1
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 app1
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 app1 is "OpenOffice.org" then
if application "OpenOffice.org" is not running then
tell application app1
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 app1
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 app1 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 app1
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 app1 is not in exList then
tell application app1
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 app1
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
end if -- app1 is not in exList
end if -- ans is equal to atleast_word1
end if -- if (item n of foo's okAddresses) is in word1
end repeat
repeat with j in winName1
if winName contains j then
set y to 1
set ansN to ansN + y
if ansN is equal to atleast_winName1 then
delay 0.02
if app1 is "TextEdit" then
if application "TextEdit" is not running then
tell application app1
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 app1
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 app1
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 app1
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 app1 is "OpenOffice.org" then
if application "OpenOffice.org" is not running then
tell application app1
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 app1
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 app1 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 app1
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 app1 is not in exList then
tell application app1
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 app1
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
end if -- app1 is not in exList
end if -- ans is equal to atleast_winName1
end if -- if (item n of foo's okAddresses) is in winName1
end repeat
end if -- def1 = 1
-- end of group1
-- group2
if def2 = 2 then
set ansW to 0
set ansN to 0
repeat with n from 1 to (count item of foo's okAddresses)
if (item n of foo's okAddresses) is in word2 then
set y to 1
set ansW to ansW + y
if ansW is equal to atleast_word2 then
delay 0.02
set meetWord to 1
repeat with j in winName2
if winName contains j then
set y to 1
set ansN to ansN + y
if ansN is equal to atleast_winName2 then
set meetName to 1
set meetGroup2 to meetWord + meetName
if meetGroup2 = 2 then
delay 0.02
if app2 is "TextEdit" then
if application "TextEdit" is not running then
tell application app2
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 app2
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 app2
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 app2
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 app2 is "OpenOffice.org" then
if application "OpenOffice.org" is not running then
tell application app2
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 app2
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 app2 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 app2
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 app2 is not in exList then
tell application app2
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 app2
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
end if -- app2 is not in exList
end if -- meetgroup2 = 2
end if -- ans is equal to atleast_winName2
end if -- wURL contains j in winName2
end repeat
end if -- ans is equal to atleast_word2
end if -- if (item n of foo's okAddresses) is in word2
end repeat
end if -- def2 = 2
-- def2 = 1
if def2 = 1 then
delay 0.02
set ansW to 0
set ansN to 0
repeat with n from 1 to (count item of foo's okAddresses)
if (item n of foo's okAddresses) is in word2 then
set y to 1
set ansW to ansW + y
if ansW is equal to atleast_word2 then
delay 0.02
if app2 is "TextEdit" then
if application "TextEdit" is not running then
tell application app2
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 app2
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 app2
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 app2
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 app2 is "OpenOffice.org" then
if application "OpenOffice.org" is not running then
tell application app2
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 app2
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 app2 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 app2
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 app2 is not in exList then
tell application app2
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 app2
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
end if -- app2 is not in exList
end if -- ans is equal to atleast_word2
end if -- if (item n of foo's okAddresses) is in word2
end repeat
repeat with j in winName2
if winName contains j then
set y to 1
set ansN to ansN + y
if ansN is equal to atleast_winName2 then
delay 0.02
if app2 is "TextEdit" then
if application "TextEdit" is not running then
tell application app2
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 app2
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 app2
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 app2
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 app2 is "OpenOffice.org" then
if application "OpenOffice.org" is not running then
tell application app2
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 app2
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 app2 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 app2
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 app2 is not in exList then
tell application app2
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 app2
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
end if -- app2 is not in exList
end if -- ans is equal to atleast_winName2
end if -- if (item n of foo's okAddresses) is in winName2
end repeat
end if -- def2 = 1
-- end of group2
-- group3
if def3 = 2 then
set ansW to 0
set ansN to 0
repeat with n from 1 to (count item of foo's okAddresses)
if (item n of foo's okAddresses) is in word3 then
set y to 1
set ansW to ansW + y
if ansW is equal to atleast_word3 then
delay 0.02
set meetWord to 1
repeat with j in winName3
if winName contains j then
set y to 1
set ansN to ansN + y
if ansN is equal to atleast_winName3 then
set meetName to 1
set meetgroup3 to meetWord + meetName
if meetgroup3 = 2 then
delay 0.02
if app3 is "TextEdit" then
if application "TextEdit" is not running then
tell application app3
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 app3
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 app3
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 app3
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 app3 is "OpenOffice.org" then
if application "OpenOffice.org" is not running then
tell application app3
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 app3
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 app3 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 app3
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 app3 is not in exList then
tell application app3
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 app3
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
end if -- app3 is not in exList
end if -- meetgroup3 = 2
end if -- ans is equal to atleast_winName3
end if -- wURL contains j in winName3
end repeat
end if -- ans is equal to atleast_word3
end if -- if (item n of foo's okAddresses) is in word3
end repeat
end if -- def3 = 2
-- def3 = 1
if def3 = 1 then
delay 0.02
set ansW to 0
set ansN to 0
repeat with n from 1 to (count item of foo's okAddresses)
if (item n of foo's okAddresses) is in word3 then
set y to 1
set ansW to ansW + y
if ansW is equal to atleast_word3 then
delay 0.02
if app3 is "TextEdit" then
if application "TextEdit" is not running then
tell application app3
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 app3
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 app3
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 app3
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 app3 is "OpenOffice.org" then
if application "OpenOffice.org" is not running then
tell application app3
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 app3
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 app3 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 app3
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 app3 is not in exList then
tell application app3
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 app3
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
end if -- app3 is not in exList
end if -- ans is equal to atleast_word3
end if -- if (item n of foo's okAddresses) is in word3
end repeat
repeat with j in winName3
if winName contains j then
set y to 1
set ansN to ansN + y
if ansN is equal to atleast_winName3 then
delay 0.02
if app3 is "TextEdit" then
if application "TextEdit" is not running then
tell application app3
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 app3
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 app3
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 app3
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 app3 is "OpenOffice.org" then
if application "OpenOffice.org" is not running then
tell application app3
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 app3
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 app3 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 app3
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 app3 is not in exList then
tell application app3
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 app3
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
end if -- app3 is not in exList
end if -- ans is equal to atleast_winName3
end if -- if (item n of foo's okAddresses) is in winName3
end repeat
end if -- def3 = 1
-- end of group3
end addr
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment