-- Builds HTML code for self-referencing link from selected text
--Adapted from the script "URL link bbcoder for the bbs." by Adam Bell: bbs.applescript.net/viewtopic.php
--The remaining comments are his
--Be careful with spaces in the selection
tell application "Finder"
set visible of process "Script Editor" to false -- Needed if runing the script from Script Editor. If a compiled app is double-clicked put its name in place of "Script Editor" (no extension). Comment this line out if the script is run by a key command to a hotkey application like QuicKeys or FastScripts.
set Front_App to item 1 of (get name of processes whose frontmost is true)
end tell
tell application Front_App to activate -- necessary if you've just hidden the Script Editor or your script.app
tell application "System Events"
tell process Front_App
keystroke "x" using {command down}
set theURL to the clipboard
keystroke " <a href=\""
keystroke "v" using {command down}
keystroke "\">"
keystroke "v" using {command down}
keystroke "</a> "
end tell
end tell
--Adapted from the script "URL link bbcoder for the bbs." by Adam Bell: bbs.applescript.net/viewtopic.php
--The remaining comments are his
--Be careful with spaces in the selection
tell application "Finder"
set visible of process "Script Editor" to false -- Needed if runing the script from Script Editor. If a compiled app is double-clicked put its name in place of "Script Editor" (no extension). Comment this line out if the script is run by a key command to a hotkey application like QuicKeys or FastScripts.
set Front_App to item 1 of (get name of processes whose frontmost is true)
end tell
tell application Front_App to activate -- necessary if you've just hidden the Script Editor or your script.app
tell application "System Events"
tell process Front_App
keystroke "x" using {command down}
set theURL to the clipboard
keystroke " <a href=\""
keystroke "v" using {command down}
keystroke "\">"
keystroke "v" using {command down}
keystroke "</a> "
end tell
end tell