FasdUAS 1.101.10
k
l
r
n

1

psxp
l
I
.earsffdralis afdr

f
	o0script_path
l

r

l

I

.sysoexecTEXTTEXT
b

m
dirname
o0script_path
o0project_path
l
r
mtrak.io.js
o0project_name !
 l!"
"l#
#O$%
$k&&'(
'I!
.miscactvnullnull()*
)l""*+,
+l""-.- make a new terminal.//( make a new terminal,01
0r"+23
2l")4
4I")5
.corecrel****null56

kocl
6m$%

Ptrm
3o0
trak_terminal178
7l,,89:
9l,,;<; talk to the new terminal<==2 talk to the new terminal:>?
>O,@A
@k0BBCD
Cl00DEF
EI07G
.ITRMLNCHPssnobj GH

Pssn
Hm23IIJJSmall TextFKL
KO8fMN
Mk@eOOPQ
Pr@KRS
Rb@ETU
Tm@CVVWWServer
UoCD0project_name
S1EJ

pnamQXY
XILYZ
.ITRMWrtenullobj Z[

iTxt
[bPU\]
\mPS^^__cd
]oST0project_pathY`
`IZea
.ITRMWrtenullobj ab

iTxt
bm^accddmake server
N18=

CssnLef
elggfgh
gIgpi
.ITRMLNCHPssnobj ij

Pssn
jmilkkllSmall Texthmn
mOqop
okyqqrs
rrytu
tby~vw
vmy|xxyyGuard
wo|}0project_name
u1~

pnamsz{
zI|
.ITRMWrtenullobj |}

iTxt
}b~
~mcd
o0project_path{
I
.ITRMWrtenullobj

iTxt
m
guard
p1qv

Cssnn
l
I
.ITRMLNCHPssnobj

Pssn
mSmall Text
O
k
r
o0project_name
1

pnam
I
.ITRMWrtenullobj

iTxt
b
mcd
o0project_path
1

Cssn
l
Ao,-0
trak_terminal?
l
%mITRMalisHMacintosh HDH+M	iTerm.app>eB	 ApplicationsW2M$Macintosh HD:Applications:iTerm.app	iTerm.appMacintosh HDApplications/iTerm.app/

.aevtoappnull****0script_path0project_path0project_name0
trak_terminal
.aevtoappnull****
k"~}|{zyxwvuItsVrq^pckx
.earsffdralis afdr

psxp~0script_path
}.sysoexecTEXTTEXT|0project_path{0project_name
z.miscactvnullnull
y
kocl
x
Ptrm
w.corecrel****nullv0
trak_terminal
u
Pssn
t.ITRMLNCHPssnobj
s
Cssn
r
pnam
q
iTxt
p.ITRMWrtenullobj )j,EO%jEOEO*j	O*lEO*lO*a,'a%*a,FO*aa%lO*aalUO*alO*a,'a%*a,FO*aa%lO*aalUO*alO*a,*a,FO*aa%lUOPUOPU/Users/msaspence/Projects/trak.io/code/trak.io.js/start-iterm-env.scptb/Users/msaspence/Projects/trak.io/code/trak.io.json
o
Ptrmnascr
ޭ

FasdUAS 1.101.10
k
l
r
n

1

psxp
l
I
.earsffdralis afdr

f
	o0script_path
l

r

l

I

.sysoexecTEXTTEXT
b

m
dirname
o0script_path
o0project_path
l
r
mtrak.io.js
o0project_name !
 l!"
"l#
#O$%
$k&&'(
'I!
.miscactvnullnull()*
)l""*+,
+l""-.- make a new terminal.//( make a new terminal,01
0r"+23
2l")4
4I")5
.corecrel****null56

kocl
6m$%

Ptrm
3o0
trak_terminal178
7l,,89:
9l,,;<; talk to the new terminal<==2 talk to the new terminal:>?
>O,@A
@k0BBCD
Cl00DEF
EI07G
.ITRMLNCHPssnobj GH

Pssn
Hm23IIJJSmall TextFKL
KO8fMN
Mk@eOOPQ
Pr@KRS
Rb@ETU
Tm@CVVWWServer
UoCD0project_name
S1EJ

pnamQXY
XILYZ
.ITRMWrtenullobj Z[

iTxt
[bPU\]
\mPS^^__cd
]oST0project_pathY`
`IZea
.ITRMWrtenullobj ab

iTxt
bm^accddmake server
N18=

CssnLef
elggfgh
gIgpi
.ITRMLNCHPssnobj ij

Pssn
jmilkkllSmall Texthmn
mOqop
okyqqrs
rrytu
tby~vw
vmy|xxyyGuard
wo|}0project_name
u1~

pnamsz{
zI|
.ITRMWrtenullobj |}

iTxt
}b~
~mcd
o0project_path{
I
.ITRMWrtenullobj

iTxt
m
guard
p1qv

Cssnn
l
I
.ITRMLNCHPssnobj

Pssn
mSmall Text
O
k
r
o0project_name
1

pnam
I
.ITRMWrtenullobj

iTxt
b
mcd
o0project_path
I
.ITRMWrtenullobj

iTxt
mBgit checkout start-iterm-env.scpt
1

Cssn
l
Ao,-0
trak_terminal?
l
%mITRMalisHMacintosh HDH+3	iTerm.app
=F	 ApplicationsF3$Macintosh HD:Applications:iTerm.app	iTerm.appMacintosh HDApplications/iTerm.app/
.aevtoappnull****
.aevtoappnull****
k"~}|{IzyVxw^vckx
.earsffdralis afdr

psxp0script_path
.sysoexecTEXTTEXT0project_path0project_name
.miscactvnullnull

kocl
~
Ptrm
}.corecrel****null|0
trak_terminal
{
Pssn
z.ITRMLNCHPssnobj
y
Cssn
x
pnam
w
iTxt
v.ITRMWrtenullobj )j,EO%jEOEO*j	O*lEO*lO*a,'a%*a,FO*aa%lO*aalUO*alO*a,'a%*a,FO*aa%lO*aalUO*alO*a,#*a,FO*aa%lO*aalUOPUOPUascr
ޭ

Change startup script to disgard its own changes on startup


try
	get application id "com.stairways.keyboardmaestro.engine"
on error err_msg number err_num
	return "Keyboard Maestro not found. First install it and then use this workflow."
end try

tell application id "com.stairways.keyboardmaestro.engine"
	gethotkeys with asstring
end tell

try
	get application id "com.stairways.keyboardmaestro.engine"
on error err_msg number err_num
	return "Keyboard Maestro not found. First install it and then use this workflow."
end try

tell application id "com.stairways.keyboardmaestro.engine"
	gethotkeys with asstring and getall
end tell

Update script to get ALL macros instead of just hotkeyed macros.


tell application "Reminders"
	activate
	set theAccount to name of first account
	tell account theAccount
		set theList to name of first list
		set myReminder to (make new reminder at list theList with properties {name:"{popclip text}"})
	end tell
end tell

on sortList(unsortedList)
	set oldDelimiters to AppleScript's text item delimiters
	set AppleScript's text item delimiters to (ASCII character 10)
	set sortedList to paragraphs of (do shell script "echo " & quoted form of (unsortedList as string) & "| sort  -d -f")
	set AppleScript's text item delimiters to oldDelimiters
	return sortedList
end sortList

-- sort the list
tell application "Reminders"
	activate
	get the name of every account
	set theAccount to name of first account
	tell account theAccount
		set allLists to the name of every list
	end tell
end tell
set sortedList to sortList(allLists)
set theList to first item of sortedList

tell application "Reminders"
	tell account theAccount to set myReminder to (make new reminder at list theList with properties {name:"{popclip text}"})
end tell

update Reminders to choose first list in alphabetical order


on run argv
    tell app "Terminal"
        activate
		set custom title to "CodeCanaan"
        set tab1 to do script item 1 of argv
    end tell
end run

on run argv
    tell app "Terminal"
        activate
        set tab1 to do script item 1 of argv
		tell tab1 to set custom title to "CodeCanaan"
    end tell
end run

設定 Mac Terminal Title

設定 Mac Terminal Title


on newPresentation(themeName)
    tell application "Keynote"
    	activate
    	-- set the chosenTheme to themeName

    	set targetWidth to 1024 -- 1440 <-- higher resolution
    	set targetHeight to 768 -- 1080 <-- higher resolution

    	set thisDocument to ¬
    		make new document with properties ¬
                {document theme:theme (themeName as string)}
    			--{document theme:theme (themeName as string), width:targetWidth, height:targetHeight}
        return name of thisDocument
    end tell
end newPresentation

on createSlide(docname, masterSlideName, thisSlideTitle, thisSlideBody)
	try
		tell application "Keynote"
			tell document named docname
				set thisSlide to make new slide with properties {base slide:master slide masterSlideName}
				tell thisSlide
					-- set the transition properties to {transition effect:dissolve, transition duration:defaultTransitionDuration, transition delay:defaultTransitionDelay, automatic transition:defaultAutomaticTransition}
					if title showing is true then
						set the object text of the default title item to thisSlideTitle
					end if
					if body showing is true then
						set the object text of the default body item to thisSlideBody
					end if
				end tell
			end tell
      return thisSlide
		end tell
	on error
		return 0
	end try
end createSlide

on finalize(docname)
	tell application "Keynote"
		tell document named docname to delete slide 1
    end tell
end finalize

on themeMasters(docname)
    --    tell application "Keynote" to get the name of every master slide of thisDocument
	tell application "Keynote"
		set names to the name of every master slide of document named docname
        return names
    end tell
end themeMasters

on addImage(docname, filepath)
  (*
    FIXME: Use slide ID to adress slide instead of "current slide"
  *)
  tell application "Keynote"
  	tell document named docname
  		tell the current slide

  			-- TO REPLACE A PLACEHOLDER OR EXISTING IMAGE:
  			set thisPlaceholderImageItem to image 1
  			-- change the value of the “file name” property of the image to be an HFS file reference to the replacement image file
        set macPath to POSIX file filepath as Unicode text
  			set file name of thisPlaceholderImageItem to ¬
  				alias macPath

  		end tell
  	end tell
  end tell
end addImage

Add an image to a slide (with an image placeholder)


--
--  slideshow -- Observe and Control Slideshow Applications
--  Copyright (c) 2014 Ralf S. Engelschall <http://engelschall.com>
--
--  This Source Code Form is subject to the terms of the Mozilla Public
--  License (MPL), version 2.0. If a copy of the MPL was not distributed
--  with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
--
--  File:     connector-osx-kn.js
--  Purpose:  connector engine for Apple Keynote 5 under Mac OS X
--  Language: AppleScript
--

--  utility function
on filterText(this_text, allowed_chars)
   set new_text to ""
   repeat with this_char in this_text
       set x to the offset of this_char in allowed_chars
       if x is not 0 then
           set new_text to (new_text & this_char) as string
       end if
   end repeat
   return new_text
end filterText

--  utility function
on replaceText(this_text, search_string, replacement_string)
   set AppleScript's text item delimiters to the search_string
   set the item_list to every text item of this_text
   set AppleScript's text item delimiters to the replacement_string
   set this_text to the item_list as string
   set AppleScript's text item delimiters to ""
   return this_text
end replace_chars

--  utility function
on asciiCharset()
    set charset to " \"'!#$%()*+,-./:;<=>?@[\\]^_{|}~"
    set charset to (charset & "0123456789")
    set charset to (charset & "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    set charset to (charset & "abcdefghijklmnopqrstuvwxyz")
    return charset
end asciiCharset

--  get application state
on knGetState()
    set state to "closed"
    tell application "System Events"
        set is_running to (exists (some process whose name is "Keynote"))
    end tell
    if is_running then
       try
            set state to "running"
            tell application "Keynote"
                if playing then
                    set state to "viewing"
                else if (get count of slides of front document) > 0 then
                    set state to "editing"
                end if
            end tell
        on error errMsg
        end try
    end if
    return state
end knGetState

--  get Apple Keynote current slide
on knGetCurSlide()
    try
        tell application "Keynote"
            if playing then
                return (get slide number of current slide of front document)
            else
                return (get slide number of current slide of front document)
            end if
        end tell
    on error errMsg
        return 0
    end try
end knGetCurSlide

--  get Apple Keynote maximum slide
on knGetMaxSlide()
    try
        tell application "Keynote"
            return (get count of slides of front document)
        end tell
    on error errMsg
        return 0
    end try
end knGetMaxSlide

--  the STATE command
on cmdSTATE()
    set state to knGetState()
    if state is "closed" then
        set position to 0
        set slides to 0
    else
        set position to knGetCurSlide()
        set slides to knGetMaxSlide()
    end if
    return ("{ \"response\": { " & ¬
        "\"state\": \"" & state & "\", " & ¬
        "\"position\": " & position & ", " & ¬
        "\"slides\": " & slides & " " & ¬
    "} }")
end cmdSTATE

--  the INFO command
on cmdINFO()
    set output to ""
    if knGetMaxSlide() is 0 then
        error "still no active presentation"
    end if
    tell application "Keynote"
        set thePresentation to front document
        set theTitles to ""
        set theNotes to ""
        set slideCount to (get count of slides of thePresentation)
        repeat with slideNum from 1 to slideCount
            set theSlide to slide slideNum of thePresentation

            set theTitle to (title of theSlide) as string
            if theTitles is not "" then
                set theTitles to (theTitles & ", ")
            end if
            set theTitles to (theTitles & "\"" & (my replaceText(theTitle, "\"", "\\\"")) & "\"")

            set theNote to (notes of theSlide) as string
            set theNote to (my filterText(theNote, my asciiCharset()))
            if theNotes is not "" then
                set theNotes to (theNotes & ", ")
            end if
            set theNotes to (theNotes & "\"" & (my replaceText(theNote, "\"", "\\\"")) & "\"")

        end repeat
        set theTitles to ("[ " & theTitles & " ]")
        set theNotes to ("[ " & theNotes & " ]")
        set output to ("{ \"response\": { \"titles\": " & theTitles & ", \"notes\": " & theNotes & " } }")
    end tell
    return output
end cmdINFO

--  the control commands
on cmdCTRL(command, arg)
    set state to knGetState()
    if command is "BOOT" then
        if state is not "closed" then
            error "application already running"
        end if
        tell application "Keynote"
            activate
        end tell
    else if command is "QUIT" then
        if state is "closed" then
            error "application already closed"
        end if
        tell application "Keynote"
            quit
        end tell
    else if command is "OPEN" then
        if state is "editing" or state is "viewing" then
            error "active presentation already existing"
        end if
        tell application "Keynote"
            tell application "Finder" to set thePath to ¬
                POSIX file (POSIX path of (container of (path to me) as string) & (arg)) as alias
            open thePath
        end tell
    else if command is "CLOSE" then
        if state is "closed" or state is "running" then
            error "still no active presentation"
        end if
        tell application "Keynote"
            close front document
        end tell
    else if command is "START" then
        if state is "closed" or state is "running" then
            error "still no active presentation"
        end if
        if state is "viewing" then
            error "active presentation already viewing"
        end if
        tell application "Keynote"
            start from (slide 1 of front document)
        end tell
    else if command is "STOP" then
        if state is not "viewing" then
            error "no active slideshow"
        end if
        tell application "Keynote"
            stop slideshow (slideshow 1)
        end tell
    else if command is "PAUSE" then
        if state is not "viewing" then
            error "no active slideshow"
        end if
        tell application "Keynote"
            activate
            tell application "System Events" to keystroke "b"
        end tell
    else if command is "RESUME" then
        if state is not "viewing" then
            error "no active slideshow"
        end if
        tell application "Keynote"
            activate
            tell application "System Events" to keystroke "b"
        end tell
    else if command is "FIRST" then
        if state is not "viewing" then
            error "no active slideshow"
        end if
        tell application "Keynote"
            show (item 1 of slides of slideshow 1)
        end tell
    else if command is "LAST" then
        if state is not "viewing" then
            error "no active slideshow"
        end if
        tell application "Keynote"
            show (item (get count of slides of slideshow 1) of slides of slideshow 1)
        end tell
    else if command is "GOTO" then
        if state is not "viewing" then
            error "no active slideshow"
        end if
        tell application "Keynote"
            show (item (arg as integer) of slides of slideshow 1)
        end tell
    else if command is "PREV" then
        if state is not "viewing" then
            error "no active slideshow"
        end if
        tell application "Keynote"
            show previous
        end tell
    else if command is "NEXT" then
        if state is not "viewing" then
            error "no active slideshow"
        end if
        tell application "Keynote"
            show next
        end tell
    end if
    return "{ \"result\": \"OK\" }"
end cmdCTRL

--  main procedure
on run argv
    set cmd to item 1 of argv
    set arg to ""
    if count of argv is 2 then
        set arg to item 2 of argv
    end if
    try
        if cmd is "STAT" then
            set output to cmdSTATE()
        else if cmd is "INFO" then
            set output to cmdINFO()
        else if cmd is "BOOT" ¬
            or cmd is "QUIT" ¬
            or cmd is "OPEN" ¬
            or cmd is "CLOSE" ¬
            or cmd is "START" ¬
            or cmd is "STOP" ¬
            or cmd is "PAUSE" ¬
            or cmd is "RESUME" ¬
            or cmd is "FIRST" ¬
            or cmd is "LAST" ¬
            or cmd is "GOTO" ¬
            or cmd is "PREV" ¬
            or cmd is "NEXT" then
            set output to cmdCTRL(cmd, arg)
        else
            set output to "{ \"error\": \"invalid command\" }"
        end if
    on error errMsg
        set output to ("{ \"error\": \"" & errMsg & "\" }")
    end try
    copy output to stdout
end run

--
--  slideshow -- Observe and Control Slideshow Applications
--  Copyright (c) 2014 Ralf S. Engelschall <http://engelschall.com>
--
--  This Source Code Form is subject to the terms of the Mozilla Public
--  License (MPL), version 2.0. If a copy of the MPL was not distributed
--  with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
--
--  File:     connector-osx-kn.js
--  Purpose:  connector engine for Apple Keynote 5 under Mac OS X
--  Language: AppleScript
--

--  utility function
on filterText(this_text, allowed_chars)
   set new_text to ""
   repeat with this_char in this_text
       set x to the offset of this_char in allowed_chars
       if x is not 0 then
           set new_text to (new_text & this_char) as string
       end if
   end repeat
   return new_text
end filterText

--  utility function
on replaceText(this_text, search_string, replacement_string)
   set AppleScript's text item delimiters to the search_string
   set the item_list to every text item of this_text
   set AppleScript's text item delimiters to the replacement_string
   set this_text to the item_list as string
   set AppleScript's text item delimiters to ""
   return this_text
end replace_chars

--  utility function
on asciiCharset()
    set charset to " \"'!#$%()*+,-./:;<=>?@[\\]^_{|}~"
    set charset to (charset & "0123456789")
    set charset to (charset & "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    set charset to (charset & "abcdefghijklmnopqrstuvwxyz")
    return charset
end asciiCharset

--  get application state
on knGetState()
    set state to "closed"
    tell application "System Events"
        set is_running to (exists (some process whose name is "Keynote"))
    end tell
    if is_running then
       try
            set state to "running"
            tell application "Keynote"
                if playing then
                    set state to "viewing"
                else if (get count of slides of front document) > 0 then
                    set state to "editing"
                end if
            end tell
        on error errMsg
        end try
    end if
    return state
end knGetState

--  get Apple Keynote current slide
on knGetCurSlide()
    try
        tell application "Keynote"
            if playing then
                return (get slide number of current slide of front document)
            else
                return (get slide number of current slide of front document)
            end if
        end tell
    on error errMsg
        return 0
    end try
end knGetCurSlide

--  get Apple Keynote maximum slide
on knGetMaxSlide()
    try
        tell application "Keynote"
            return (get count of slides of front document)
        end tell
    on error errMsg
        return 0
    end try
end knGetMaxSlide

--  the STATE command
on cmdSTATE()
    set state to knGetState()
    if state is "closed" then
        set position to 0
        set slides to 0
    else
        set position to knGetCurSlide()
        set slides to knGetMaxSlide()
    end if
    return ("{ \"response\": { " & ¬
        "\"state\": \"" & state & "\", " & ¬
        "\"position\": " & position & ", " & ¬
        "\"slides\": " & slides & " " & ¬
    "} }")
end cmdSTATE

--  the INFO command
on cmdINFO()
    set output to ""
    if knGetMaxSlide() is 0 then
        error "still no active presentation"
    end if
    tell application "Keynote"
        set thePresentation to front document
        set theTitles to ""
        set theNotes to ""
        set slideCount to (get count of slides of thePresentation)
        repeat with slideNum from 1 to slideCount
            set theSlide to slide slideNum of thePresentation

            set theTitle to (title of theSlide) as string
            if theTitles is not "" then
                set theTitles to (theTitles & ", ")
            end if
            set theTitles to (theTitles & "\"" & (my replaceText(theTitle, "\"", "\\\"")) & "\"")

            set theNote to (notes of theSlide) as string
            set theNote to (my filterText(theNote, my asciiCharset()))
            if theNotes is not "" then
                set theNotes to (theNotes & ", ")
            end if
            set theNotes to (theNotes & "\"" & (my replaceText(theNote, "\"", "\\\"")) & "\"")

        end repeat
        set theTitles to ("[ " & theTitles & " ]")
        set theNotes to ("[ " & theNotes & " ]")
        set output to ("{ \"response\": { \"titles\": " & theTitles & ", \"notes\": " & theNotes & " } }")
    end tell
    return output
end cmdINFO

--  the control commands
on cmdCTRL(command, arg)
    set state to knGetState()
    if command is "BOOT" then
        if state is not "closed" then
            error "application already running"
        end if
        tell application "Keynote"
            activate
        end tell
    else if command is "QUIT" then
        if state is "closed" then
            error "application already closed"
        end if
        tell application "Keynote"
            quit
        end tell
    else if command is "OPEN" then
        if state is "editing" or state is "viewing" then
            error "active presentation already existing"
        end if
        tell application "Keynote"
            tell application "Finder" to set thePath to ¬
                POSIX file (POSIX path of (container of (path to me) as string) & (arg)) as alias
            open thePath
        end tell
    else if command is "CLOSE" then
        if state is "closed" or state is "running" then
            error "still no active presentation"
        end if
        tell application "Keynote"
            close front document
        end tell
    else if command is "START" then
        if state is "closed" or state is "running" then
            error "still no active presentation"
        end if
        if state is "viewing" then
            error "active presentation already viewing"
        end if
        tell application "Keynote"
            start from (slide 1 of front document)
        end tell
    else if command is "STOP" then
        if state is not "viewing" then
            error "no active slideshow"
        end if
        tell application "Keynote"
            stop slideshow (slideshow 1)
        end tell
    else if command is "PAUSE" then
        if state is not "viewing" then
            error "no active slideshow"
        end if
        tell application "Keynote"
            activate
            tell application "System Events" to keystroke "b"
        end tell
    else if command is "RESUME" then
        if state is not "viewing" then
            error "no active slideshow"
        end if
        tell application "Keynote"
            activate
            tell application "System Events" to keystroke "b"
        end tell
    else if command is "FIRST" then
        if state is not "viewing" then
            error "no active slideshow"
        end if
        tell application "Keynote"
            show (item 1 of slides of slideshow 1)
        end tell
    else if command is "LAST" then
        if state is not "viewing" then
            error "no active slideshow"
        end if
        tell application "Keynote"
            show (item (get count of slides of slideshow 1) of slides of slideshow 1)
        end tell
    else if command is "GOTO" then
        if state is not "viewing" then
            error "no active slideshow"
        end if
        tell application "Keynote"
            show (item (arg as integer) of slides of slideshow 1)
        end tell
    else if command is "PREV" then
        if state is not "viewing" then
            error "no active slideshow"
        end if
        tell application "Keynote"
            show previous
        end tell
    else if command is "NEXT" then
        if state is not "viewing" then
            error "no active slideshow"
        end if
        tell application "Keynote"
            show next
        end tell
    end if
    return "{ \"response\": \"OK\" }"
end cmdCTRL

--  main procedure
on run argv
    set cmd to item 1 of argv
    set arg to ""
    if count of argv is 2 then
        set arg to item 2 of argv
    end if
    try
        if cmd is "STAT" then
            set output to cmdSTATE()
        else if cmd is "INFO" then
            set output to cmdINFO()
        else if cmd is "BOOT" ¬
            or cmd is "QUIT" ¬
            or cmd is "OPEN" ¬
            or cmd is "CLOSE" ¬
            or cmd is "START" ¬
            or cmd is "STOP" ¬
            or cmd is "PAUSE" ¬
            or cmd is "RESUME" ¬
            or cmd is "FIRST" ¬
            or cmd is "LAST" ¬
            or cmd is "GOTO" ¬
            or cmd is "PREV" ¬
            or cmd is "NEXT" then
            set output to cmdCTRL(cmd, arg)
        else
            set output to "{ \"error\": \"invalid command\" }"
        end if
    on error errMsg
        set output to ("{ \"error\": \"" & errMsg & "\" }")
    end try
    copy output to stdout
end run

fix protocol

fix protocol


#!/usr/bin/osascript

on run args
	if count of args is greater than 0
		set applescript's text item delimiters to " "
		set pn to (args as string)
		repeat
			log pn
		end
	else
		repeat
			log "y"
		end
	end
end

Add Shebang to Applescript

Add Shebang to Applescript


FasdUAS 1.101.10
k
lH
QH

O=
k<

r

m
fsck
o0returnvaluereturnValue
r
n
1

pnam
1

pPla
o0alibraryaLibrary
r
1

pTrk
o0atrackaTrack
r
m

null
 o0
atrackartwork
aTrackArtwork!"
!Z5#$
#@&%&
%l$'
'I$(
.corecnte********
(n )*
)m

cArt
*o0atrackaTrack
&m$%
$r)1+,
+n)/-.
-1-/

pPCT
.n)-/0
/4*-1

cArt
1m+,
0o)*0atrackaTrack
,o0
atrackartwork
aTrackArtwork"2
2r6<34
3J6:5567
6o670
atrackartwork
aTrackArtwork78
8o780alibraryaLibrary
4o0returnvaluereturnValue
m99null:
iTunes.app007`20$)|( ߀hookalis>SaulireH+:
iTunes.app#/	 ApplicationsM:Saulire:Applications:iTunes.app
iTunes.appSaulireApplications/iTunes.app/
	R
.ascrerr ********

rEH:;
:mEF<<
fsck
;o0returnvaluereturnValue=>
=lIK?
?LIK@
@oIJ0returnvaluereturnValue>A
AlBCB
.aevtoappnull****CDEF
.aevtoappnull****
DkKGGHH=EF9<0returnvaluereturnValue

pPla

pnam0alibraryaLibrary

pTrk0atrackaTrack

null0
atrackartwork
aTrackArtwork

cArt
.corecnte********

pPCTL?7EO*,,EO*,EOEO,jk
k/,EYhOlvEUW
X
EOascrޭ

FasdUAS 1.101.10
k
lH
QH

O=
k<

r

mfsck
o0returnvaluereturnValue
r
n
1

pnam
1

pPla
o0alibraryaLibrary
r
1

pTrk
o0atrackaTrack
r !
 m

null
!o0
atrackartwork
aTrackArtwork"#
"Z5$%
$@&&'
&l$(
(I$)
.corecnte********
)n *+
*m

cArt
+o0atrackaTrack
'm$%
%r)1,-
,n)/./
.1-/

pRaw
/n)-01
04*-2

cArt
2m+,
1o)*0atrackaTrack
-o0
atrackartwork
aTrackArtwork#3
3r6<45
4J6:6678
7o670
atrackartwork
aTrackArtwork89
9o780alibraryaLibrary
5o0returnvaluereturnValue
m::hookalisLSnow-Leopardƺ8H+
iTunes.appuƀ*	 ApplicationsƻƁM$Snow-Leopard:Applications:iTunes.app
iTunes.appSnow-LeopardApplications/iTunes.app/
	R
.ascrerr ********

rEH;<
;mEF==>>fsck
<o0returnvaluereturnValue?@
?lIKA
ALIKB
BoIJ0returnvaluereturnValue@C
ClDED
.aevtoappnull****EFGH
.aevtoappnull****
FkKIIJJ?GH:=0returnvaluereturnValue

pPla

pnam0alibraryaLibrary

pTrk0atrackaTrack

null0
atrackartwork
aTrackArtwork

cArt
.corecnte********

pRawL?7EO*,,EO*,EOEO,jk
k/,EYhOlvEUW
X
EOascrޭ

Fix #114: GrowlTunes hanging if pictd has died.

As noted in the ticket, the fix here is to ask for the raw data, not the PICT data, for the artwork.


property pTitle : "OmniFocus: Quick Stats"
property pVersion : "2.07.brett"

property pstrDBPath : "$HOME/Library/Containers/com.omnigroup.OmniFocus2/Data/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2"
property pstrMinOSX : "10.9"

property pTimeOut : 20

-- Original version: https://github.com/RobTrew/tree-tools/blob/master/OmniFocus%20scripts/Statistics/QuickStats.applescript

-- Copyright  2012, 2013, 2014 Robin Trew
--
-- Permission is hereby granted, free of charge,
-- to any person obtaining a copy of this software
-- and associated documentation files (the "Software"),
-- to deal in the Software without restriction,
-- including without limitation the rights to use, copy,
-- modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons
-- to whom the Software is furnished to do so,
-- subject to the following conditions:
--
-- *******
-- The above copyright notice and this permission notice
-- shall be included in ALL copies
-- or substantial portions of the Software.
-- *******
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-- OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

-- Ver 0.8 adds clipboard option to dialogue
-- Ver 0.9 gives an error message if the cache schema has changed, leading to an SQL error in the script
-- Ver 1.0 slight simplification of the code
-- Ver 1.1 added count of Pending projects
-- Ver 1.2 added a count of available actions
-- Ver 1.3 added a break-down of unavailable actions
-- Ver 1.4 added count of Current projects to complement Pending projects
-- ver 1.5 replaced Applescript time function with SQL time expression
-- Ver 1.7 Reorganizes menu, and attempts to enable access for .macappstore installations of OF
--Ver 1.8 Adjusts handling of variant bundle identifiers generally
-- Ver 2.00 Redraft of task breakdown, with progressive narrowing of criteria ...

property pToClipboard : "Copy list to clipboard"

if not FileExists(pstrDBPath) then set pstrDBPath to GetCachePath()

tell application "Finder"
	if (version < pstrMinOSX) then
		display dialog "This script requires OSX " & pstrMinOSX & " or higher" buttons {"OK"} default button 1 with title pTitle & "Ver. " & pVersion
		return
	end if

	set screen_resolution to bounds of window of desktop
	set height to item 4 of screen_resolution
	if height < 900 then
		set brief to true
	else
		set brief to false
	end if
end tell

if pstrDBPath  "" then
	set inbox_cmd to "
	select 'INBOX GROUPS & ACTIONS', count(*) from task where (inInbox=1);
	select '    Inbox action groups', count(*) from task where (inInbox=1) and (childrenCount>0);
	select '    Inbox actions', count(*) from task where (inInbox=1) and (childrenCount=0);
	select null;
	"
	set folders_cmd to "
	select 'FOLDERS'	, count(*) from folder;
	select '    Active folders', count(*) from folder where effectiveActive=1;
	select '    Dropped folders', count(*) from folder where effectiveActive=0;
	select null;
	"
	set projects_cmd to "
	select 'PROJECTS', count(*) from projectInfo where containsSingletonActions=0;
	select '    Active projects', count(*) from projectInfo where (containsSingletonActions=0) and (status='active');
	select '            Current projects', count(*) from projectInfo p join task t on t.projectinfo=p.pk where (p.containsSingletonActions=0) and (p.folderEffectiveActive=1) and (p.status='active') and (t.dateToStart is null or t.dateToStart < (strftime('%s','now') - strftime('%s','2001-01-01')));
	select '            Pending projects', count(*) from projectInfo p join task t on t.projectinfo=p.pk where (p.containsSingletonActions=0) and (p.folderEffectiveActive=1) and (p.status='active') and (t.dateToStart > (strftime('%s','now') - strftime('%s','2001-01-01')));
	select '    On-hold projects', count(*) from projectInfo where (containsSingletonActions=0) and (status='inactive');
	select '    Completed projects', count(*) from projectInfo where (containsSingletonActions=0) and (status='done');
	select '    Dropped projects', count(*) from projectInfo where (containsSingletonActions=0) and (( status='dropped') or (folderEffectiveActive=0));
	select null;
	"
	set lists_cmd to "
	select 'SINGLE ACTION LISTS', count(*) from projectInfo where containsSingletonActions=1;
	select '    Active single action lists', count(*) from projectInfo where (containsSingletonActions=1) and (status='active');
	select '    On-hold single action lists', count(*) from projectInfo where (containsSingletonActions=1) and (status='inactive');
	select '    Completed single action lists', count(*) from projectInfo where (containsSingletonActions=1) and (status='done');
	select '    Dropped single action lists', count(*) from projectInfo where (containsSingletonActions=1) and (( status='dropped') or (folderEffectiveActive=0));
	select null;
	"
	set contexts_cmd to "
	select 'CONTEXTS', count(*) from context;
	select '    Active contexts', count(*) from context where (effectiveActive=1) and (allowsNextAction=1);
	select '    On-hold contexts', count(*) from context where (effectiveActive=1) and allowsNextAction=0;
	select '    Dropped contexts', count(*) from context where effectiveActive=0;
	select null;
	"
	set groups_cmd to "
	select 'ACTION GROUPS', count(*) from task where (projectinfo is null) and (childrenCount>0);
	select '    Remaining action groups', count(*) from task where (projectinfo is null) and (dateCompleted is null) and (childrenCount>0);
	select '    Completed action groups', count(dateCompleted) from task where (projectinfo is null) and (childrenCount>0);
	select null;
	"
	set tasks_cmd to "
	select 'ALL TASKS', count(*) from task;
	select null;
	"
	set actions_cmd to "
	select 'ACTIONS', count(*) from task where (projectinfo is null) and (childrenCount=0);
	select '    Completed actions', count(dateCompleted) from task where (projectinfo is null) and (childrenCount=0);
	select '    Dropped project actions', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp where (projectinfo is null) and (childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is not null and (tp.status='dropped' or tp.folderEffectiveActive=0));
	select '    Dropped context actions', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (projectinfo is null) and (tp.childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and c.effectiveActive= 0;
	select '    Remaining actions', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (projectinfo is null) and (tp.childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.context is null or c.effectiveActive= 1);
	select '        Actions in Projects on hold', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (projectinfo is null) and (tp.childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.context is null or c.effectiveActive= 1)
				and (tp.containingProjectInfo is not null and tp.status='inactive');
	select '        Actions in Contexts on hold', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (projectinfo is null) and (tp.childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.context is null or c.effectiveActive= 1)
				and (tp.containingProjectInfo is null or tp.status!='inactive')
				and (tp.context is not null and c.allowsNextAction=0);
	select '        Blocked actions', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (projectinfo is null) and (tp.childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.context is null or c.effectiveActive= 1)
				and (tp.containingProjectInfo is null or tp.status!='inactive')
				and (tp.context is null or c.allowsNextAction=1)
				and tp.blocked=1;
	select '        	Blocked by future start date', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (projectinfo is null) and (tp.childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.context is null or c.effectiveActive= 1)
				and (tp.containingProjectInfo is null or tp.status!='inactive')
				and (tp.context is null or c.allowsNextAction=1)
				and tp.blocked=1
				and tp.blockedByFutureStartDate=1;
	select '        	Sequentially blocked', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (projectinfo is null) and (tp.childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.context is null or c.effectiveActive= 1)
				and (tp.containingProjectInfo is null or tp.status!='inactive')
				and (tp.context is null or c.allowsNextAction=1)
				and tp.blocked=1
				and tp.blockedByFutureStartDate=0;
	select '        Available actions', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (projectinfo is null) and (tp.childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.context is null or c.effectiveActive= 1)
				and (tp.containingProjectInfo is null or tp.status!='inactive')
				and (tp.context is null or c.allowsNextAction=1)
				and tp.blocked=0;
	select null;
	"
	set summary_cmd to "
	select 'SUMMARY';
	select '    Inbox available actions', count(*) from task where (inInbox=1) and (dateCompleted is null);
	select '    Due in next week', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (((projectinfo is null) and (tp.childrenCount=0))  or containsSingletonActions=0) and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.containingProjectInfo is null or tp.status!='inactive')
				and tp.blockedByFutureStartDate=0
				and effectiveDateDue <= strftime('%s','now','+7 days') - strftime('%s','2001-01-01');
	select '    Flagged projects and actions', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (((projectinfo is null) and (tp.childrenCount=0))  or containsSingletonActions=0) and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.containingProjectInfo is null or tp.status!='inactive')
				and tp.blockedByFutureStartDate=0
				and tp.effectiveFlagged;
	select '    Due or Flagged', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (((projectinfo is null) and (tp.childrenCount=0))  or containsSingletonActions=0) and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.containingProjectInfo is null or tp.status!='inactive')
				and tp.blockedByFutureStartDate=0
				and (tp.effectiveFlagged or (effectiveDateDue <= strftime('%s','now','+7 days') - strftime('%s','2001-01-01')));
	select null;
	"
	if brief then
		set commands to projects_cmd & lists_cmd & contexts_cmd & groups_cmd & actions_cmd & summary_cmd
	else
		set commands to inbox_cmd & folders_cmd & projects_cmd & lists_cmd & contexts_cmd & groups_cmd & actions_cmd & tasks_cmd & summary_cmd
	end if
	set strCmd to "sqlite3 -separator ': ' \"" & pstrDBPath & "\" " & quoted form of (commands)

	-- 		try
	set strList to do shell script strCmd
	-- 		on error
	-- 			display dialog "The SQL schema for the OmniFocus cache may have changed in a recent update of OF." & return & return &
	-- 				"Look on the OmniFocus user forums for an updated version of this script." buttons {"OK"} with title pTitle & "Ver. " & pVersion
	-- 			return
	-- 		end try
	tell application id "sevs"
		activate
		if button returned of (display dialog strList buttons {pToClipboard, "OK"} default button "OK" giving up after pTimeOut with title pTitle & " Ver. " & pVersion)
			is pToClipboard then tell application id "com.apple.finder" to set the clipboard to strList
	end tell
else
	tell application id "sevs"
		activate
		display dialog "OmniFocus cache not found ..." buttons {"OK"} default button 1 with title pTitle & " Ver. " & pVersion
	end tell
end if

on FileExists(strPath)
	(do shell script "test -e " & strPath & " ; echo $?") = "0"
end FileExists

on GetCachePath()
	try
		tell application "Finder" to tell (application file id "OFOC") to "$HOME/Library/Containers/com.omnigroup.OmniFocus2/Data/Library/Caches/" & its id & "/OmniFocusDatabase2"
	on error
		error "OmniFocus not installed ..."
	end try
end GetCachePath

property pTitle : "OmniFocus: Quick Stats"
property pVersion : "2.07.brett"

property pstrDBPath : "$HOME/Library/Containers/com.omnigroup.OmniFocus2/Data/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2"
property pstrMinOSX : "10.9"

property pTimeOut : 30

-- Original version: https://github.com/RobTrew/tree-tools/blob/master/OmniFocus%20scripts/Statistics/QuickStats.applescript

-- Copyright  2012, 2013, 2014 Robin Trew
--
-- Permission is hereby granted, free of charge,
-- to any person obtaining a copy of this software
-- and associated documentation files (the "Software"),
-- to deal in the Software without restriction,
-- including without limitation the rights to use, copy,
-- modify, merge, publish, distribute, sublicense,
-- and/or sell copies of the Software, and to permit persons
-- to whom the Software is furnished to do so,
-- subject to the following conditions:
--
-- *******
-- The above copyright notice and this permission notice
-- shall be included in ALL copies
-- or substantial portions of the Software.
-- *******
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-- OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

-- Ver 0.8 adds clipboard option to dialogue
-- Ver 0.9 gives an error message if the cache schema has changed, leading to an SQL error in the script
-- Ver 1.0 slight simplification of the code
-- Ver 1.1 added count of Pending projects
-- Ver 1.2 added a count of available actions
-- Ver 1.3 added a break-down of unavailable actions
-- Ver 1.4 added count of Current projects to complement Pending projects
-- ver 1.5 replaced Applescript time function with SQL time expression
-- Ver 1.7 Reorganizes menu, and attempts to enable access for .macappstore installations of OF
--Ver 1.8 Adjusts handling of variant bundle identifiers generally
-- Ver 2.00 Redraft of task breakdown, with progressive narrowing of criteria ...

property pToClipboard : "Copy list to clipboard"

if not FileExists(pstrDBPath) then set pstrDBPath to GetCachePath()

tell application "Finder"
	if (version < pstrMinOSX) then
		display dialog "This script requires OSX " & pstrMinOSX & " or higher" buttons {"OK"} default button 1 with title pTitle & "Ver. " & pVersion
		return
	end if

	set screen_resolution to bounds of window of desktop
	set height to item 4 of screen_resolution
	if height < 900 then
		set brief to true
	else
		set brief to false
	end if
end tell

if pstrDBPath  "" then
	set inbox_cmd to "
	select 'INBOX GROUPS & ACTIONS', count(*) from task where (inInbox=1);
	select '    Inbox action groups', count(*) from task where (inInbox=1) and (childrenCount>0);
	select '    Inbox actions', count(*) from task where (inInbox=1) and (childrenCount=0);
	select null;
	"
	set folders_cmd to "
	select 'FOLDERS'	, count(*) from folder;
	select '    Active folders', count(*) from folder where effectiveActive=1;
	select '    Dropped folders', count(*) from folder where effectiveActive=0;
	select null;
	"
	set projects_cmd to "
	select 'PROJECTS', count(*) from projectInfo where containsSingletonActions=0;
	select '    Active projects', count(*) from projectInfo where (containsSingletonActions=0) and (status='active');
	select '            Current projects', count(*) from projectInfo p join task t on t.projectinfo=p.pk where (p.containsSingletonActions=0) and (p.folderEffectiveActive=1) and (p.status='active') and (t.dateToStart is null or t.dateToStart < (strftime('%s','now') - strftime('%s','2001-01-01')));
	select '            Pending projects', count(*) from projectInfo p join task t on t.projectinfo=p.pk where (p.containsSingletonActions=0) and (p.folderEffectiveActive=1) and (p.status='active') and (t.dateToStart > (strftime('%s','now') - strftime('%s','2001-01-01')));
	select '    On-hold projects', count(*) from projectInfo where (containsSingletonActions=0) and (status='inactive');
	select '    Completed projects', count(*) from projectInfo where (containsSingletonActions=0) and (status='done');
	select '    Dropped projects', count(*) from projectInfo where (containsSingletonActions=0) and (( status='dropped') or (folderEffectiveActive=0));
	select null;
	"
	set lists_cmd to "
	select 'SINGLE ACTION LISTS', count(*) from projectInfo where containsSingletonActions=1;
	select '    Active single action lists', count(*) from projectInfo where (containsSingletonActions=1) and (status='active');
	select '    On-hold single action lists', count(*) from projectInfo where (containsSingletonActions=1) and (status='inactive');
	select '    Completed single action lists', count(*) from projectInfo where (containsSingletonActions=1) and (status='done');
	select '    Dropped single action lists', count(*) from projectInfo where (containsSingletonActions=1) and (( status='dropped') or (folderEffectiveActive=0));
	select null;
	"
	set contexts_cmd to "
	select 'CONTEXTS', count(*) from context;
	select '    Active contexts', count(*) from context where (effectiveActive=1) and (allowsNextAction=1);
	select '    On-hold contexts', count(*) from context where (effectiveActive=1) and allowsNextAction=0;
	select '    Dropped contexts', count(*) from context where effectiveActive=0;
	select null;
	"
	set groups_cmd to "
	select 'ACTION GROUPS', count(*) from task where (projectinfo is null) and (childrenCount>0);
	select '    Remaining action groups', count(*) from task where (projectinfo is null) and (dateCompleted is null) and (childrenCount>0);
	select '    Completed action groups', count(dateCompleted) from task where (projectinfo is null) and (childrenCount>0);
	select null;
	"
	set tasks_cmd to "
	select 'ALL TASKS', count(*) from task;
	select null;
	"
	set actions_cmd to "
	select 'ACTIONS', count(*) from task where (projectinfo is null) and (childrenCount=0);
	select '    Completed actions', count(dateCompleted) from task where (projectinfo is null) and (childrenCount=0);
	select '    Dropped project actions', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp where (projectinfo is null) and (childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is not null and (tp.status='dropped' or tp.folderEffectiveActive=0));
	select '    Dropped context actions', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (projectinfo is null) and (tp.childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and c.effectiveActive= 0;
	select '    Remaining actions', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (projectinfo is null) and (tp.childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.context is null or c.effectiveActive= 1);
	select '        Actions in Projects on hold', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (projectinfo is null) and (tp.childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.context is null or c.effectiveActive= 1)
				and (tp.containingProjectInfo is not null and tp.status='inactive');
	select '        Actions in Contexts on hold', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (projectinfo is null) and (tp.childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.context is null or c.effectiveActive= 1)
				and (tp.containingProjectInfo is null or tp.status!='inactive')
				and (tp.context is not null and c.allowsNextAction=0);
	select '        Blocked actions', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (projectinfo is null) and (tp.childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.context is null or c.effectiveActive= 1)
				and (tp.containingProjectInfo is null or tp.status!='inactive')
				and (tp.context is null or c.allowsNextAction=1)
				and tp.blocked=1;
	select '        	Blocked by future start date', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (projectinfo is null) and (tp.childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.context is null or c.effectiveActive= 1)
				and (tp.containingProjectInfo is null or tp.status!='inactive')
				and (tp.context is null or c.allowsNextAction=1)
				and tp.blocked=1
				and tp.blockedByFutureStartDate=1;
	select '        	Sequentially blocked', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (projectinfo is null) and (tp.childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.context is null or c.effectiveActive= 1)
				and (tp.containingProjectInfo is null or tp.status!='inactive')
				and (tp.context is null or c.allowsNextAction=1)
				and tp.blocked=1
				and tp.blockedByFutureStartDate=0;
	select '        Available actions', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (projectinfo is null) and (tp.childrenCount=0)  and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.context is null or c.effectiveActive= 1)
				and (tp.containingProjectInfo is null or tp.status!='inactive')
				and (tp.context is null or c.allowsNextAction=1)
				and tp.blocked=0;
	select null;
	"
	set summary_cmd to "
	select 'SUMMARY';
	select '    Inbox available actions', count(*) from task where (inInbox=1) and (dateCompleted is null);
	select '    Due in next week', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (((projectinfo is null) and (tp.childrenCount=0))  or containsSingletonActions=0) and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.containingProjectInfo is null or tp.status!='inactive')
				and tp.blockedByFutureStartDate=0
				and effectiveDateDue <= strftime('%s','now','+7 days') - strftime('%s','2001-01-01');
	select '    Flagged projects and actions', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (((projectinfo is null) and (tp.childrenCount=0))  or containsSingletonActions=0) and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.containingProjectInfo is null or tp.status!='inactive')
				and tp.blockedByFutureStartDate=0
				and tp.effectiveFlagged;
	select '    Due or Flagged', count(*) from (task t left join projectinfo p on t.containingProjectinfo=p.pk) tp left join context c on tp.context=c.persistentIdentifier where (((projectinfo is null) and (tp.childrenCount=0))  or containsSingletonActions=0) and (dateCompleted is null)
				and (tp.containingProjectinfo is null or (tp.status !='dropped' and tp.folderEffectiveActive=1))
				and (tp.containingProjectInfo is null or tp.status!='inactive')
				and tp.blockedByFutureStartDate=0
				and (tp.effectiveFlagged or (effectiveDateDue <= strftime('%s','now','+7 days') - strftime('%s','2001-01-01')));
	select null;
	"
	if brief then
		set commands to projects_cmd & lists_cmd & contexts_cmd & groups_cmd & actions_cmd & summary_cmd
	else
		set commands to inbox_cmd & folders_cmd & projects_cmd & lists_cmd & contexts_cmd & groups_cmd & actions_cmd & tasks_cmd & summary_cmd
	end if
	set strCmd to "sqlite3 -separator ': ' \"" & pstrDBPath & "\" " & quoted form of (commands)

	-- 		try
	set strList to do shell script strCmd
	-- 		on error
	-- 			display dialog "The SQL schema for the OmniFocus cache may have changed in a recent update of OF." & return & return &
	-- 				"Look on the OmniFocus user forums for an updated version of this script." buttons {"OK"} with title pTitle & "Ver. " & pVersion
	-- 			return
	-- 		end try
	tell application id "sevs"
		activate
		if button returned of (display dialog strList buttons {pToClipboard, "OK"} default button "OK" giving up after pTimeOut with title pTitle & " Ver. " & pVersion)
			is pToClipboard then tell application id "com.apple.finder" to set the clipboard to strList
	end tell
else
	tell application id "sevs"
		activate
		display dialog "OmniFocus cache not found ..." buttons {"OK"} default button 1 with title pTitle & " Ver. " & pVersion
	end tell
end if

on FileExists(strPath)
	(do shell script "test -e " & strPath & " ; echo $?") = "0"
end FileExists

on GetCachePath()
	try
		tell application "Finder" to tell (application file id "OFOC") to "$HOME/Library/Containers/com.omnigroup.OmniFocus2/Data/Library/Caches/" & its id & "/OmniFocusDatabase2"
	on error
		error "OmniFocus not installed ..."
	end try
end GetCachePath

increase the timeout

increase the timeout


-- stolen from: https://discussions.apple.com/thread/3172966
property keyPhrase : "Trashed on: "
property securityLevel : 2 -- overwrites: 1=1-pass, 2=7-pass, 3=35-pass,  see man srm
property daysToWait : 7

tell application "Finder"
  -- get files in trash that are not new, and check dates
          set oldFiles to (every item of trash whose comment contains keyPhrase)
          set trashmeFiles to ""
          repeat with thisFile in oldFiles
  -- extract trashed date from the spotlight comments
                    set trashedDate to last item of my tid(comment of thisFile, keyPhrase)
                    try
  -- check dates in a try block in case of weirdness)
                              if my checkDate(trashedDate) then
                                        log thisFile
                                        set trashmeFiles to trashmeFiles & " " & my makePosix(thisFile as alias)
                              end if
                    end try
          end repeat

  -- trash 'em in a subroutine
          my trashEm(trashmeFiles)

  -- gather new files
          set newFiles to every item of trash whose comment does not contain keyPhrase
  -- add the current date to the spotlight comment of the new files
          repeat with thisFile in newFiles
                    set c to comment of thisFile
                    if c = "" then
                              set comment of thisFile to keyPhrase & short date string of (current date)
                    else
                              set comment of thisFile to c & return & keyPhrase & short date string of (current date)
                    end if
          end repeat
end tell

on trashEm(fs)
  -- set up proper security level
          if securityLevel = 1 then
                    set cmd to "srm -rfsz"
          else if securityLevel = 3 then
                    set cmd to "srm -rfz"
          else
                    set cmd to "srm -rfmz"
          end if

  -- start a secure delete process in the background
          do shell script cmd & fs & " &> /dev/null &"
end trashEm

on tid(input, delim)
  -- generic subroutine to handle text items
          set {oldTID, my text item delimiters} to {my text item delimiters, delim}
          if class of input is list then
                    set output to input as text
          else
                    set output to text items of input
          end if
          set my text item delimiters to oldTID
          return output
end tid

on makePosix(f)
          return quoted form of POSIX path of f
end makePosix

on checkDate(d)
	set n to short date string of ((current date) - daysToWait * days)
	log d
	log n
	log (date d) ≤ (date n)
	-- log (date d) ≤ short date string of ((current date) - daysToWait * days)
	-- return (date d) ≤ short date string of ((current date) - daysToWait * days)
end checkDate

-- stolen from: https://discussions.apple.com/thread/3172966
property keyPhrase : "Trashed on: "
property securityLevel : 2 -- overwrites: 1=1-pass, 2=7-pass, 3=35-pass,  see man srm
property daysToWait : 7

tell application "Finder"
  -- get files in trash that are not new, and check dates
          set oldFiles to (every item of trash whose comment contains keyPhrase)
          set trashmeFiles to ""
          repeat with thisFile in oldFiles
  -- extract trashed date from the spotlight comments
                    set trashedDate to last item of my tid(comment of thisFile, keyPhrase)
                    try
  -- check dates in a try block in case of weirdness)
                              if my checkDate(trashedDate) then
                                        log thisFile
                                        set trashmeFiles to trashmeFiles & " " & my makePosix(thisFile as alias)
                              end if
                    end try
          end repeat

  -- trash 'em in a subroutine
          my trashEm(trashmeFiles)

  -- gather new files
          set newFiles to every item of trash whose comment does not contain keyPhrase
  -- add the current date to the spotlight comment of the new files
          repeat with thisFile in newFiles
                    set c to comment of thisFile
                    if c = "" then
                              set comment of thisFile to keyPhrase & short date string of (current date)
                    else
                              set comment of thisFile to c & return & keyPhrase & short date string of (current date)
                    end if
          end repeat
end tell

on trashEm(fs)
  -- set up proper security level
          if securityLevel = 1 then
                    set cmd to "srm -rfsz"
          else if securityLevel = 3 then
                    set cmd to "srm -rfz"
          else
                    set cmd to "srm -rfmz"
          end if

  -- start a secure delete process in the background
          do shell script cmd & fs & " &> /dev/null &"
end trashEm

on tid(input, delim)
  -- generic subroutine to handle text items
          set {oldTID, my text item delimiters} to {my text item delimiters, delim}
          if class of input is list then
                    set output to input as text
          else
                    set output to text items of input
          end if
          set my text item delimiters to oldTID
          return output
end tid

on makePosix(f)
          return quoted form of POSIX path of f
end makePosix

on checkDate(d)
	set n to short date string of ((current date) - daysToWait * days)
	log d
	log n
	log (date d) ≤ (date n)

	return (date d) ≤ (date n)
	-- log (date d) ≤ short date string of ((current date) - daysToWait * days)
	-- return (date d) ≤ short date string of ((current date) - daysToWait * days)
end checkDate

allow for weird dates

allow for weird dates


#!/usr/bin/env osascript

-- Fist: Click Install Button
delay 0.4
tell application "System Events"
  set installer to "Install Command Line Developer Tools"
  click UI Element "Install" of window 1 of installer
  click UI Element "Agree" of window 1 of installer
end tell

#!/usr/bin/env osascript

-- Fist: Click Install Button
delay 0.4
tell application "System Events"
  set installer to application process "Install Command Line Developer Tools"
  click UI Element "Install" of window 1 of installer
  click UI Element "Agree" of window 1 of installer
end tell

Fix fatal mistake

Fix fatal mistake


tell application "Finder"
	set json_path to file "json.scpt" of folder of (path to me)
end tell
set json to load script (json_path as alias)

on is_running(appName)
	tell application "System Events" to (name of processes) contains appName
end is_running

set reply to json's createDict()
if is_running("Hermes") then
	reply's setkv("running", true)
	set hermesInfo to json's createDict()
	tell application "Hermes"
		hermesInfo's setkv("state", playback state as string)
		hermesInfo's setkv("title", current song's title)
		hermesInfo's setkv("artist", current song's artist)
		hermesInfo's setkv("album", current song's album)
		hermesInfo's setkv("artwork", current song's artwork URL)
		hermesInfo's setkv("rating", current song's rating)
		hermesInfo's setkv("position", playback position as integer)
		hermesInfo's setkv("duration", current song duration as integer)
	end tell
	reply's setkv("info", hermesInfo)
else
	reply's setkv("running", false)
end if
return reply's toJson()

tell application "Finder"
	set json_path to file "json.scpt" of folder of (path to me)
end tell
set json to load script (json_path as alias)

on is_running(appName)
	tell application "System Events" to (name of processes) contains appName
end is_running

set reply to json's createDict()
if is_running("Hermes") then
	reply's setkv("running", true)
	set hermesInfo to json's createDict()
	set hermesStations to json's createDict()
	tell application "Hermes"
		hermesInfo's setkv("state", playback state as string)
		hermesInfo's setkv("volume", playback volume)

-- XXX: execution error: Hermes got an error: every station doesn’t understand the “count” message. (-1708)
--		repeat with theStation in stations
--			hermesStations's setkv("name", theStation's name)
--			hermesStations's setkv("id", theStation's station ID)
--		end repeat

		hermesInfo's setkv("title", current song's title)
		hermesInfo's setkv("artist", current song's artist)
		hermesInfo's setkv("album", current song's album)
		hermesInfo's setkv("artwork", current song's artwork URL)
		hermesInfo's setkv("rating", current song's rating)
		hermesInfo's setkv("position", playback position as integer)
		hermesInfo's setkv("duration", current song duration as integer)
		hermesInfo's setkv("station_name", current station's name)
		hermesInfo's setkv("station_id", current station's station ID)
	end tell
	hermesInfo's setkv("stations", hermesStations)
	reply's setkv("info", hermesInfo)
else
	reply's setkv("running", false)
end if
return reply's toJson()

add volume and stations framework for when i fix it


set open_vagrant to "z puppet; vagrant up;"

tell application "iTerm"
	activate
	try
		set mysession to current session of current terminal
	on error
		set myterm to (make new terminal)
		tell myterm
			launch session "Default"
			set mysession to current session
		end tell
	end try

	tell mysession
		write text open_vagrant
	end tell
end tell

set open_vagrant to "z puppet; vagrant up;"
set update_master to "/Users/alex/.homesick/repos/palcu/dotfiles/scripts/update_master.sh;"

tell application "iTerm"
	activate
	try
		set mysession to current session of current terminal
	on error
		set myterm to (make new terminal)
		tell myterm
			launch session "Default"
			set mysession to current session
		end tell
	end try

	tell mysession
        write text update_master
		write text open_vagrant
	end tell
end tell

Add update script to open vagrant applescript


on escape_quotes(string_to_escape)
  set AppleScript's text item delimiters to the "\""
  set the item_list to every text item of string_to_escape
  set AppleScript's text item delimiters to the "\\\""
  set string_to_escape to the item_list as string
  set AppleScript's text item delimiters to ""
  return string_to_escape
end escape_quotes

tell application "Spotify"
  set ctrack to "{"
  set ctrack to ctrack & "\"artist\": \"" & my escape_quotes(current track's artist) & "\""
  set ctrack to ctrack & ",\"album\": \"" & my escape_quotes(current track's album) & "\""
  set ctrack to ctrack & ",\"disc_number\": " & current track's disc number
  set ctrack to ctrack & ",\"duration\": " & current track's duration
  set ctrack to ctrack & ",\"played_count\": " & current track's played count
  set ctrack to ctrack & ",\"track_number\": " & current track's track number
  set ctrack to ctrack & ",\"popularity\": " & current track's popularity
  set ctrack to ctrack & ",\"id\": \"" & current track's id & "\""
  set ctrack to ctrack & ",\"name\": \"" & my escape_quotes(current track's name) & "\""
  set ctrack to ctrack & ",\"album_artist\": \"" & my escape_quotes(current track's album artist) & "\""
  set ctrack to ctrack & ",\"spotify_url\": \"" & current track's spotify url & "\""
  set ctrack to ctrack & "}"
end tell

on escape_quotes(string_to_escape)
	set AppleScript's text item delimiters to the "\""
	set the item_list to every text item of string_to_escape
	set AppleScript's text item delimiters to the "\\\""
	set string_to_escape to the item_list as string
	set AppleScript's text item delimiters to ""
	return string_to_escape
end escape_quotes

tell application "Spotify"
	set ctrack to "{"
	set ctrack to ctrack & "\"artist\": \"" & my escape_quotes(current track's artist) & "\""
	set ctrack to ctrack & ",\"album\": \"" & my escape_quotes(current track's album) & "\""
	set ctrack to ctrack & ",\"disc_number\": " & current track's disc number
	set ctrack to ctrack & ",\"duration\": " & current track's duration
	set ctrack to ctrack & ",\"played_count\": " & current track's played count
	set ctrack to ctrack & ",\"track_number\": " & current track's track number
	set ctrack to ctrack & ",\"popularity\": " & current track's popularity
	set ctrack to ctrack & ",\"id\": \"" & current track's id & "\""
	set ctrack to ctrack & ",\"name\": \"" & my escape_quotes(current track's name) & "\""
	set ctrack to ctrack & ",\"album_artist\": \"" & my escape_quotes(current track's album artist) & "\""
	set ctrack to ctrack & ",\"artwork_url\": \"" & current track's artwork url & "\""
	set ctrack to ctrack & ",\"spotify_url\": \"" & current track's spotify url & "\""
	set ctrack to ctrack & "}"
end tell

add album artwork url to get_track

add album artwork url to get_track


(*
Copyright (c) 2015-present, Facebook, Inc.
All rights reserved.

This source code is licensed under the BSD-style license found in the
-- LICENSE file in the root directory of this source tree. An additional grant
of patent rights can be found in the PATENTS file in the same directory.
*)

on run argv
  set theURL to item 1 of argv

  tell application "Chrome"

    if (count every window) = 0 then
      make new window
    end if

    -- Find a tab currently running the debugger
    set found to false
    set theTabIndex to -1
    repeat with theWindow in every window
      set theTabIndex to 0
      repeat with theTab in every tab of theWindow
        set theTabIndex to theTabIndex + 1
        if theTab's URL is theURL then
          set found to true
          exit repeat
        end if
      end repeat

      if found then
        exit repeat
      end if
    end repeat

    if found then
      tell theTab to reload
      set index of theWindow to 1
      set theWindow's active tab index to theTabIndex
    else
      tell window 1
        activate
        make new tab with properties {URL:theURL}
      end tell
    end if
  end tell
end run

(*
Copyright (c) 2015-present, Facebook, Inc.
All rights reserved.

This source code is licensed under the BSD-style license found in the
-- LICENSE file in the root directory of this source tree. An additional grant
of patent rights can be found in the PATENTS file in the same directory.
*)

on run argv
  set theURL to item 1 of argv

  tell application "Chrome"

    if (count every window) = 0 then
      make new window
    end if

    -- Find a tab currently running the debugger
    set found to false
    set theTabIndex to -1
    repeat with theWindow in every window
      set theTabIndex to 0
      repeat with theTab in every tab of theWindow
        set theTabIndex to theTabIndex + 1
        if theTab's URL as string contains theURL then
          set found to true
          exit repeat
        end if
      end repeat

      if found then
        exit repeat
      end if
    end repeat

    if found then
      tell theTab to reload
      set index of theWindow to 1
      set theWindow's active tab index to theTabIndex
      tell theWindow to activate
    else
      tell window 1
        activate
        make new tab with properties {URL:theURL}
      end tell
    end if
  end tell
end run

Fix chrome tab reuse (#1035)

Fix chrome tab reuse (#1035)

* Correctly checks site url to tab url in reuse check

* Bring chrome to foreground focused after tab reuse


(*
  Script object to make calling a defined function easier while in the
  iTunes and System Events name space.
*)
script remoteSpeakerFinder
	global the_bwindow, the_state

	-- Given a list of buttons, find the remote speakers button
	-- by finding the first button with a name that isn't in a
	-- rejection list.
	on findCorrectButton(in_buttons)
		set buttons_to_skip to {"Burn Disc"}

		repeat with a_button in in_buttons
			try -- some buttons don't have names
				set the_name to name of a_button
				if buttons_to_skip does not contain {the_name} then
					return the_name
				end if
			end try
		end repeat

		return 16 -- default response
	end findCorrectButton

	on setRemoteSpeakersTo(item_index)
		tell application "System Events"
			tell process "iTunes"

				set the_buttons to (get buttons of window 1)
				set the_speaker_button to (remoteSpeakerFinder's findCorrectButton(the_buttons))

				-- Switch to the speakers in my bedroom
				set frontmost to true
				click button the_speaker_button of window 1
				key code 115 -- Home Key (first speaker in list)

				repeat item_index times
					key code 125 -- Down Arrow
				end repeat

				key code 36 -- Return Key

				-- Wait for iTunes to connect to the speakers
				delay 5
			end tell
		end tell
	end setRemoteSpeakersTo

	on prepareWindow()
		tell application "iTunes"
			set the_bwindow to (get first browser window)
			set the_state to (get minimized of the_bwindow)
			set visible of the_bwindow to true
			set minimized of the_bwindow to false
		end tell
	end prepareWindow

	on resetWindow()
		tell application "iTunes"
			-- Return window to previous state
			set minimized of the_bwindow to the_state
		end tell
	end resetWindow
end script

on handle_string(s)
	remoteSpeakerFinder's prepareWindow()
	remoteSpeakerFinder's setRemoteSpeakersTo(s)
	remoteSpeakerFinder's resetWindow()
	set volume 1
	tell application "iTunes"
		play (get the first item of (get every track where database ID is 24759))
	end tell
end handle_string

on run
	remoteSpeakerFinder's prepareWindow()
	remoteSpeakerFinder's setRemoteSpeakersTo(2)
	remoteSpeakerFinder's resetWindow()
end run

(*
  Script object to make calling a defined function easier while in the
  iTunes and System Events name space.
*)
script remoteSpeakerFinder
	global the_bwindow, the_state

	-- Find the remote speakers button
	on findCorrectButton()
		tell application "System Events"
			tell process "iTunes"
				set in_buttons to (get buttons of window 1)

				repeat with a_button in in_buttons
					set the_desc to (get description of a_button)
					if the_desc is equal to "remote speakers" then
						return a_button
					end if
				end repeat
			end tell
		end tell
	end findCorrectButton

	on setRemoteSpeakersTo(item_index)
		tell application "System Events"
			tell process "iTunes"

				set the_speaker_button to (remoteSpeakerFinder's findCorrectButton())

				-- Switch to the speakers in my bedroom
				set frontmost to true
				click the_speaker_button
				key code 115 -- Home Key (first speaker in list)

				repeat item_index times
					key code 125 -- Down Arrow
				end repeat

				key code 36 -- Return Key

				-- Wait for iTunes to connect to the speakers
				delay 5
			end tell
		end tell
	end setRemoteSpeakersTo

	on prepareWindow()
		tell application "iTunes"
			set the_bwindow to (get first browser window)
			set the_state to (get minimized of the_bwindow)
			set visible of the_bwindow to true
			set minimized of the_bwindow to false
		end tell
	end prepareWindow

	on resetWindow()
		tell application "iTunes"
			-- Return window to previous state
			set minimized of the_bwindow to the_state
		end tell
	end resetWindow
end script

on handle_string(s)
	tell application "iTunes" to stop
	remoteSpeakerFinder's prepareWindow()
	remoteSpeakerFinder's setRemoteSpeakersTo(s)
	remoteSpeakerFinder's resetWindow()
	set volume 1
	tell application "iTunes" to play (get the first item of (get every track where database ID is 24759))
end handle_string

on run
	remoteSpeakerFinder's prepareWindow()
	remoteSpeakerFinder's setRemoteSpeakersTo(2)
	remoteSpeakerFinder's resetWindow()
end run

Update for iTunes 10

Update for iTunes 10


FasdUAS 1.101.10
k
l>
O>
k=

I
.miscactvnullnull

O
*
k)
l
I
.prcskprsnullctxt
mp

faal
J
m
eMdsKcmd activate print menu item2 activate print menu item
I!
.sysodelanullnmbr
!m""? #$
#l#%&'
%I#(
.prcskprsnullctxt
(o

ret & print')) print$*
*I$)+
.sysodelanullnmbr
+m$%,,@
m
--sevsalisMacintosh HDΘ*SH+-System Events.appjX|	 CoreServicesΗX
-*)=Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/./
.l++/01
0r+123
24+/4

cwin
4m-.
3o0w156
5r2778
7n259:
9135

cTab
:o230w
8o0t6;
;I8=<
.coreclosnullobj
<o890t
	m==sfrialisNMacintosh HDΘ*SH+O
Safari.app!G͝
r	 ApplicationsΗ͜O%Macintosh HD:Applications:Safari.app
Safari.appMacintosh HDApplications/Safari.app/>
>l?@AB?
.aevtoappnull****0w0t@CDE
.aevtoappnull****
Ck>FFDE=-",
.miscactvnullnull

faal
eMdsKcmd
.prcskprsnullctxt
.sysodelanullnmbr

ret

cwin0w

cTab0t
.coreclosnullobj ?;*jOkvlOjOjOjUO*k/EO,EOjUAGG=

cwin֡
kfrmID  BHHII=

cwin֡
kfrmID

bTabascr
ޭ

FasdUAS 1.101.10
k
i
I
.aevtoappnull****
	o0argv
k

l

 printer ?????? printer 0o_ep0gn!0Y
l 1. last use printer( 1. last use printer
l 2. none 2. none
l 3. your printer 1$ 3. your printer 1
l!"! 4. your printer 2"##$ 4. your printer 2 $%
$l&'&
 and so on'(( and so on%)*
)r+,
+[-.
-m
.l/
/n01
042

cobj
2m
1o0argv
,o0printer*34
3l		456
5O	`78
7k
_99:;
:I

.miscactvnullnull;<=
<r>?
>5@

xppb
@mAABB:com.apple.preference.printfax
kfrmID
?1

xpcp=CD
CI"E
.sysodelanullnmbr
EmFF?DGH
Gl##HIJ
IO#]KL
KO'\MN
Mk.[OOPQ
PI.9R
.prcsclicnulluiel
Rn.5ST
S425U

popB
Um34
T4.2V

cwin
Vm01QWX
WI:?Y
.sysodelanullnmbr
Ym:;ZZ?X[\
[l@@]^] 1????????3^__ 10dv0n00000o3\`a
`l@@bcb 2????????4 ????2??????cdd. 20dv0n00000o4 0n00F0k20d0Z0d0Z00aef
eI@Ug
.prcsclicnulluiel
gn@Qhi
h4LQj

menI
joOP0printer
in@Lkl
k4GLm

menE
mmJK
ln@Gno
n4DGp

popB
pmEF
o4@Dq

cwin
qmBCfr
rIV[s
.sysodelanullnmbr
smVWtt?
N4'+u

prcs
um)*vvww$System Preferences
Lm#$xxsevsalisMacintosh HDΘ*SH+liSystem Events.appp5-	 CoreServicesΗ5"lilizliy=Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/Jy
yl^^
8m
zzsprfalis~Macintosh HDΘ*SH+liSystem Preferences.apppAF	 ApplicationsΗA=li1Macintosh HD:Applications:System Preferences.app.System Preferences.appMacintosh HD#Applications/System Preferences.app/6{|
{laa|}~
}Iaf
.aevtquitnullnull
mabsprfalis~Macintosh HDΘ*SH+liSystem Preferences.apppAF	 ApplicationsΗA=li1Macintosh HD:Applications:System Preferences.app.System Preferences.appMacintosh HD#Applications/System Preferences.app/~
Igl
.aevtquitnullnull
mghsevsalisMacintosh HDΘ*SH+liSystem Events.appp5-	 CoreServicesΗ5"lilizliy=Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/
lmm
Om
ks
Isx
.miscactvnullnull
lyy
Oy
k}
I}
.prcskprsnullctxt
m}p

faal
J
m
eMdsKcmd
I
.sysodelanullnmbr
m?
l
I
.prcskprsnullctxt
o

ret  print print
I
.sysodelanullnmbr
m@
myzsevsalisMacintosh HDΘ*SH+liSystem Events.appp5-	 CoreServicesΗ5"lilizliy=Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/
l
r
4

cwin
m
o0w
r
n
1

cTab
o0w
o0t
I
.coreclosnullobj
o0t
mmpsfrialisNMacintosh HDΘ*SH+li
Safari.applR_	 ApplicationsΗyli%Macintosh HD:Applications:Safari.app
Safari.appMacintosh HDApplications/Safari.app/
l
l
.aevtoappnull****
.aevtoappnull****0argv0argvzAFxv~}|{zyxwv

cobj0printer
.miscactvnullnull

xppb
kfrmID

xpcp
.sysodelanullnmbr

prcs

cwin

popB
.prcsclicnulluiel

menE

menI
~.aevtquitnullnull
}
faal
|eMdsKcmd
{.prcskprsnullctxt
z
ret y0w
x
cTabw0t
v.coreclosnullobj jk/EOT*jO*0*,FOj	O7*//*k/k/jOj	O*k/k/ak/a/jOj	UUOPUOjOjOaO*jO'aaakvlOj	O_jOaj	UO*k/E`O_a,E`O_jUOPascr
ޭ

Add printer select feature

Add printer select feature