I can do a lot of things with applescript, but I seem to be missing something obvious. I do a lot of linking in web replies and it is just a pain to type out the all the time. I figured I’d finally just assign it to a keystroke…Um, but I couldn’t get it done.
I edit scripts in word all the time to do this sort of thing, and all i want to do is have a global script that would let me press something like Command + Option +Shift +F1 and get a string entered ( possibly with a paste where the [url]is and moving the cursor to the position between the tags to name the link). Writing text to the current application has to be simple, but everywhere I look for solutions everything goes on-and-on about all the other more complicated stuff…
set clipurl to the clipboard
if clipurl starts with “http” then
set the clipboard to “<a href="” & clipurl & “" target="_blank">”
else
set the clipboard to “<a href="" target="_blank">”
end if
Stops me from entering something that isn’t really a URL
Just to complete the process…To get the info into the clipboard with a keystroke took a lot more doing than I’d supposed. Perhaps this will help someone…
I needed to create the script in Automator and save as an application, and thn run it via Butler, which is a free application that allows you to run a script application with a keystroke…
Create the script in Automator:
File>New
Choose Custom
Drag in Run Applescript from Actions
Paste in script
–
set clipurl to the clipboard
if clipurl starts with “http” then
set the clipboard to “<a href="” & clipurl & “" target="_blank">”
else
set the clipboard to “<a href="" target="_blank">”
end if
–
Locate butler after install on menubar and choose Customize
Add File with the button at lower left, choose the application stored previously.
Click the Triggers item on the right of the butler screen
Add the hot key by pressing the desired keys
Took far to many hours to figure this out…I can’t believe Apple doesn’t have a way to incorporate something like the quick keys here which had to be done via third party software. But now in my many travels to forums and the like I can create links in discussions by copying the URLs, using 3 keystrokes! (Copy, Refine Clipboard, Paste)