Scripting Examples

You are here: Sqwarq Apps > Scripting Examples

OSXClock
Starting in version 1.9, OSXClock supports AppleScript. Here’s a few examples of some of the ways you can script OSXClock using your mac’s built-in Script Editor.app:

--bring OSXClock the the front
tell application "OSXClock"
activate
end tell

--get OSXClock's properties
tell application "OSXClock"
properties
end tell

--toggle ghostmode's current state
tell application "OSXClock" to ghost

--turn ghostmode on
tell application "OSXClock"
set x to ghostmode
if x = false then ghost
end tell

--turn ghostmode, transparency and 'Always on Top' off
tell application "OSXClock"
if ghostmode = true then
ghost
transparent
ontop
end if
end tell


-- reset the timer to 0
tell application "OSXClock"
reset timer
end tell


--set an alarm
tell application "OSXClock"
alarm 3 --let's boil some eggs
end tell


--cancel an existing alarm
tell application "OSXClock"
alarm 0
end tell


-- get the time remaining on the alarm in seconds
tell application "OSXClock"
set x to alarmcounter
set h to word 1 of x as number
set h to (h * 60) * 60
set m to word 2 of x as number
set m to m * 60
set s to word 3 of x as number
set timeRemaining to h + m + s

if timeRemaining < 300 then
–only 5 minutes remaining, do something
log “less than 5 minutes = ” & timeRemaining & ” secs”
else
–plenty of time left, do something else
log “more than 5 minutes = ” & timeRemaining & ” secs”
end if
end tell

 

DetectX
Starting with DetectX 2, it will be possible to run the Inspector View’s Record mode with AppleScript:


--run the Inspector
tell application "DetectX" to inspect

FastTasks 2
Scripting support and examples forthcoming

BatteryAlert
Scripting support and examples forthcoming

@sqwarq

Follow @sqwarq on Twitter

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s