Need an applescript so I can start to learn applescript

I’m interested in learning applescript for automating things, I have automation programs like btt and km but without applescript knowledge they aren’t that effective.

I stumbled onto this site somehow and seems interesting, anyway, I’m willing to put in the work to learn it myself, because SO are OCPD douchebags who take themselves way too seriously, paid freelancers generally don’t know applescript and if they do they charge alot and I’d prefer to do it myself.

Anyway, I need a simple script, I have 2 windows of chrome open, left window is a bookmark manager, right window is for reading/evaulating bookmarks, is there a script I can do that will send the link under the cursor of left window to a new tab on the right window, with a click or keypress, I can reassign it in a shortcut program so it’s not that important.

Tell application chrome window 1 window 2 etc? (sorry, I don’t know enough for an example script).

With this setup and notes, I can learn efficiently, would be much appreciated.

Welcome to it!

Here is a very simple script that works with Google Chrome. It does a few things.
Builds a URL out of text
Opens that URL in Chrome
Changes the URL
Makes a new window in Chrome
Opens the changed URL in the new window’s tab
This script (based on one I use every day to automate multiple google searches) should give you an idea about how AppleScript does the very basic things you were asking about.

I suggest downloading the Script Debugger Trial version to write scripts and use the resources here and elsewhere to get started learning.

Also, these forums are very responsible and helpful.

Good luck!

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set preString to ""
set midString to ""
set postString to ""
set URLtoOpen to preString & midString & postString
tell application "Google Chrome"
   open location URLtoOpen
end tell

set midString to "support"
set postString to "/"
set URLtoOpen to preString & midString & postString
tell application "Google Chrome"
   set myNewWindow to make new window
   tell myNewWindow
      tell tab 1
         set the URL to URLtoOpen
      end tell
   end tell
end tell
1 Like

Thanks a lot I will give it a try, these forums seem nice, automation with applescript, exactly what I’m interested in/what i want to learn, if I get going well learning I will definitely buy script debugger eventually and participate in forums and share my scripts.

Great! Maybe this will help:

Learning AppleScript

If you are new to AppleScript and are interested in learning more, then I’d suggest you take a look at:

  1. AppleScript: Beginner’s Tutorial
  2. Script Debugger 7 – a full IDE for developing AppleScript.
    SD7 now comes with a 20-day free trial, and then will gracefully downgrade to the FREE SD7 Lite (which is still much better than Script Editor).
  3. Documentation Links by Mark @alldritt.

thanks for links, I think I might abandon that original script idea this thread’s about, it would be nice but it’s pretty complex and I found a workaround, better to start learning, then one day I’ll script it when I don’t need it :face_with_raised_eyebrow:

AppleScript can handle complex. Where it really shines is controlling multiple applications from different developers within the same script.

I got help from someone skilled in applescript to achieve what this thread was about, but it was complex, I actually didn’t need it to start learning. I was just being picky, but he was nice😬

Between knowing applescript and all the automation programs that utilize it like keyboard maestro, bettertouchtool, alfred, you can pretty much automate anything you want on a mac, it’s cool, and not many know the language as opposed to python where everyone knows it, although it never hurts to know more languages.