This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function run() { | |
// KEYBOARD MAESTRO VARIABLES IN YOSEMITE JXA JAVASCRIPT FOR APPLICATIONS | |
// FINDING, CREATING, READING, UPDATING | |
// SIMPLE EXAMPLE - TOGGLING A BOOLEAN KM VARIABLE FROM .js | |
var strKMVarName = "flag"; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rob Trew @complexpoint 2015 | |
function run() { | |
"use strict"; | |
var blnUseKeyboardMaestro = false; | |
// EDIT TO NAMES OF TWO ALTERNATIVE SOUND OUTPUT DEVICES | |
var dctSources = { // A unique substring for each is enough | |
primary: "Internal", | |
secondary: "Elgato" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// YOSEMITE Javascript for Applications JXA | |
// Capture the main result links from a Google search page as Markdown | |
// ( Using XPath to search for <a> elements which are children | |
// of elements with class 'r' | |
var resultLinksMD = function () { | |
var r = document.evaluate( | |
"//*[@class='r']/a", | |
document, null, 0, null | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ver 0.4 Rob Trew | |
// Library for using OSX Yosemite Script Editor scripts | |
// written in an idiom compatible with FoldingText, Drafts, 1Writer, TextWell | |
// In iOS Drafts 4 scripts, the header is simply: | |
// var drafts = this; | |
// For headers for FoldingText and other editors, see: | |
// See: http://support.foldingtext.com/t/writing-scripts-which-run-on-both-foldingtext-and-ios-drafts-4/652/7 | |
// Call functions, after this header, with the prefix: | |
// drafts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ROBIN TREW 2015 MIT License | |
// OSX 10.10 SCRIPT EDITOR – WRAP SELECTED LINE(S) IN SIMPLE TIMING CODE (FOR PERFORMANCE EXPERIMENTS) | |
// Add remove '// ' from before printing characters | |
// Depends on a library .scpt being saved at ~/Library/Script Libraries/DraftsSE.scpt | |
// See: See: http://support.foldingtext.com/t/writing-scripts-which-run-on-both-foldingtext-and-ios-drafts-4/652/7 | |
// INCLUDE LIBRARY OF IOS DRAFTS-COMPATIBLE EDITOR FUNCTIONS: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ROBIN TREW 2015 MIT License | |
// OSX 10.10 SCRIPT EDITOR – REDUCE INDENTATION OF SELECTED LINES (by Tab or 4 spaces) | |
// Add remove '// ' from before printing characters | |
// Depends on a library .scpt being saved at ~/Library/Script Libraries/DraftsSE.scpt | |
// See: See: http://support.foldingtext.com/t/writing-scripts-which-run-on-both-foldingtext-and-ios-drafts-4/652/7 | |
// INCLUDE ALL OR PART OF LIBRARY OF IOS DRAFTS-COMPATIBLE EDITOR FUNCTIONS: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ROBIN TREW 2015 MIT License | |
// OSX 10.10 SCRIPT EDITOR – INDENT SELECTED LINES (with Tab or 4 spaces) | |
// Add remove '// ' from before printing characters | |
// Depends on a library .scpt being saved at ~/Library/Script Libraries/DraftsSE.scpt | |
// See: See: http://support.foldingtext.com/t/writing-scripts-which-run-on-both-foldingtext-and-ios-drafts-4/652/7 | |
// INCLUDE ALL OR PART OF LIBRARY OF IOS DRAFTS-COMPATIBLE EDITOR FUNCTIONS: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ROBIN TREW 2015 MIT License | |
// OSX 10.10 SCRIPT EDITOR – TOGGLE COMMENTS | |
// Add remove '// ' from before printing characters | |
// Depends on a library .scpt being saved at ~/Library/Script Libraries/DraftsSE.scpt | |
// See: See: http://support.foldingtext.com/t/writing-scripts-which-run-on-both-foldingtext-and-ios-drafts-4/652/7 | |
// INCLUDE LIBRARY OF IOS DRAFTS-COMPATIBLE EDITOR FUNCTIONS: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ver 0.2 | |
// Restores syntax highlighting by recompiling | |
// either restoring cursor or placing it at first error found | |
// Assumes installation of node.js | |
// http://nodejs.org/download/ | |
// with npm at: | |
var pathNPM = '/usr/local/bin'; |
NewerOlder