Skip to content

Instantly share code, notes, and snippets.

View JMichaelTX's full-sized avatar

JMichaelTX JMichaelTX

View GitHub Profile
@JMichaelTX
JMichaelTX / JXA Resources.md
Last active March 31, 2024 04:38
JavaScript for Automation (JXA) Resources

JXA Resources

Revised: 2019-11-28 16:16 GMT-6

JXA

This is a list of the key resources I have found useful. If you know of others, please post in a comment below, and I will add to this list.

I have tried to order this list in the order that, to me, is best for learning JXA from scratch. We all learn a bit diferently, so adjust to suit your style/needs. Please post if you have suggestions on learning JXA.

@JMichaelTX
JMichaelTX / JXA Alert Function.md
Last active March 18, 2024 11:33
JXA Alert Function - JavaScript for Automation

JXA Alert Function
See code below.

JMichaelTX JXA Gists
Because there is so little JavaScript for Automation (JXA) code that is published, I plan to publish as much as I can that will hopefully be of help to others learning JXA.

Much of what I publish will be based on the work of others, and I always try to cite those references in the code header. If I have failed to properly credit your code, please post a comment, and I will correct my Gist.

Your JXA Code
If you have example code you'd like to share, please post a link to your code. After having searched and evaluated various options for posting/sharing code, i have concluded that Github Gists is the best.

@JMichaelTX
JMichaelTX / Set KM Variable Function AS.applescript
Last active March 9, 2024 06:20
Set Keyboard Maestro (KM) Variable using AppleScript
###——————————————————————————————————————————————
# setKMVar() Sets KM Variable, Makes if needed
#
# Ver 2.0 2015-12-27
###——————————————————————————————————————————————
on setKMVar(pKMVarName, pKMVarValue)
--log ("setKMVar: " & pKMVarName & ": " & pKMVarValue)
tell application "Keyboard Maestro Engine"
@JMichaelTX
JMichaelTX / Create Hyperlink with Custom Protocol from Selected Text.applescript
Created August 3, 2016 05:46
AppleScript to Create Rich Text Hyperlink with Custom Protocol from Selected Text
@JMichaelTX
JMichaelTX / Copy & Get Selection to Clipboard JXA.js
Last active January 2, 2023 19:32
Copy & Get Selection to Clipboard using JavaScript for Automation (JXA) [Ver 1.1.1]
'use strict';
var app = Application.currentApplication()
app.includeStandardAdditions = true
var mySelection = copySelection("Safari", 1)
mySelection
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function copySelection(pAppName, pTimeLimitSec) {
@JMichaelTX
JMichaelTX / Create Internet Location File from EN Note.applescript
Last active October 3, 2022 00:39
Create an .inetloc File to open Evernote Note in Evernote Mac app using AppleScript.
property ptyScriptName : "Create Internet Location File from EN Note"
property ptyScriptVer : "2.0"
property ptyScriptDate : "2018-03-29"
property ptyScriptAuthor : "JMichaelTX"
(*
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REQUIRED:
1. macOS 10.11.6+
2. Mac Applications
@JMichaelTX
JMichaelTX / Get List of Finder Tags.applescript
Last active February 7, 2022 20:46
Get Finder Tag list from plist file. By @shanestanley
(*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get List of Finder Tags
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DATE: 2018-03-19
AUTHOR: ShaneStanley with minor mod by JMichaelTX
REF:
• How Can I get a List of All Finder Tags?
• Late Night Software Ltd.,
• http://forum.latenightsw.com/t/how-can-i-get-a-list-of-all-finder-tags/1192/2?u=jmichaeltx
@JMichaelTX
JMichaelTX / 1 Mods to AppleScript formatICUDate by JMichaelTX.md
Last active October 8, 2021 18:48 — forked from ccstone/Create date-string using ICU Date-Time Format Syntax.applescript
AppleScript (ASObjC) Format Date/Time Using ISO/ICU Format Codes

MODS BY JMichaelTX on Sat, Feb 27, 2016

AppleScript Handler: on formatDate(pDate, pFormat)

  1. Changed record-style parameters to single-field parameters
  2. Added block to handle date parameter as a string, including International format (YYYY-MM-DD)
  3. Added handler/function: convertIntlDate(pDateStr)
@JMichaelTX
JMichaelTX / JXA_PersistentProperties.js
Last active March 16, 2021 13:27 — forked from RobTrew/JXA_PersistentProperties.js
Persistent 'properties' for OS X JavaScript for Applications (JXA) Forked from Rob Trew
(function () {
'use strict';
// OSX JavaScript for Applications lacks the persistent 'properties'
// of AppleScript (in which global variables and properties persist between script runs)
// but we can, of course, serialise to JSON or plist at the end of a script
// parsing it at the start of the next run.
// Here is one approach to persistence between script runs
// using JSON.stringify() and JSON.parse()
@JMichaelTX
JMichaelTX / EN Mac Append Note OR Create New Note (AS).applescript
Last active March 13, 2021 20:02
AppleScript to Append HTML to Existing Evernote Note, or Create New Note (EN Mac)
(*
===============================================================================
Append to Existing Note OR Create New Note
===============================================================================
VER: 1.2 LAST UPDATE: 2016-07-05
PURPOSE:
• Search for Existing Note by Title and Notebook
• IF found, append HTML