Skip to content

Instantly share code, notes, and snippets.

View garybehrend's full-sized avatar

Gary Behrend garybehrend

View GitHub Profile
@garybehrend
garybehrend / alfred.scpt
Created March 8, 2016 02:26 — forked from pancraschow/alfred.scpt
Alfred 常用的AppleScript Work Flows
-- 让Finder展示或者不展示隐藏文件
on alfred_script(q)
if q is "true" then
do shell script "defaults write com.apple.finder AppleShowAllFiles -bool true"
else
do shell script "defaults write com.apple.finder AppleShowAllFiles -bool false"
end if
end alfred_script
@garybehrend
garybehrend / Set KM Variable Function AS.applescript
Created March 8, 2016 02:26 — forked from JMichaelTX/Set KM Variable Function AS.applescript
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"
@garybehrend
garybehrend / 2013-04-21-TUAW_Waldie.applescript
Created March 8, 2016 02:23 — forked from benwaldie/2013-04-21-TUAW_Waldie.applescript
TUAW > Extract App Resource Icons with AppleScript
-- Ask the user to select an app
set theApp to choose file of type "app" default location (path to applications folder)
-- Get the app name
tell application "System Events"
set theAppName to name of theApp
if theAppName ends with ".app" then set theAppName to text 1 thru -5 of theAppName
-- Determine whether the app is a package, and notify the user if it's not
set isPackage to (package folder of theApp)
@garybehrend
garybehrend / launch-application-in-full-screen
Created March 8, 2016 02:23 — forked from RobertAlan/applescript-launch-application-in-full-screen
Applescript - Launch application in Full Screen
on run {input, parameters}
tell application "Calendar" to activate
delay 2
tell application "System Events"
keystroke "f" using {option down}
end tell
@garybehrend
garybehrend / launch-app.scpt
Created March 8, 2016 02:23 — forked from olivmonnier/launch-app.scpt
Applescript - Launch application and resize window
tell application "Safari" to activate
set x to 187
set y to 22
set w to 973
set h to 816
tell application "System Events"
tell process "Safari" to get first window
set this_window to result
set position of this_window to {x, y}
set size of this_window to {w, h}
@garybehrend
garybehrend / §(Toggle Wi-Fi).app
Created March 8, 2016 02:23 — forked from viktorklang/§(Toggle Wi-Fi).app
AppleScript to toggle Wi-Fi in OSX
(*
Installation instructions
=========================
Run as an Application:
1) Open AppleScript Editor and create a new script
2) Paste this file into it
3) Save name it '§(Toggle Wi-Fi)'
- Or substitute '§' for a symbol that you can press with a single key
4) Put it in Applications/Utilities
@garybehrend
garybehrend / ToggleHiddenFiles.scpt
Created March 8, 2016 02:23 — forked from razola/ToggleHiddenFiles.scpt
Applescript that toggles hidden files
try
set state to do shell script "defaults read com.apple.finder AppleShowAllFiles" as string
if state is "OFF" then
do shell script "defaults write com.apple.finder AppleShowAllFiles ON"
else
do shell script "defaults write com.apple.finder AppleShowAllFiles OFF"
end if
on error
do shell script "defaults write com.apple.finder AppleShowAllFiles ON"
end try
@garybehrend
garybehrend / gist:fe22eecbbc9c2c07aefb
Created March 8, 2016 02:23 — forked from kfriend/gist:6396197
AppleScript: Create file w/ prompt
-- Get the currently selected item
tell application "Finder"
set currentFile to selection as text
end tell
set container to GetParentPath(currentFile)
display dialog "File name and extension" default answer "New File.txt"
set fileName to text returned of result
-------------------------------------------------------------------------------------------
REFERENCES FOR LEARNING & USING APPLESCRIPT Modified: 2016/01/10 05:18
-------------------------------------------------------------------------------------------
NOTES
-------------------------------------------------------------------------------------------
AppleScript is a rather peculiar scripting language to learn.
@garybehrend
garybehrend / macid.applescript
Created March 8, 2016 02:09 — forked from firefox254/macid.applescript
macid_sendclipboard.applescript
ignoring application responses
tell application "System Events" to tell process "MacID"
click menu bar item 1 of menu bar 2
end tell
end ignoring
do shell script "killall System\\ Events"
delay 0.1
tell application "System Events" to tell process "MacID"
tell menu bar item 1 of menu bar 2
--click menu item "Send clipboard text to all iOS clipboards..." of menu 1