Skip to content

Instantly share code, notes, and snippets.

@mals14
mals14 / GetNameAndTitleOfActiveWindow.scpt
Created August 12, 2018 14:51 — forked from timpulver/GetNameAndTitleOfActiveWindow.scpt
[AppleScript] Get Name of active window | Returns the name / title of the active (frontmost) window
# taken from user Albert's answer on StackOverflow
# http://stackoverflow.com/questions/5292204/macosx-get-foremost-window-title
# tested on Mac OS X 10.7.5
global frontApp, frontAppName, windowTitle
set windowTitle to ""
tell application "System Events"
set frontApp to first application process whose frontmost is true
set frontAppName to name of frontApp
@mals14
mals14 / copyURLPlusSafari.scpt
Created August 12, 2018 14:51 — forked from chmurph2/copyURLPlusSafari.scpt
In Safari, this applescript copies the title and URL of the current tab to the clipboard.
-- In Safari, this copies the Title and URL of the current tab to the clipboard.
-- Save the script in ~/Library/Scripts/Applications/Safari
-- Using QuickSilver, I assign a trigger to this script using the hotkey ⌥-C (option c), with the scope of the trigger limited to Safari.
-- Inspired by CopyURL + (http://copyurlplus.mozdev.org/)
-- Christopher R. Murphy
tell application "Safari"
set theURL to URL of front document
set theTitle to name of front document
set the clipboard to theTitle & return & theURL as string
@mals14
mals14 / get_url.scpt
Created August 12, 2018 14:53 — forked from prashanthrajagopal/get_url.scpt
AppleScript to get url from Safari, Firefox and Chrome
display dialog "Name of the browser?" default answer "Safari"
set inp to text returned of result
tell application "System Events"
if inp is "Google Chrome" then
tell application "Google Chrome" to return URL of active tab of front window
else if inp is "Safari" then
tell application "Safari" to return URL of front document
else if inp is "Firefox" then
tell application "Firefox" to activate
@mals14
mals14 / idletime.sh
Created August 13, 2018 10:51 — forked from Neil-Smithline/idletime.sh
Mac OS X Idle Time Shell Script
#!/bin/sh
# Get MacOSX idletime. Shamelessly stolen from http://bit.ly/yVhc5H
/usr/sbin/ioreg -c IOHIDSystem | /usr/bin/awk '/HIDIdleTime/ {print int($NF/1000000000); exit}'
@mals14
mals14 / Access NSScreen.scpt
Created October 10, 2019 12:15 — forked from henryroe/Access NSScreen.scpt
Demonstration of how to use an AppleScript Bundle to enable access to NSScreen in AppleScriptObjC
(*
Copy and paste this script into a new document in AppleScript Editor.
When saving, select "Script Bundle" as File Type.
Save the file to: "~/Library/Script Libraries/Access NSScreen.scptd"
Note: you may need to create the directory: "~/Library/Script Libraries"
Note: while this gist has the file ending "scpt", by selecting the
"Script Bundle" file type, the file extension "scptd" should be added.
@mals14
mals14 / index.js
Created October 10, 2019 12:53 — forked from shedali/index.js
test grab due tasks with jxa in node
const runJxa = require("run-jxa");
const _ = require('lodash');
(async () => {
const result = await runJxa(() => {
var of = Application("OmniFocus");
var doc = of.defaultDocument;
return getTasks();
@mals14
mals14 / Save mail attachments with pre-pended YYYY-MM-DD_.kmmacros
Created October 10, 2019 12:53 — forked from henryroe/Save mail attachments with pre-pended YYYY-MM-DD_.kmmacros
Keyboard Maestro macro to take Mail.app attachments, pre-pend YYYY-MM-DD_..., and save to user-selected dir
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>Activate</key>
<string>Normal</string>
<key>IsActive</key>
<true/>
<key>Macros</key>
@mals14
mals14 / trello_days_left.js
Created October 10, 2019 12:56 — forked from anjiro/trello_days_left.js
Trello show days left Greasemonkey script
// ==UserScript==
// @name Trello days left
// @namespace edu.rit.ashbrook.daniel
// @include https://trello.com/*
// @version 1.1
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant GM_addStyle
// @description Add the number of days left until an item is due to each applicable card.
// ==/UserScript==
@mals14
mals14 / jxaClickAppSubMenuItem.applescript
Created December 2, 2020 13:40 — forked from RobTrew/jxaClickAppSubMenuItem.applescript
Yosemite JXA Javascript Function for clicking application sub-menu items
// Click an OS X app sub-menu item
// 2nd argument is an array of arbitrary length (exact menu item labels, giving full path)
// e.g. menuItemClick("InqScribe", ['View', 'Aspect Ratio', 'Use Media Ratio'])
// Note that the menu path (spelling & sequence) must be exactly as in the app
// See menuItemTestClick() below for a slower version which reports any errors
// For macOS Yosemite to Sierra
@mals14
mals14 / jxaClickAppSubMenuItem.applescript
Created December 2, 2020 13:42 — forked from bumaociyuan/jxaClickAppSubMenuItem.applescript
Yosemite JXA Javascript Function for clicking application sub-menu items
// Click an OS X app sub-menu item
// 2nd argument is an array of arbitrary length (exact menu item labels, giving full path)
// e.g. menuItemClick("InqScribe", ['View', 'Aspect Ratio', 'Use Media Ratio'])
// Note that the menu path (spelling & sequence) must be exactly as in the app
// See menuItemTestClick() below for a slower version which reports any errors
// For OS X 10.10 Yosemite JXA JavaScript for Automation