#!/usr/bin/osascript
(*
Copyright 2012 Software Freedom Conservancy. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)

(*
This script can be used to quickly re-install the SafariDriver extension
during development.

Requirements:
- The extension must be manually installed before use
- This script must be run from the trunk.
*)

-- Keep this in sync with the name of the extension in the Info.plist
set EXTENSION to "WebDriver"

tell application "System Events"
	set ui_elements_enabled to UI elements enabled
end tell

if ui_elements_enabled is false then
	tell application "System Preferences"
		activate
		set current pane to pane id "com.apple.preference.universalaccess"
		display dialog "Please \"Enable access for assistive devices\" " & ¬
		    "and try again..."
		error number -128
	end tell
end if

tell application "Safari" to activate

tell application "System Events"
	tell process "Safari"
		tell menu bar 1
			tell menu "Develop"
				click menu item "Show Extension Builder"
				delay 1
			end tell
		end tell

		-- https://discussions.apple.com/thread/2726674?start=0&tstart=0
		tell UI element 1 of scroll area 1 of window "Extension Builder"
			set found_extension to false
			set tc to (count (groups whose its images is not {}))
			repeat with i from 1 to tc
				if exists (static text 1 of group i) then
					set t_name to name of static text 1 of group i
					if t_name is EXTENSION then
						set found_extension to true
						click button "Reload" of UI element ("ReloadUninstall" & t_name)
						exit repeat
					end if
				end if
				keystroke (character id 31)
				delay 0.2
			end repeat

			if found_extension is false then
				display dialog "Was unable to locate the extension \"" & EXTENSION ¬
				    & "\"" & return & return ¬
				    & "It must be manually installed before this script may be used."
				error number -128
			end if
		end tell
	end tell
end tell

tell application "Safari" to quit

#!/usr/bin/osascript
(*
Copyright 2012 Software Freedom Conservancy. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)

(*
This script can be used to quickly re-install the SafariDriver extension
during development.

Requirements:
- The extension must be manually installed before use
- This script must be run from the trunk.
*)

-- Keep this in sync with the name of the extension in the Info.plist
set EXTENSION to "WebDriver"

tell application "System Events"
	set ui_elements_enabled to UI elements enabled
end tell

if ui_elements_enabled is false then
	tell application "System Preferences"
		activate
		set current pane to pane id "com.apple.preference.universalaccess"
		display dialog "Please \"Enable access for assistive devices\" " & ¬
			"and try again..."
		error number -128
	end tell
end if

tell application "Safari" to activate

tell application "System Events"
	tell process "Safari"
		tell menu bar 1
			-- tell menu "Develop"
			tell menu bar item 8
				tell menu 1
					-- click menu item "Show Extension Builder"
					click menu item 7
				end tell
			end tell
		end tell

		delay 0.2

		-- https://discussions.apple.com/thread/2726674?start=0&tstart=0
		-- tell UI element 1 of scroll area 1 of window "Extension Builder"
		tell UI element 1 of scroll area 1 of window 1
			set found_extension to false
			set tc to (count (groups whose its images is not {}))
			repeat with i from 1 to tc
				if exists (static text 1 of group i) then
					set t_name to name of static text 1 of group i
					if t_name is EXTENSION then
						set found_extension to true
						-- click button "Reload" of UI element ("ReloadUninstall" & t_name)
						click button 1 of UI element 4
						exit repeat
					end if
				end if
				keystroke (character id 31)
				delay 0.2
			end repeat

			if found_extension is false then
				display dialog "Was unable to locate the extension \"" & EXTENSION ¬
					& "\"" & return & return ¬
					& "It must be manually installed before this script may be used."
				error number -128
			end if
		end tell
	end tell
end tell

tell application "Safari" to quit

JasonLeyba: Make reinstall.scpt system language independent.

git-svn-id: 4179480af2c2519a5eb5e1e9b541cbdf5cf27696@16964 07704840-8298-11de-bf8c-fd130f914ac9


-- core configuration --

-- configurable options --

-- limit number of songs to improve efficiency
property resultLimit : 25
-- whether or not to retrieve/display album artwork for each result
property albumArtEnabled : true

-- workflow parameters --

property homeFolder : (path to home folder as text)
property libraryFolder : (path to library folder from user domain as text)
property cacheFolder : (libraryFolder & "Caches:")
property alfredWorkflowDataFolder : (cacheFolder & "com.runningwithcrayons.Alfred-3:Workflow Data:")
property bundleId : "com.calebevans.playsong"
property workflowCacheFolder : (alfredWorkflowDataFolder & bundleId & ":") as text
property artworkCacheFolderName : "Album Artwork"
property artworkCachePath : (workflowCacheFolder & artworkCacheFolderName & ":")
property songArtworkNameSep : " | "
property defaultIconName : "icon-noartwork.png"
-- the name of the playlist used by the workflow for playing songs
property workflowPlaylistName : "Alfred Play Song"
-- the text used to determine if a track is an audio file
property songDescriptor : "audio"
-- list of Alfred results
property resultList : {}

-- replaces substring in string with another substring
on replace(replaceThis, replaceWith, theString)

	set oldDelims to AppleScript's text item delimiters
	set AppleScript's text item delimiters to replaceThis
	set strItems to text items of theString
	set AppleScript's text item delimiters to replaceWith
	set newString to strItems as text
	set AppleScript's text item delimiters to oldDelims
	return newString

end replace

-- retrieve the plural/singular form of a quantity based on the given number
on quantifyNumber(theNumber, quantityName, pluralQuantityName)

	if theNumber is 1 then

		set theString to (theNumber as text) & quantityName

	else

		set theString to (theNumber as text) & pluralQuantityName

	end if

	return theString

end quantifyNumber

-- encodes JSON reserved characters in the given string
on encodeFeedbackChars(theString)

	set theString to replace("\\", "\\\\", theString)
	set theString to replace("\"", "\\\"", theString)
	return theString

end encodeFeedbackChars

-- decodes JSON reserved characters in the given string
on decodeFeedbackChars(theString)

	set theString to replace("\\\\", "\\", theString)
	set theString to replace("\\\"", "\"", theString)
	return theString

end decodeFeedbackChars

-- adds Alfred result to result list
on addResult(theResult)

	copy theResult to the end of resultList

end addResult

-- adds item for "No Results" message
on addNoResultsItem(query, queryType)

	addResult({uid:"no-results", valid:"no", title:"No Results Found", subtitle:("No " & queryType & "s matching '" & query & "'"), icon:defaultIconName})

end addNoResultsItem

on resultListIsFull()

	return (length of resultList is resultLimit)

end resultListIsFull

on resultListIsEmpty()

	return (length of resultList is 0)

end resultListIsFull

-- builds Alfred result item as JSON
on getResultFeedback(theResult)

	-- encode reserved JSON characters
	set resultUid to encodeFeedbackChars(uid of theResult)
	set resultValid to (valid of theResult) as text
	set resultTitle to encodeFeedbackChars(title of theResult)
	set resultSubtitle to encodeFeedbackChars(subtitle of theResult)

	if (icon of theResult) contains ":" then

		set resultIcon to encodeFeedbackChars(POSIX path of icon of theResult)

	else

		set resultIcon to icon of theResult

	end if

	set json to "{"
	set json to json & "\"uid\":\"" & resultUid & "\","
	set json to json & "\"arg\":\"" & resultUid & "\","
	set json to json & "\"valid\":\"" & resultValid & "\","
	set json to json & "\"title\":\"" & resultTitle & "\","
	set json to json & "\"subtitle\":\"" & resultSubtitle & "\","
	set json to json & "\"icon\":{\"path\":\"" & resultIcon & "\"}"
	set json to json & "}"
	return json

end getResultFeedback

-- retrieves JSON document for Alfred results
on getResultListFeedback()

	set json to "{\"items\": ["

	repeat with theResult in resultList

		set json to json & getResultFeedback(theResult)
		set json to json & ","

	end repeat

	-- remove trailing comma after last item
	set json to text 1 thru (length of json - 1) of json
	set json to json & "]}"
	return json

end getResultListFeedback

-- writes the given content to the given file
on fileWrite(theFile, theContent)

	set fileRef to open for access theFile with write permission
	try
		set eof of fileRef to 0
		write theContent to fileRef starting at eof
		close access fileRef
	on error
		close access fileRef
	end try

end fileWrite

-- builds path to album art for the given song
on getSongArtworkPath(theSong)

	if albumArtEnabled is false then return defaultIconName

	tell application "iTunes"

		set songArtist to artist of theSong
		set songAlbum to album of theSong
		-- generate a unique identifier for that album
		set songArtworkName to (songArtist & songArtworkNameSep & songAlbum) as text
		-- remove forbidden path characters
		set songArtworkName to replace(":", "", songArtworkName) of me
		set songArtworkName to replace("/", "", songArtworkName) of me
		set songArtworkName to replace(".", "", songArtworkName) of me
		set songArtworkPath to (artworkCachePath & songArtworkName & ".jpg")

	end tell

	tell application "Finder"

		-- cache artwork if it's not already cached
		if not (songArtworkPath exists) then

			tell application "iTunes"

				set songArtworks to artworks of theSong
				-- only save artwork if artwork exists for this song
				if (length of songArtworks) is 0 then

					-- use default iTunes icon if song has no artwork
					set songArtworkPath to defaultIconName

				else

					-- save artwork to file
					set songArtwork to data of (item 1 of songArtworks)
					fileWrite(songArtworkPath, songArtwork) of me

				end if

			end tell

		end if

	end tell

	return songArtworkPath

end getSongArtworkPath

-- creates album artwork cache
on createWorkflowPlaylist()

	tell application "iTunes"

		if not (user playlist workflowPlaylistName exists) then

			make new user playlist with properties {name:workflowPlaylistName, shuffle:false}

		end if

	end tell

end createWorkflowPlaylist

on clearQueue()

	tell application "iTunes"

		if user playlist workflowPlaylistName exists then

			delete tracks of user playlist workflowPlaylistName

		end if

	end tell

end clearQueue

on queueSongs(theSongs)

	tell application "iTunes"

		repeat with theSong in theSongs

			duplicate theSong to user playlist workflowPlaylistName

		end repeat

	end tell

end queueSongs

on playQueue()

	tell application "iTunes"

		if number of tracks in user playlist workflowPlaylistName is not 0 then

			play user playlist workflowPlaylistName

		end if

	end tell

end playQueue

-- brings queue into view in iTunes window
on focusQueue()

	tell application "iTunes"

		reveal user playlist workflowPlaylistName

	end tell

end focusQueue

on getPlaylistSongs(playlistId)

	tell application "iTunes"

		set thePlaylist to first user playlist whose id is playlistId
		set theSongs to every track of thePlaylist

	end tell

	return theSongs

end getPlaylistSongs

-- retrieves list of artist names for the given genre
on getGenreArtists(genreName)

	tell application "iTunes"

		set theSongs to every track of playlist 2 whose genre is genreName and kind contains songDescriptor
		set artistNames to {}

		repeat with theSong in theSongs

			if (artist of theSong) is not in artistNames then

				set artistNames to artistNames & (artist of theSong)

			end if

		end repeat

	end tell

	return artistNames

end getGenreArtists

-- retrieves list of songs within the given genre, sorted by artist
on getGenreSongs(genreName)

	set artistNames to getGenreArtists(genreName) of me
	set theSongs to {}

	repeat with artistName in artistNames

		set theSongs to theSongs & getArtistSongs(artistName) of me

	end repeat

	return theSongs

end getGenreSongs

-- retrieves list of album names for the given artist
on getArtistAlbums(artistName)

	tell application "iTunes"

		set theSongs to every track of playlist 2 whose artist is artistName and kind contains songDescriptor
		set albumNames to {}

		repeat with theSong in theSongs

			if (album of theSong) is not in albumNames then

				set albumNames to albumNames & (album of theSong)

			end if

		end repeat

	end tell

	return albumNames

end getArtistAlbums

-- retrieves list of songs by the given artist, sorted by album
on getArtistSongs(artistName)

	tell application "iTunes"

		set albumNames to getArtistAlbums(artistName) of me
		set theSongs to {}

		repeat with albumName in albumNames

			set albumSongs to (every track of playlist 2 whose artist is artistName and album is albumName and kind contains songDescriptor)
			set albumSongs to sortSongsByAlbumOrder(albumSongs) of me
			set theSongs to theSongs & albumSongs

		end repeat

	end tell

	return theSongs

end getArtistSongs

-- retrieves list of songs in the given album
on getAlbumSongs(albumName)

	tell application "iTunes"

		set theSongs to every track of playlist 2 whose album is albumName and kind contains songDescriptor
		set theSongs to sortSongsByAlbumOrder(theSongs) of me

	end tell

	return theSongs

end getAlbumSongs

-- sorts songs from the same album by track number
on sortSongsByAlbumOrder(theSongs)

	tell application "iTunes"

		set theSongsSorted to theSongs

		if length of theSongs is greater than 1 then

			set trackCount to track count of (item 1 of theSongs)
			set discCount to disc count of (item 1 of theSongs)

			if trackCount is not 0 and discCount is not 0 then

				set theSongsSorted to {} as list

				repeat with discIndex from 1 to discCount

					repeat with songIndex from 1 to trackCount

						repeat with theSong in theSongs

							if disc number of theSong is discIndex and track number of theSong is songIndex then

								set nextSong to theSong
								copy nextSong to the end of theSongsSorted

							end if

						end repeat

					end repeat

				end repeat

			end if

		end if

	end tell

	return theSongsSorted

end sortSongsByAlbumOrder

-- retrieves the song with the given ID
on getSong(songId)

	tell application "iTunes"

		set theSong to first track of playlist 2 whose database ID is songId and kind contains songDescriptor

	end tell

	return theSong

end getSong

-- retrieves a list of objects or names matching the given query and type
on getResultsFromQuery(query, queryType)

	set evalScript to run script "
	script

		on findResults(query, queryType, resultLimit, songDescriptor)

			tell application \"iTunes\"

				set theSongs to (get every track in playlist 2 whose " & queryType & " starts with query and kind contains songDescriptor)

				if length of theSongs < resultLimit then

					set theSongs to theSongs & (get every track in playlist 2 whose " & queryType & " contains (space & query) and " & queryType & " does not start with query and kind contains songDescriptor)

				end if

				if length of theSongs < resultLimit then

					set theSongs to theSongs & (get every track in playlist 2 whose " & queryType & " contains query and " & queryType & " does not start with query and " & queryType & " does not contain (space & query) and kind contains songDescriptor)

				end if

				if queryType is \"name\" then

					if length of theSongs > resultLimit then

						set theSongs to items 1 thru resultLimit of theSongs

					end if

					set theResults to theSongs

				else

					set theResults to {}

					repeat with theSong in theSongs

						if length of theResults is resultLimit then exit repeat

						set theResult to " & queryType & " of theSong

						if theResult is not in theResults then

							set theResults to theResults & theResult

						end if

					end repeat

				end if

			end tell

			return theResults

		end findResults

	end script
	"

	evalScript's findResults(query, queryType, resultLimit, songDescriptor)

end getResultsFromQuery

-- returns the given string with leading and trailing whitespace removed
on trimWhitespace(theString)

	-- trim leading whitespace
	repeat while theString begins with space

		if length of theString is 1 then return ""
		set theString to text 2 thru end of theString

	end repeat

	-- trim trailing whitespace
	repeat while theString ends with space

		set theString to text 1 thru ((length of theString) - 1) of theString

	end repeat

	return theString

end trimWhitespace

-- queues the song with the given ID
on queueSong(songId)

	set theSong to getSong(songId)
	queueSongs({theSong})

end queueSong

-- queues all songs belonging to the given album
on queueAlbum(albumName)

	set albumName to decodeFeedbackChars(albumName)
	set theSongs to getAlbumSongs(albumName)
	queueSongs(theSongs)

end queueAlbum

-- queues all songs by the given artist
on queueArtist(artistName)

	set artistName to decodeFeedbackChars(artistName)
	set theSongs to getArtistSongs(artistName)
	queueSongs(theSongs)

end queueArtist

-- queues all songs within the given genre
on queueGenre(genreName)

	set genreName to decodeFeedbackChars(genreName)
	set theSongs to getGenreSongs(genreName)
	queueSongs(theSongs)

end queueGenre

-- queues all songs in the given playlist
on queuePlaylist(playlistId)

	set theSongs to getPlaylistSongs(playlistId)
	queueSongs(theSongs)

end queuePlaylist

-- parses the given result query to retrieve type and id of item to queue
on parseResultQuery(query)

	set pos to offset of "-" in query
	set theType to text 1 thru (pos - 1) of query
	set theId to text (pos + 1) thru end of query
	return {type:theType, id:theId}

end parseResultQuery

on queue(query)

	set typeAndId to parseResultQuery(query)
	set theType to type of typeAndId
	set theId to id of typeAndId

	createWorkflowPlaylist()

	if theType is "song" then
		queueSong(theId)
	else if theType is "album" then
		queueAlbum(theId)
	else if theType is "artist" then
		queueArtist(theId)
	else if theType is "genre" then
		queueGenre(theId)
	else if theType is "playlist" then
		queuePlaylist(theId)
	else
		log "Unknown type: " & theType
	end if

	focusQueue()

end queue

on play(query)

	clearQueue()
	queue(query)
	focusQueue()
	playQueue()

end play

-- core configuration --

-- configurable options --

-- limit number of songs to improve efficiency
property resultLimit : 25
-- whether or not to retrieve/display album artwork for each result
property albumArtEnabled : true

-- workflow parameters --

property homeFolder : (path to home folder as text)
property libraryFolder : (path to library folder from user domain as text)
property cacheFolder : (libraryFolder & "Caches:")
property alfredWorkflowDataFolder : (cacheFolder & "com.runningwithcrayons.Alfred-3:Workflow Data:")
property bundleId : "com.calebevans.playsong"
property workflowCacheFolder : (alfredWorkflowDataFolder & bundleId & ":") as text
property artworkCacheFolderName : "Album Artwork"
property artworkCachePath : (workflowCacheFolder & artworkCacheFolderName & ":")
property songArtworkNameSep : " | "
property defaultIconName : "icon-noartwork.png"
-- the name of the playlist used by the workflow for playing songs
property workflowPlaylistName : "Alfred Play Song"
-- the text used to determine if a track is an audio file
property songDescriptor : "audio"
-- list of Alfred results
property resultList : {}

-- replaces substring in string with another substring
on replace(replaceThis, replaceWith, theString)

	set oldDelims to AppleScript's text item delimiters
	set AppleScript's text item delimiters to replaceThis
	set strItems to text items of theString
	set AppleScript's text item delimiters to replaceWith
	set newString to strItems as text
	set AppleScript's text item delimiters to oldDelims
	return newString

end replace

-- retrieve the plural/singular form of a quantity based on the given number
on quantifyNumber(theNumber, quantityName, pluralQuantityName)

	if theNumber is 1 then

		set theString to (theNumber as text) & space & quantityName

	else

		set theString to (theNumber as text) & space & pluralQuantityName

	end if

	return theString

end quantifyNumber

-- encodes JSON reserved characters in the given string
on encodeFeedbackChars(theString)

	set theString to replace("\\", "\\\\", theString)
	set theString to replace("\"", "\\\"", theString)
	return theString

end encodeFeedbackChars

-- decodes JSON reserved characters in the given string
on decodeFeedbackChars(theString)

	set theString to replace("\\\\", "\\", theString)
	set theString to replace("\\\"", "\"", theString)
	return theString

end decodeFeedbackChars

-- adds Alfred result to result list
on addResult(theResult)

	copy theResult to the end of resultList

end addResult

-- adds item for "No Results" message
on addNoResultsItem(query, queryType)

	addResult({uid:"no-results", valid:"no", title:"No Results Found", subtitle:("No " & queryType & "s matching '" & query & "'"), icon:defaultIconName})

end addNoResultsItem

on resultListIsFull()

	return (length of resultList is resultLimit)

end resultListIsFull

on resultListIsEmpty()

	return (length of resultList is 0)

end resultListIsFull

-- builds Alfred result item as JSON
on getResultFeedback(theResult)

	-- encode reserved JSON characters
	set resultUid to encodeFeedbackChars(uid of theResult)
	set resultValid to (valid of theResult) as text
	set resultTitle to encodeFeedbackChars(title of theResult)
	set resultSubtitle to encodeFeedbackChars(subtitle of theResult)

	if (icon of theResult) contains ":" then

		set resultIcon to encodeFeedbackChars(POSIX path of icon of theResult)

	else

		set resultIcon to icon of theResult

	end if

	set json to "{"
	set json to json & "\"uid\":\"" & resultUid & "\","
	set json to json & "\"arg\":\"" & resultUid & "\","
	set json to json & "\"valid\":\"" & resultValid & "\","
	set json to json & "\"title\":\"" & resultTitle & "\","
	set json to json & "\"subtitle\":\"" & resultSubtitle & "\","
	set json to json & "\"icon\":{\"path\":\"" & resultIcon & "\"}"
	set json to json & "}"
	return json

end getResultFeedback

-- retrieves JSON document for Alfred results
on getResultListFeedback()

	set json to "{\"items\": ["

	repeat with theResult in resultList

		set json to json & getResultFeedback(theResult)
		set json to json & ","

	end repeat

	-- remove trailing comma after last item
	set json to text 1 thru (length of json - 1) of json
	set json to json & "]}"
	return json

end getResultListFeedback

-- writes the given content to the given file
on fileWrite(theFile, theContent)

	set fileRef to open for access theFile with write permission
	try
		set eof of fileRef to 0
		write theContent to fileRef starting at eof
		close access fileRef
	on error
		close access fileRef
	end try

end fileWrite

-- builds path to album art for the given song
on getSongArtworkPath(theSong)

	if albumArtEnabled is false then return defaultIconName

	tell application "iTunes"

		set songArtist to artist of theSong
		set songAlbum to album of theSong
		-- generate a unique identifier for that album
		set songArtworkName to (songArtist & songArtworkNameSep & songAlbum) as text
		-- remove forbidden path characters
		set songArtworkName to replace(":", "", songArtworkName) of me
		set songArtworkName to replace("/", "", songArtworkName) of me
		set songArtworkName to replace(".", "", songArtworkName) of me
		set songArtworkPath to (artworkCachePath & songArtworkName & ".jpg")

	end tell

	tell application "Finder"

		-- cache artwork if it's not already cached
		if not (songArtworkPath exists) then

			tell application "iTunes"

				set songArtworks to artworks of theSong
				-- only save artwork if artwork exists for this song
				if (length of songArtworks) is 0 then

					-- use default iTunes icon if song has no artwork
					set songArtworkPath to defaultIconName

				else

					-- save artwork to file
					set songArtwork to data of (item 1 of songArtworks)
					fileWrite(songArtworkPath, songArtwork) of me

				end if

			end tell

		end if

	end tell

	return songArtworkPath

end getSongArtworkPath

-- creates album artwork cache
on createWorkflowPlaylist()

	tell application "iTunes"

		if not (user playlist workflowPlaylistName exists) then

			make new user playlist with properties {name:workflowPlaylistName, shuffle:false}

		end if

	end tell

end createWorkflowPlaylist

on clearQueue()

	tell application "iTunes"

		if user playlist workflowPlaylistName exists then

			delete tracks of user playlist workflowPlaylistName

		end if

	end tell

end clearQueue

on queueSongs(theSongs)

	tell application "iTunes"

		repeat with theSong in theSongs

			duplicate theSong to user playlist workflowPlaylistName

		end repeat

	end tell

end queueSongs

on playQueue()

	tell application "iTunes"

		if number of tracks in user playlist workflowPlaylistName is not 0 then

			play user playlist workflowPlaylistName

		end if

	end tell

end playQueue

-- brings queue into view in iTunes window
on focusQueue()

	tell application "iTunes"

		reveal user playlist workflowPlaylistName

	end tell

end focusQueue

on getPlaylistSongs(playlistId)

	tell application "iTunes"

		set thePlaylist to first user playlist whose id is playlistId
		set theSongs to every track of thePlaylist

	end tell

	return theSongs

end getPlaylistSongs

-- retrieves list of artist names for the given genre
on getGenreArtists(genreName)

	tell application "iTunes"

		set theSongs to every track of playlist 2 whose genre is genreName and kind contains songDescriptor
		set artistNames to {}

		repeat with theSong in theSongs

			if (artist of theSong) is not in artistNames then

				set artistNames to artistNames & (artist of theSong)

			end if

		end repeat

	end tell

	return artistNames

end getGenreArtists

-- retrieves list of songs within the given genre, sorted by artist
on getGenreSongs(genreName)

	set artistNames to getGenreArtists(genreName) of me
	set theSongs to {}

	repeat with artistName in artistNames

		set theSongs to theSongs & getArtistSongs(artistName) of me

	end repeat

	return theSongs

end getGenreSongs

-- retrieves list of album names for the given artist
on getArtistAlbums(artistName)

	tell application "iTunes"

		set theSongs to every track of playlist 2 whose artist is artistName and kind contains songDescriptor
		set albumNames to {}

		repeat with theSong in theSongs

			if (album of theSong) is not in albumNames then

				set albumNames to albumNames & (album of theSong)

			end if

		end repeat

	end tell

	return albumNames

end getArtistAlbums

-- retrieves list of songs by the given artist, sorted by album
on getArtistSongs(artistName)

	tell application "iTunes"

		set albumNames to getArtistAlbums(artistName) of me
		set theSongs to {}

		repeat with albumName in albumNames

			set albumSongs to (every track of playlist 2 whose artist is artistName and album is albumName and kind contains songDescriptor)
			set albumSongs to sortSongsByAlbumOrder(albumSongs) of me
			set theSongs to theSongs & albumSongs

		end repeat

	end tell

	return theSongs

end getArtistSongs

-- retrieves list of songs in the given album
on getAlbumSongs(albumName)

	tell application "iTunes"

		set theSongs to every track of playlist 2 whose album is albumName and kind contains songDescriptor
		set theSongs to sortSongsByAlbumOrder(theSongs) of me

	end tell

	return theSongs

end getAlbumSongs

-- sorts songs from the same album by track number
on sortSongsByAlbumOrder(theSongs)

	tell application "iTunes"

		set theSongsSorted to theSongs

		if length of theSongs is greater than 1 then

			set trackCount to track count of (item 1 of theSongs)
			set discCount to disc count of (item 1 of theSongs)

			if trackCount is not 0 and discCount is not 0 then

				set theSongsSorted to {} as list

				repeat with discIndex from 1 to discCount

					repeat with songIndex from 1 to trackCount

						repeat with theSong in theSongs

							if disc number of theSong is discIndex and track number of theSong is songIndex then

								set nextSong to theSong
								copy nextSong to the end of theSongsSorted

							end if

						end repeat

					end repeat

				end repeat

			end if

		end if

	end tell

	return theSongsSorted

end sortSongsByAlbumOrder

-- retrieves the song with the given ID
on getSong(songId)

	tell application "iTunes"

		set theSong to first track of playlist 2 whose database ID is songId and kind contains songDescriptor

	end tell

	return theSong

end getSong

-- retrieves a list of objects or names matching the given query and type
on getResultsFromQuery(query, queryType)

	set evalScript to run script "
	script

		on findResults(query, queryType, resultLimit, songDescriptor)

			tell application \"iTunes\"

				set theSongs to (get every track in playlist 2 whose " & queryType & " starts with query and kind contains songDescriptor)

				if length of theSongs < resultLimit then

					set theSongs to theSongs & (get every track in playlist 2 whose " & queryType & " contains (space & query) and " & queryType & " does not start with query and kind contains songDescriptor)

				end if

				if length of theSongs < resultLimit then

					set theSongs to theSongs & (get every track in playlist 2 whose " & queryType & " contains query and " & queryType & " does not start with query and " & queryType & " does not contain (space & query) and kind contains songDescriptor)

				end if

				if queryType is \"name\" then

					if length of theSongs > resultLimit then

						set theSongs to items 1 thru resultLimit of theSongs

					end if

					set theResults to theSongs

				else

					set theResults to {}

					repeat with theSong in theSongs

						if length of theResults is resultLimit then exit repeat

						set theResult to " & queryType & " of theSong

						if theResult is not in theResults then

							set theResults to theResults & theResult

						end if

					end repeat

				end if

			end tell

			return theResults

		end findResults

	end script
	"

	evalScript's findResults(query, queryType, resultLimit, songDescriptor)

end getResultsFromQuery

-- returns the given string with leading and trailing whitespace removed
on trimWhitespace(theString)

	-- trim leading whitespace
	repeat while theString begins with space

		if length of theString is 1 then return ""
		set theString to text 2 thru end of theString

	end repeat

	-- trim trailing whitespace
	repeat while theString ends with space

		set theString to text 1 thru ((length of theString) - 1) of theString

	end repeat

	return theString

end trimWhitespace

-- queues the song with the given ID
on queueSong(songId)

	set theSong to getSong(songId)
	queueSongs({theSong})

end queueSong

-- queues all songs belonging to the given album
on queueAlbum(albumName)

	set albumName to decodeFeedbackChars(albumName)
	set theSongs to getAlbumSongs(albumName)
	queueSongs(theSongs)

end queueAlbum

-- queues all songs by the given artist
on queueArtist(artistName)

	set artistName to decodeFeedbackChars(artistName)
	set theSongs to getArtistSongs(artistName)
	queueSongs(theSongs)

end queueArtist

-- queues all songs within the given genre
on queueGenre(genreName)

	set genreName to decodeFeedbackChars(genreName)
	set theSongs to getGenreSongs(genreName)
	queueSongs(theSongs)

end queueGenre

-- queues all songs in the given playlist
on queuePlaylist(playlistId)

	set theSongs to getPlaylistSongs(playlistId)
	queueSongs(theSongs)

end queuePlaylist

-- parses the given result query to retrieve type and id of item to queue
on parseResultQuery(query)

	set pos to offset of "-" in query
	set theType to text 1 thru (pos - 1) of query
	set theId to text (pos + 1) thru end of query
	return {type:theType, id:theId}

end parseResultQuery

on queue(query)

	set typeAndId to parseResultQuery(query)
	set theType to type of typeAndId
	set theId to id of typeAndId

	createWorkflowPlaylist()

	if theType is "song" then
		queueSong(theId)
	else if theType is "album" then
		queueAlbum(theId)
	else if theType is "artist" then
		queueArtist(theId)
	else if theType is "genre" then
		queueGenre(theId)
	else if theType is "playlist" then
		queuePlaylist(theId)
	else
		log "Unknown type: " & theType
	end if

	focusQueue()

end queue

on play(query)

	clearQueue()
	queue(query)
	focusQueue()
	playQueue()

end play

Add space between quantity number and quantity name


tell application "Terminal"
  activate
  set currentTab to do script ("vba-blocks help")
end tell

tell application "Terminal"
	activate
	do script ("vba-blocks help")
end tell

Tweak run applescript

Tweak run applescript


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()

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
reply's setkv("time", (do shell script "date -u +%s"))
return reply's toJson()

Add UTC unix epoch as "time" as string

Add UTC unix epoch as "time" as string

otherwise it converts to a real since AppleScript's integer
is seemingly narrow...


FasdUAS 1.101.10
lR
OR
kQ
I
.miscactvnullnull

l

} TODO: test if ~/.boot2docker/boot2docker.iso exists, and if not, copy it from the install (need to ship it in the installer)
 TODO: test if ~/.boot2docker/boot2docker.iso exists, and if not, copy it from the install (need to ship it in the installer)
r

I

.coredoscnullctxt
o0	newwindow	newWindow
r
m&Boot2Docker for OSX
o0windowtitlewindowTitle
r
m
boovtrue
n
1

tdct
o0	newwindow	newWindow
r!!"
!o0windowtitlewindowTitle
"n#$
#1

titl
$o0	newwindow	newWindow %&
%r"%'(
'm"#))**4/usr/local/bin/boot2docker
(o0b2d&+,
+I&--.
.coredoscnullctxt
-m&'//00.mkdir -p ~/.boot2docker.1

kfil
1o()0	newwindow	newWindow,23
2I.545
.coredoscnullctxt
4m./6677if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi58

kfil
8o010	newwindow	newWindow39:
9I6?;<
.coredoscnullctxt
;b69=>
=o670b2d
>m78??@@ init <A

kfil
Ao:;0	newwindow	newWindow:BC
BI@IDE
.coredoscnullctxt
Db@CFG
Fo@A0b2d
GmABHHII up && export DOCKER_HOST=tcp://$(/usr/local/bin/boot2docker ip 2>/dev/null):2375EJ

kfil
JoDE0	newwindow	newWindowCK
KIJQLM
.coredoscnullctxt
LmJKNNOOdocker versionMP

kfil
PoLM0	newwindow	newWindow
mQQ@alisZOSX-OSxH+PTerminal.app(>e	 	Utilitiesy`?APO,OSX-OS:Applications:Utilities:Terminal.appTerminal.appOSX-OS#Applications/Utilities/Terminal.app/RSR
.aevtoappnull****STUV
.aevtoappnull****
TkRWWUVQ)/6?HN
.miscactvnullnull
.coredoscnullctxt0	newwindow	newWindow0windowtitlewindowTitle

tdct

titl0b2d

kfilSO*jO*jEOEOe,FO,FOEOlOlO%lO%lOlUascrޭ

FasdUAS 1.101.10
l\
O\
k[
I
.miscactvnullnull

l

} TODO: test if ~/.boot2docker/boot2docker.iso exists, and if not, copy it from the install (need to ship it in the installer)
 TODO: test if ~/.boot2docker/boot2docker.iso exists, and if not, copy it from the install (need to ship it in the installer)
r

I

.coredoscnullctxt
o0	newwindow	newWindow
r
m&Boot2Docker for OSX
o0windowtitlewindowTitle
r
m
boovtrue
n
1

tdct
o0	newwindow	newWindow
r!!"
!o0windowtitlewindowTitle
"n#$
#1

titl
$o0	newwindow	newWindow %&
%r"%'(
'm"#))**4/usr/local/bin/boot2docker
(o0b2d&+,
+I&--.
.coredoscnullctxt
-m&'//00bash.1

kfil
1o()0	newwindow	newWindow,23
2I.545
.coredoscnullctxt
4m./6677.mkdir -p ~/.boot2docker58

kfil
8o010	newwindow	newWindow39:
9I6=;<
.coredoscnullctxt
;m67==>>if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi<?

kfil
?o890	newwindow	newWindow:@A
@I>GBC
.coredoscnullctxt
Bb>ADE
Do>?0b2d
Em?@FFGG init CH

kfil
HoBC0	newwindow	newWindowAIJ
IIHQKL
.coredoscnullctxt
KbHKMN
MoHI0b2d
NmIJOOPP up && export DOCKER_HOST=tcp://$(/usr/local/bin/boot2docker ip 2>/dev/null):2375LQ

kfil
QoLM0	newwindow	newWindowJR
RIR[ST
.coredoscnullctxt
SmRUUUVVdocker versionTW

kfil
WoVW0	newwindow	newWindow
mXX@alislMacintosh HDH++Terminal.app_?O	 	Utilities?A+*2Macintosh HD:Applications:Utilities:Terminal.appTerminal.appMacintosh HD#Applications/Utilities/Terminal.app/YZY
.aevtoappnull****Z[\]
.aevtoappnull****
[k\^^\]X)/6=FOU
.miscactvnullnull
.coredoscnullctxt0	newwindow	newWindow0windowtitlewindowTitle

tdct

titl0b2d

kfil]Y*jO*jEOEOe,FO,FOEOlOlOlO%lO%lOalUascrޭ

fix for issue #28, switch to bash before executing script


tell application "Xcode"
	if not (exists active project document) then
		error "No active project. Please open an Xcode project and re-run the script."
	try
		my updateProjectXmod(project of active project document)
	on error errMsg
		my logger("Xmod.scpt exception: " & errMsg)
	end try
end tell

on updateProjectXmod(_project)
	tell application "Xcode"
		-- Iterate over every .xcdatamodel in the project.
		set modelList to every file reference of _project whose file kind is "wrapper.xcdatamodel"
		repeat with modelIt in modelList
			if comments of modelIt contains "xmod" then
				set modelSrcDir to my modelSrcDirPath(full path of modelIt)
				set targetList to my everyTargetWithBuildFilePath(_project, full path of modelIt)

				-- Create the .xcdatamodel related source group if necessary.
				if not (exists (every item reference of group of modelIt whose full path is modelSrcDir)) then
					tell group of modelIt
						make new group with properties {full path:modelSrcDir, name:text 1 thru -13 of ((name of modelIt) as string)}
					end tell
				end if
				set modelSrcGroup to item 1 of (every item reference of group of modelIt whose full path is modelSrcDir)
				tell modelSrcGroup to delete every item reference -- clear it out for population in case we didn't just create it

				--	Meat.
				do shell script "/usr/bin/mogenerator --model '" & full path of modelIt & "' --output-dir '" & modelSrcDir & "'"

				--	Build a list of resulting source files.
				tell application "System Events"
					set modelSrcDirAlias to POSIX file modelSrcDir as alias
					set humanHeaderFileList to (every file of modelSrcDirAlias whose name ends with ".h" and name does not start with "_")
					set humanSourceFileList to (every file of modelSrcDirAlias whose (name ends with ".m" or name ends with ".mm") and name does not start with "_")
					set machineHeaderFileList to (every file of modelSrcDirAlias whose name ends with ".h" and name starts with "_")
					set machineSourceFileList to (every file of modelSrcDirAlias whose (name ends with ".m" or name ends with ".mm") and name starts with "_")
					set fileList to humanHeaderFileList & humanSourceFileList & machineHeaderFileList & machineSourceFileList
					set pathList to {}
					repeat with fileItem in fileList
						set pathList to pathList & POSIX path of fileItem
					end repeat
				end tell

				--	Add the source files to the model's source group and the model's targets.
				repeat with pathIt in pathList
					tell modelSrcGroup
						set modelSrcFileRef to make new file reference with properties {full path:pathIt, name:name of (info for POSIX file pathIt)}
						repeat with targetIndex from 1 to (count of targetList)
							set targetIt to item targetIndex of targetList
							add modelSrcFileRef to targetIt
						end repeat
					end tell
				end repeat
			end if
		end repeat
	end tell
end updateProjectXmod

on everyTargetWithBuildFilePath(_project, _buildFilePath)
	set theResult to {}
	tell application "Xcode"
		repeat with targetIt in (every target of _project)
			repeat with buildFileIt in build files of targetIt
				if full path of file reference of buildFileIt is _buildFilePath then set theResult to theResult & {(targetIt as anything)}
			end repeat
		end repeat
	end tell
	return theResult
end everyTargetWithBuildFilePath

on modelSrcDirPath(modelFileUnixPath)
	set modelFilePosixRef to POSIX file modelFileUnixPath
	set modelFileAlias to modelFilePosixRef as alias

	tell application "Finder"
		set modelFileFolder to folder of modelFileAlias
		set modelFileName to name of modelFileAlias
		set modelSrcFolderName to text 1 thru -13 of modelFileName -- pull off the .xcdatamodel extension
		if not (exists folder modelSrcFolderName of modelFileFolder) then
			make folder at modelFileFolder with properties {name:modelSrcFolderName}
		end if
		set modelSrcFolder to folder modelSrcFolderName of modelFileFolder
	end tell
	return text 1 thru -2 of (POSIX path of (modelSrcFolder as alias)) -- kill the trailing slash
end modelSrcDirPath

on logger(msg)
	do shell script "logger '" & msg & "'"
end logger

tell application "Xcode"
	if not (exists active project document) then
		error "No active project. Please open an Xcode project and re-run the script."
	try
		my updateProjectXmod(project of active project document)
	on error errMsg
		my logger("Xmod.scpt exception: " & errMsg)
	end try
end tell

on updateProjectXmod(_project)
	tell application "Xcode"
		-- Iterate over every .xcdatamodel in the project.
		set modelList to every file reference of _project whose file kind is "wrapper.xcdatamodel"
		repeat with modelIt in modelList
			if comments of modelIt contains "xmod" then
				set modelSrcDir to my modelSrcDirPath(full path of modelIt)
				set targetList to my everyTargetWithBuildFilePath(_project, full path of modelIt)

				-- Create the .xcdatamodel related source group if necessary.
				if not (exists (every item reference of group of modelIt whose full path is modelSrcDir)) then
					tell group of modelIt
						make new group with properties {full path:modelSrcDir, name:text 1 thru -13 of ((name of modelIt) as string)}
					end tell
				end if
				set modelSrcGroup to item 1 of (every item reference of group of modelIt whose full path is modelSrcDir)
				tell modelSrcGroup to delete every item reference -- clear it out for population in case we didn't just create it

				--	Meat.
				do shell script "/usr/bin/mogenerator --model '" & full path of modelIt & "' --output-dir '" & modelSrcDir & "'"

				--	Build a list of resulting source files.
				tell application "System Events"
					set modelSrcDirAlias to POSIX file modelSrcDir as alias
					set humanHeaderFileList to (every file of modelSrcDirAlias whose name ends with ".h" and name does not start with "_")
					set humanSourceFileList to (every file of modelSrcDirAlias whose (name ends with ".m" or name ends with ".mm") and name does not start with "_")
					set machineHeaderFileList to (every file of modelSrcDirAlias whose name ends with ".h" and name starts with "_")
					set machineSourceFileList to (every file of modelSrcDirAlias whose (name ends with ".m" or name ends with ".mm") and name starts with "_")
					set fileList to humanSourceFileList & humanHeaderFileList & machineSourceFileList & machineHeaderFileList
					set pathList to {}
					repeat with fileItem in fileList
						set pathList to pathList & POSIX path of fileItem
					end repeat
				end tell

				--	Add the source files to the model's source group and the model's targets.
				repeat with pathIt in pathList
					tell modelSrcGroup
						set modelSrcFileRef to make new file reference with properties {full path:pathIt, name:name of (info for POSIX file pathIt)}
						repeat with targetIndex from 1 to (count of targetList)
							set targetIt to item targetIndex of targetList
							add modelSrcFileRef to targetIt
						end repeat
					end tell
				end repeat
			end if
		end repeat
	end tell
end updateProjectXmod

on everyTargetWithBuildFilePath(_project, _buildFilePath)
	set theResult to {}
	tell application "Xcode"
		repeat with targetIt in (every target of _project)
			repeat with buildFileIt in build files of targetIt
				if full path of file reference of buildFileIt is _buildFilePath then set theResult to theResult & {(targetIt as anything)}
			end repeat
		end repeat
	end tell
	return theResult
end everyTargetWithBuildFilePath

on modelSrcDirPath(modelFileUnixPath)
	set modelFilePosixRef to POSIX file modelFileUnixPath
	set modelFileAlias to modelFilePosixRef as alias

	tell application "Finder"
		set modelFileFolder to folder of modelFileAlias
		set modelFileName to name of modelFileAlias
		set modelSrcFolderName to text 1 thru -13 of modelFileName -- pull off the .xcdatamodel extension
		if not (exists folder modelSrcFolderName of modelFileFolder) then
			make folder at modelFileFolder with properties {name:modelSrcFolderName}
		end if
		set modelSrcFolder to folder modelSrcFolderName of modelFileFolder
	end tell
	return text 1 thru -2 of (POSIX path of (modelSrcFolder as alias)) -- kill the trailing slash
end modelSrcDirPath

on logger(msg)
	do shell script "logger '" & msg & "'"
end logger

[CHANGE] Xmo'd: change file ordering to human.m, human.h, machine.m, machine.h (from human.h, human.m, machine.h, machine.m).


-- http://www-01.ibm.com/support/docview.wss?uid=swg21506026
-- https://github.com/jgstew/tools/blob/master/bash/openQnA.sh
-- http://alvinalexander.com/blog/post/mac-os-x/applescript-use-comments
tell application "Terminal"
	if not (exists window 1) then reopen
	activate
	do script "/Library/BESAgent/BESAgent.app/Contents/MacOS/QnA -showtypes" in window 1
end tell

Update openQnA.scpt

Update openQnA.scpt


tell application "System Events" to tell process "iOS Simulator"
	activate
	set frontmost to true
	click menu item "Reset Content and Settings" of menu 0 of menu bar item "iOS Simulator" of menu bar 1
  delay 0.1
  tell application "System Events" to key code 36
	-- click button "Reset" of window ""
  return
end tell

tell application "System Events" to tell process "Simulator"
	activate
	set frontmost to true
	click menu item "Reset Content and Settings" of menu 0 of menu bar item "Simulator" of menu bar 1
  delay 0.1
  tell application "System Events" to key code 36
	-- click button "Reset" of window ""
  return
end tell

Fix simulator script

Fix simulator script


on alfred_script(q)

    tell application "Google Chrome"

        if q is "" or q is "p" or q is "pp" or q is "play" or q is "pause" then
            set buttonClass to "play"
            set execCode to "$('." & buttonClass & "').first().click()"
        else if q is "next" or q is "skip" or q is "n" then
            set buttonClass to "next"
            set execCode to "$('." & buttonClass & "').first().click()"
        else
            set argList to every text item of q
            if item 1 of argList is "genre" then
                set execCode to "$('li.genre a')[" & item 2 of argList & "].click();"
            end if
        end if

        set seenPlayerTab to 0

        set thisWindowIndex to 1
        repeat with thisWindow in windows

            set thisTabIndex to 1
            repeat with thisTab in tabs of thisWindow

                if URL of thisTab starts with "https://www.focusatwill.com/" then
                    set seenPlayerTab to 1
                    exit repeat
                end if

                set thisTabIndex to thisTabIndex + 1

            end repeat

            if seenPlayerTab is greater than 0 then
                tell tab thisTabIndex of window thisWindowIndex
                    execute javascript execCode
                end tell
                exit repeat
            end if

            set thisWindowIndex to thisWindowIndex + 1

        end repeat

        if seenPlayerTab is 0 then
            set newTab to make new tab at end of tabs of window 1
            set URL of newTab to "https://www.focusatwill.com/music/#player"
            delay 5
            tell newTab
                execute javascript execCode
            end tell
        end if

    end tell
end alfred_script

on alfred_script(q)

    set AppleScript's text item delimiters to {" "}

    tell application "Google Chrome"

        if q is "" or q is "p" or q is "pp" or q is "play" or q is "pause" then
            set buttonClass to "play"
            set execCode to "$('." & buttonClass & "').first().click()"
        else if q is "next" or q is "skip" or q is "n" then
            set buttonClass to "next"
            set execCode to "$('." & buttonClass & "').first().click()"
        else
            set argList to every text item of q
            if item 1 of argList is "genre" then
                set execCode to "$('li.genre a')[" & item 2 of argList & "].click();"
            end if
        end if

        set seenPlayerTab to 0

        set thisWindowIndex to 1
        repeat with thisWindow in windows

            set thisTabIndex to 1
            repeat with thisTab in tabs of thisWindow

                if URL of thisTab starts with "https://www.focusatwill.com/" then
                    set seenPlayerTab to 1
                    exit repeat
                end if

                set thisTabIndex to thisTabIndex + 1

            end repeat

            if seenPlayerTab is greater than 0 then
                tell tab thisTabIndex of window thisWindowIndex
                    execute javascript execCode
                end tell
                exit repeat
            end if

            set thisWindowIndex to thisWindowIndex + 1

        end repeat

        if seenPlayerTab is 0 then
            set newTab to make new tab at end of tabs of window 1
            set URL of newTab to "https://www.focusatwill.com/music/#player"
            delay 5
            tell newTab
                execute javascript execCode
            end tell
        end if

    end tell
end alfred_script

Fix potential text delimiter bug

Fix potential text delimiter bug


use scripting additions
use framework "Foundation"
property NSString : a reference to current application's NSString

-- Helper

on myRemoveLastPath(myPath)
set myString to NSString's stringWithString:myPath
set removedLastPathString to myString's stringByDeletingLastPathComponent
removedLastPathString as text
end myRemoveLastPath

on myFolderExists(myFolder) -- (String) as Boolean
tell application "System Events"
if exists folder myFolder then
return true
else
return false
end if
end tell
end myFolderExists

-- Path

on myHomePath()
tell application "System Events"
"/Users/" & (name of current user)
end tell
end myHomePath

on myLibraryPath()
myHomePath() & "/Library"
end myLibraryPath

on myXcodePath()
myLibraryPath() & "/Developer/Xcode"
end myXcodePath

on myUserDataPath()
myXcodePath() & "/UserData"
end myUserDataPath

on myProjectPath()
tell application "Xcode"
tell active workspace document
set myPath to path
end tell
end tell
myRemoveLastPath(myPath)
end myProjectPath

-- Generic Open

on myOpenFolder(myPath)
tell application "Finder"
activate
open myPath as POSIX file
end tell
end myOpenFolder

on myOpeniTerm(myPath)
tell application "Finder"
do shell script "open -a iTerm " & quoted form of myPath
end tell
end myOpeniTerm

-- Open

on myOpenThemesFolder()
set myPath to myUserDataPath() & "/FontAndColorThemes/"
myOpenFolder(myPath)
end myOpenThemesFolder

on myOpenCodeSnippetsFolder()
set myPath to myUserDataPath() & "/CodeSnippets/"
myOpenFolder(myPath)
end myOpenCodeSnippetsFolder

on myOpenDeviceSupportFolder()
set myPath to "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport"
myOpenFolder(myPath)
end myOpenDeviceSupportFolder

on myOpenArchivesFolder()
set myPath to myXcodePath() & "/Archives/"
myOpenFolder(myPath)
end myOpenArchivesFolder

on myOpenProvisioningProfileFolder()
set myPath to myLibraryPath() & "/MobileDevice/Provisioning Profiles"
myOpenFolder(myPath)
end myOpenProvisioningProfileFolder

on myOpenProjectFolder()
set myPath to myProjectPath()
myOpenFolder(myPath)
end myOpenProjectFolder

on myOpeniTermForCurrentProject()
set myPath to myProjectPath()
myOpeniTerm(myPath)
end myOpeniTermForCurrentProject

on myOpenDerivedDataFolder()
set myRelativePath to myProjectPath() & "/DerivedData/"
if myFolderExists(myRelativePath) then
myOpenFolder(myRelativePath)
else
myOpenFolder(myXcodePath() & "/DerivedData/")
end if
end myOpenDerivedDataFolder

on myOpenGitHub()
set myPath to myProjectPath()
set myUrl to (do shell script "cd " & quoted form of myPath & "; git config --get remote.origin.url")
open location myUrl
end myOpenGitHub

use scripting additions
use framework "Foundation"
property NSString : a reference to current application's NSString

-- Helper

on myRemoveLastPath(myPath)
set myString to NSString's stringWithString:myPath
set removedLastPathString to myString's stringByDeletingLastPathComponent
removedLastPathString as text
end myRemoveLastPath

on myFolderExists(myFolder) -- (String) as Boolean
tell application "System Events"
if exists folder myFolder then
return true
else
return false
end if
end tell
end myFolderExists

on myGetRemote(myText)
set myString to NSString's stringWithString:myText
set myParts to myString's componentsSeparatedByString:"  "
set myFirstParts to item 1 of myParts
myFirstParts as text
end myGetRemote

-- Path

on myHomePath()
tell application "System Events"
"/Users/" & (name of current user)
end tell
end myHomePath

on myLibraryPath()
myHomePath() & "/Library"
end myLibraryPath

on myXcodePath()
myLibraryPath() & "/Developer/Xcode"
end myXcodePath

on myUserDataPath()
myXcodePath() & "/UserData"
end myUserDataPath

on myProjectPath()
tell application "Xcode"
tell active workspace document
set myPath to path
end tell
end tell
myRemoveLastPath(myPath)
end myProjectPath

-- Generic Open

on myOpenFolder(myPath)
tell application "Finder"
activate
open myPath as POSIX file
end tell
end myOpenFolder

on myOpeniTerm(myPath)
tell application "Finder"
do shell script "open -a iTerm " & quoted form of myPath
end tell
end myOpeniTerm

-- Open

on myOpenThemesFolder()
set myPath to myUserDataPath() & "/FontAndColorThemes/"
myOpenFolder(myPath)
end myOpenThemesFolder

on myOpenCodeSnippetsFolder()
set myPath to myUserDataPath() & "/CodeSnippets/"
myOpenFolder(myPath)
end myOpenCodeSnippetsFolder

on myOpenDeviceSupportFolder()
set myPath to "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport"
myOpenFolder(myPath)
end myOpenDeviceSupportFolder

on myOpenArchivesFolder()
set myPath to myXcodePath() & "/Archives/"
myOpenFolder(myPath)
end myOpenArchivesFolder

on myOpenProvisioningProfileFolder()
set myPath to myLibraryPath() & "/MobileDevice/Provisioning Profiles"
myOpenFolder(myPath)
end myOpenProvisioningProfileFolder

on myOpenProjectFolder()
set myPath to myProjectPath()
myOpenFolder(myPath)
end myOpenProjectFolder

on myOpeniTermForCurrentProject()
set myPath to myProjectPath()
myOpeniTerm(myPath)
end myOpeniTermForCurrentProject

on myOpenDerivedDataFolder()
set myRelativePath to myProjectPath() & "/DerivedData/"
if myFolderExists(myRelativePath) then
myOpenFolder(myRelativePath)
else
myOpenFolder(myXcodePath() & "/DerivedData/")
end if
end myOpenDerivedDataFolder

on myOpenGitHub()
set myPath to myProjectPath()
set myConsoleOutput to (do shell script "cd " & quoted form of myPath & "; git remote -v")
set myRemote to myGetRemote(myConsoleOutput)
set myUrl to (do shell script "cd " & quoted form of myPath & "; git config --get remote." & quoted form of myRemote & ".url")
open location myUrl
end myOpenGitHub

Add myGetRemote

Add myGetRemote


on run -- for testing in script editor
	process_disk_image("Growl", "/Users/evands/growl/Release/Artwork")
end run

on process_disk_image(volumeName, artPath)
	tell application "Finder"
		tell disk volumeName
			open
			tell container window
				set current view to icon view
				set toolbar visible to false
				set statusbar visible to false
				--set the bounds to {30, 50, 579, 600}
			end tell
			close
			set opts to the icon view options of container window
			tell opts
				set icon size to 64
				set arrangement to not arranged
			end tell
			set background picture of opts to file ".background:growlDMGBackground.png"
			set position of item "Growl.pkg" to {147, 75}
			set position of item "Extras" to {100, 320}
			--set position of item "Scripts" to {36, 153}
			set position of item "Growl Documentation.webloc" to {100, 218}
			set position of item "Growl version history.webloc" to {275, 218}
			set position of item "Get more styles.webloc" to {415, 218}
			set position of item "Uninstall Growl.app" to {415, 320}

			-- Custom icons
			my copyIconOfTo(artPath & "/GrowlIcon", "/Volumes/" & volumeName & "/Growl.mpkg")

			update without registering applications
			tell container window
				open
				set the_window_id to id
			end tell
			update without registering applications
		end tell
		set bounds of window id the_window_id to {30, 50, 575, 450}
		--give the finder some time to write the .DS_Store file
		delay 5
	end tell
end process_disk_image

on copyIconOfTo(aFileOrFolderWithIcon, aFileOrFolder)
	tell application "Finder" to set f to POSIX file aFileOrFolderWithIcon as alias
	-- grab the file's icon
	my CopyOrPaste(f, "c")
	-- now the icon is in the clipboard
	tell application "Finder" to set c to POSIX file aFileOrFolder as alias
	my CopyOrPaste(result, "v")
end copyIconOfTo

on CopyOrPaste(i, cv)
	tell application "Finder"
		activate
		open information window of i
	end tell
	tell application "System Events" to tell process "Finder" to tell window 1
		keystroke tab -- select icon button
		keystroke (cv & "w") using command down (* (copy or paste) + close window *)
	end tell -- window 1 then process Finder then System Events
end CopyOrPaste

on run -- for testing in script editor
	process_disk_image("Growl", "/Users/evands/growl/Release/Artwork")
end run

on process_disk_image(volumeName, artPath)
	tell application "Finder"
		tell disk volumeName
			open
			tell container window
				set current view to icon view
				set toolbar visible to false
				set statusbar visible to false
				set bounds to {30, 50, 579, 486}
			end tell
			close
			set opts to the icon view options of container window
			tell opts
				set icon size to 64
				set arrangement to not arranged
			end tell
			set background picture of opts to file ".background:growlDMGBackground.png"
			set position of item "Growl.pkg" to {147, 75}
			set position of item "Extras" to {100, 320}
			--set position of item "Scripts" to {36, 153}
			set position of item "Growl Documentation.webloc" to {100, 218}
			set position of item "Growl version history.webloc" to {275, 218}
			set position of item "Get more styles.webloc" to {415, 218}
			set position of item "Uninstall Growl.app" to {415, 320}

			-- Custom icons
			my copyIconOfTo(artPath & "/GrowlIcon", "/Volumes/" & volumeName & "/Growl.mpkg")

			update without registering applications
			tell container window
				open
				set the_window_id to id
			end tell
			update without registering applications
		end tell
		set bounds of window id the_window_id to {30, 50, 575, 450}
		--give the finder some time to write the .DS_Store file
		delay 5
	end tell
end process_disk_image

on copyIconOfTo(aFileOrFolderWithIcon, aFileOrFolder)
	tell application "Finder" to set f to POSIX file aFileOrFolderWithIcon as alias
	-- grab the file's icon
	my CopyOrPaste(f, "c")
	-- now the icon is in the clipboard
	tell application "Finder" to set c to POSIX file aFileOrFolder as alias
	my CopyOrPaste(result, "v")
end copyIconOfTo

on CopyOrPaste(i, cv)
	tell application "Finder"
		activate
		open information window of i
	end tell
	tell application "System Events" to tell process "Finder" to tell window 1
		keystroke tab -- select icon button
		keystroke (cv & "w") using command down (* (copy or paste) + close window *)
	end tell -- window 1 then process Finder then System Events
end CopyOrPaste

Set the bounds of the disk image volume window. I'm not sure why this was commented out. Not only have I uncommented it, I also changed the value.


#
# This script outlines  the basic funcationality needed to build
# an automatic scraper or other chrome automation function.  It solves
# several annoying problems with automator and appleScript and should save
# people a bunch of time.  It does not catch errors or implement other
# bulletproofing.
#
# It uses google.com for illustration.
# Operations:
#   Open chrome window of a certain size at position 0,0
#   Type something in
#   Click somewhere on the screen
#   Screen shot just the window

set screenWidth to 1200
set screenHeight to 1440

tell application "Google Chrome"
	activate
	set w to make new window with properties {bounds:{0, 0, screenWidth, screenHeight}}
	delay (random number from 0.2304 to 2.8472)
	open location "http://google.com"
	delay (random number from 1.2304 to 2.8472)
	tell application "System Events" to keystroke "test"
	delay (random number from 0.335 to 1.534)

	tell application "System Events" to keystroke return
	delay (random number from 0.335 to 1.534)

	repeat 5 times
		tell application "System Events" to keystroke tab
		delay (random number from 0.335 to 1.534)
	end repeat
end tell
do shell script "/usr/bin/click -x 0 -y 0"
set fileName to do shell script "date \"+Screen Shot  %Y-%m-%d at %H.%M.%S.png\""
tell application "System Events" to set thePath to POSIX path of desktop folder
do shell script "screencapture  -o -R0,0,1200,1400 -x -T 1 " & "\"" & thePath & "/" & fileName & "\""

#
# This script outlines  the basic funcationality needed to build
# an automatic scraper or other chrome automation function.  It solves
# several annoying problems with automator and appleScript and should save
# people a bunch of time.  It does not catch errors or implement other
# bulletproofing.
#
# It uses google.com for illustration.
# Operations:
#   Open chrome window of a certain size at position 0,0
#   Type something in
#   Click somewhere on the screen
#   Screen shot just the window

set screenWidth to 1200
set screenHeight to 1440

tell application "Google Chrome"
	activate
	set w to make new window with properties {bounds:{0, 0, screenWidth, screenHeight}}
	delay (random number from 0.2304 to 2.8472)
	open location "http://google.com"
	delay (random number from 1.2304 to 2.8472)
	tell application "System Events" to keystroke "test"
	delay (random number from 0.335 to 1.534)

	tell application "System Events" to keystroke return
	delay (random number from 0.335 to 1.534)

	repeat 5 times
		tell application "System Events" to keystroke tab
		delay (random number from 0.335 to 1.534)
	end repeat
end tell
do shell script "/usr/local/bin/click -x 0 -y 0"
set fileName to do shell script "date \"+Screen Shot  %Y-%m-%d at %H.%M.%S.png\""
tell application "System Events" to set thePath to POSIX path of desktop folder
do shell script "screencapture  -o -R0,0,1200,1400 -x -T 1 " & "\"" & thePath & "/" & fileName & "\""

Update pictureit.scpt

Update pictureit.scpt

Best to put click in /usr/local/bin


on control(keyCode)
  set code to "var keyCode = " & keyCode & ";
    var event = document.createEvent('Events');
    event.initEvent('keydown', true, true);
    event.keyCode = keyCode;
    event.which = keyCode;

    document.dispatchEvent(event);
  "

  set targetTab to activeTab() of me
  executeJavaScript(targetTab, code) of me
end control

on notifyCurrentSong()
  set targetTab to activeTab() of me

  set songCode to "document.querySelector('.playerSongTitle .fade-out-content').innerHTML"
  set song to executeJavaScript(targetTab, songCode) of me

  set artistCode to "document.querySelector('.playerArtist .fade-out-content').innerHTML"
  set artist to executeJavaScript(targetTab, artistCode) of me

  notify(song, artist) of me
end notifyCurrentSong

on notify(name, message)
  set command to "/usr/local/bin/growlnotify -n " & quoted form of name & " -m " & quoted form of message
  do shell script command
end notify

on activeTab()
  set targetTab to null

  tell application "Google Chrome"
    repeat with theWindow in every window
      repeat with theTab in every tab of theWindow
        if theTab's title ends with "- Google Play Music" then
          set targetTab to theTab
          exit repeat
        end if
      end repeat
    end repeat
  end tell

  return targetTab
end activeTab

on executeJavaScript(activeTab, code)
  set result to null

  tell application "Google Chrome"
    set result to execute activeTab javascript code
  end tell

  return result
end executeJavaScript

on control(keyCode)
  set code to "var keyCode = " & keyCode & ";
    var event = document.createEvent('Events');
    event.initEvent('keydown', true, true);
    event.keyCode = keyCode;
    event.which = keyCode;

    document.dispatchEvent(event);
  "

  set targetTab to activeTab() of me
  executeJavaScript(targetTab, code) of me
end control

on notifyCurrentSong()
  set targetTab to activeTab() of me

  set songCode to "document.querySelector('#playerSongTitle').innerHTML"
  set song to executeJavaScript(targetTab, songCode) of me

  set artistCode to "document.querySelector('.player-artist-album-wrapper').innerText"
  set artist to executeJavaScript(targetTab, artistCode) of me

  notify(song, artist) of me
end notifyCurrentSong

on notify(name, message)
  display notification message with title name
end notify

on activeTab()
  set targetTab to null

  tell application "Google Chrome"
    repeat with theWindow in every window
      repeat with theTab in every tab of theWindow
        if theTab's title ends with "- Google Play Music" then
          set targetTab to theTab
          exit repeat
        end if
      end repeat
    end repeat
  end tell

  return targetTab
end activeTab

on executeJavaScript(activeTab, code)
  set result to null

  tell application "Google Chrome"
    set result to execute activeTab javascript code
  end tell

  return result
end executeJavaScript

update to use notification center instead of growl


FasdUAS 1.101.10
k
l
i

	I
.aevtoappnull****

Q
k

r
n

I
0inputdialoginputDialog
mEnter task:
m
f
o
0	task_text
n

I"0addentrytoinboxaddEntryToInbox !
 o
0	task_text!"
"m##$$
f

R
.ascrerr ********%&
%l&'(
'i)*
)I+
.aevtodocnullalis
+o0
dropped_files
*XH,-
,kC../0
/r12
1n34
31

strq
4n56
51

psxp
6o
0	file_path
2o0afileaFile078
7r!9:
9I;
.sysoexecTEXTTEXT
;b<=
<m>>??basename
=o0afileaFile
:o0filename8@
@Q"CAB
Ak%:CCDE
Dr%2FG
Fn%0HI
HI&0J0inputdialoginputDialogJKL
Kb&+MN
Mb&)OP
Om&'QQRR Task related to
Po'(0filename
Nm)*SSTT:LU
Uo+,0filename
If%&
Go
0	task_textEV
Vn3:WX
WI4:Y"0addentrytoinboxaddEntryToInboxYZ[
Zo45
0	task_text[\
\o560afileaFile
Xf34
BR
.ascrerr ********
0	file_path
-o0
dropped_files(]^
]l^_`
_iab
aIc"0addentrytoinboxaddEntryToInboxcde
do
0	task_textef
fo
0	file_path
bk+gghi
hrjk
jIl
.sysoexecTEXTTEXT
lmmmnnNdefaults read inbox.app.plist inbox_cmd
ko
0	inbox_cmdiop
oZqrs
q=tu
to
0	file_path
um
vvww
rrxy
xmzz{{
yo0file_ref
sr|}
|b~
~m file://
o
0	file_path
}o0file_refp
r#
b!
b
b
o
0	inbox_cmd
m
o
0	task_text
o 0file_ref
o0cmd
o$%0cmd
I&+
.sysoexecTEXTTEXT
o&'0cmd`
l
i
I0inputdialoginputDialog
o	0title
o0default_text
k
r
l
I
.sysodlogaskrTEXT
l

o	0title

dtxt
l

o0default_text

disp
l

m

btns
l

J

mCancel
mOK

dflt
mOK
o0	thedialog	theDialog
r
n
1

ttxt
o0	thedialog	theDialog
o0
text_typed
L
o0
text_typed
l
l
~}
.aevtoappnull****
.aevtodocnullalis"0addentrytoinboxaddEntryToInbox0inputdialoginputDialog
0	task_text~}|
{zy
|.aevtoappnull****{zxw#vutx0inputdialoginputDialogw
0	task_textv"0addentrytoinboxaddEntryToInboxuty)l+EO)l+WXhs*rqp
s.aevtodocnullalisr0
dropped_filesqonmlko0
dropped_filesn
0	file_pathm0afileaFilel0filenamek
0	task_text
jihgf>eQSdcba
j
kocl
i
cobj
h.corecnte********
g
psxp
f
strq
e.sysoexecTEXTTEXTd0inputdialoginputDialogc"0addentrytoinboxaddEntryToInboxbapIG[lkh,,EO%jEO)%%l+	EO)l+
WXh[OY`b_^]`"0addentrytoinboxaddEntryToInbox_\\[Z[
0	task_textZ
0	file_path^YXWVUY
0	task_textX
0	file_pathW
0	inbox_cmdV0file_refU0cmdmTvz
T.sysoexecTEXTTEXT],jEOEY%EO%%%EOOjSRQPS0inputdialoginputDialogROONMN	0titleM0default_textQLKJIL	0titleK0default_textJ0	thedialog	theDialogI0
text_typed
HGFEDCB
H
dtxt
G
disp
F
btns
E
dfltD
C.sysodlogaskrTEXT
B
ttxtPklvEO,EOFooascr
ޭ

FasdUAS 1.101.10
k
l
i

	I
.aevtoappnull****

Q
k

r
n

I
0inputdialoginputDialog
mEnter task:
m
f
o
0	task_text
n

I"0addentrytoinboxaddEntryToInbox !
 o
0	task_text!"
"m##$$
f

R
.ascrerr ********%&
%l&'(
'i)*
)I+
.aevtodocnullalis
+o0
dropped_files
*XH,-
,kC../0
/r12
1n34
31

strq
4n56
51

psxp
6o
0	file_path
2o0afileaFile078
7r!9:
9I;
.sysoexecTEXTTEXT
;b<=
<m>>??basename
=o0afileaFile
:o0filename8@
@Q"CAB
Ak%:CCDE
Dr%2FG
Fn%0HI
HI&0J0inputdialoginputDialogJKL
Kb&+MN
Mb&)OP
Om&'QQRR Task related to
Po'(0filename
Nm)*SSTT:LU
Uo+,0filename
If%&
Go
0	task_textEV
Vn3:WX
WI4:Y"0addentrytoinboxaddEntryToInboxYZ[
Zo45
0	task_text[\
\o560afileaFile
Xf34
BR
.ascrerr ********
0	file_path
-o0
dropped_files(]^
]l^_`
_iab
aIc"0addentrytoinboxaddEntryToInboxcde
do
0	task_textef
fo
0	file_path
bk+gghi
hrjk
jIl
.sysoexecTEXTTEXT
lmmmnnNdefaults read inbox.app.plist inbox_cmd
ko
0	inbox_cmdiop
oZqrs
q=tu
to
0	file_path
um
vvww
rrxy
xmzz{{
yo0file_ref
sr|}
|b~
~m file://
o
0	file_path
}o0file_refp
r#
b!
b
b
o
0	inbox_cmd
m
o
0	task_text
o 0file_ref
o0cmd
o$%0cmd
I&+
.sysoexecTEXTTEXT
o&'0cmd`
l
i
I0inputdialoginputDialog
o	0title
o0default_text
k
r
l
I
.sysodlogaskrTEXT
l

o	0title

dtxt
l

o0default_text

disp
l

m

btns
l

J

mCancel
mOK

dflt
mOK
o0	thedialog	theDialog
r
n
1

ttxt
o0	thedialog	theDialog
o0
text_typed
L
o0
text_typed
l
l
~}
.aevtoappnull****
.aevtodocnullalis"0addentrytoinboxaddEntryToInbox0inputdialoginputDialog
0	task_text~}|
{zy
|.aevtoappnull****{zxw#vutx0inputdialoginputDialogw
0	task_textv"0addentrytoinboxaddEntryToInboxuty)l+EO)l+WXhs*rqp
s.aevtodocnullalisr0
dropped_filesqonmlko0
dropped_filesn
0	file_pathm0afileaFilel0filenamek
0	task_text
jihgf>eQSdcba
j
kocl
i
cobj
h.corecnte********
g
psxp
f
strq
e.sysoexecTEXTTEXTd0inputdialoginputDialogc"0addentrytoinboxaddEntryToInboxbapIG[lkh,,EO%jEO)%%l+	EO)l+
WXh[OY`b_^]`"0addentrytoinboxaddEntryToInbox_\\[Z[
0	task_textZ
0	file_path^YXWVUY
0	task_textX
0	file_pathW
0	inbox_cmdV0file_refU0cmdmTvz
T.sysoexecTEXTTEXT],jEOEY%EO%%%EOOjSRQPS0inputdialoginputDialogROONMN	0titleM0default_textQLKJIL	0titleK0default_textJ0	thedialog	theDialogI0
text_typed
HGFEDCB
H
dtxt
G
disp
F
btns
E
dfltD
C.sysodlogaskrTEXT
B
ttxtPklvEO,EOfooascr
ޭ

Update inbox applescript

Update inbox applescript