Tidied the display implementation

Tidied the display implementation

--
--  DASAppDelegate.applescript
--  itunes-concatenator
--
--  Created by David Schlachter on 2014-08-26.
--  Copyright (c) 2014 Red Eft Software. All rights reserved.
--

-- via http://macscripter.net/viewtopic.php?pid=173787 ; apparently needed for using arrays

script DASAppDelegate
	property parent : class "NSObject"

    global these_files, these_titles

	-- IBOutlets
	property window : missing value
    property trackTable : missing value
    property catName : missing value
    property catArtist : missing value
    property catAlbum : missing value
    property catComposer : missing value
    property catGenre : missing value
    property catTrack : missing value
    property catTracks : missing value
    property catDisc : missing value
    property catDiscs : missing value

    -- Again, per macscripter, we'll set up bindings for the options
    property pcatName : ""
    property pcatArtist : ""
    property pcatAlbum : ""
    property pcatComposer : ""
    property pcatGenre : ""
    property pcatTrack : ""
    property pcatTracks : ""
    property pcatDisc : ""
    property pcatDiscs : ""

    -- Empty strings for each file name and location
    property pEachName : ""
    property pEachLocation : ""

    property these_titles : {}
    property these_files : {}

    on awakeFromNib()
        --
        -- Check for FFMPEG
        --
        -- (This works, but it's ugly!)
        --
        --
        try
            do shell script "if [[ -r /etc/profile ]];then . /etc/profile;fi;if [[ -r ~/.bashrc ]];then . ~/.bashrc;fi;if [[ -r ~/.bash_profile ]];then . ~/.bash_profile;fi; if [ -x \"`/usr/bin/which ffmpeg`\" ];then exit 0;else exit 1;fi"
        on error number error_number
            display dialog "You must install FFMPEG to continue. \n\nYou may have to install Xcode Command Line Tools and Homebrew first. If you continue, we'll attempt to install them for you if they are not already present. \n\nIf you have already installed FFMPEG, ensure that it is in your bash path." buttons {"Quit","Install FFMPEG"} default button 2
            If button returned of result is "Install FFMPEG" then
                try
                    tell application "Terminal"
                        -- TODO: This should be cleaner -- Terminal in front, only one window, focus back to the cat'er afterwards
                        set newTab to do script "if [[ -r /etc/profile ]];then . /etc/profile;fi;if [[ -r ~/.bashrc ]];then . ~/.bashrc;fi;if [[ -r ~/.bash_profile ]];then . ~/.bash_profile;fi;if [[ -x `which brew` ]];then brew install ffmpeg;else /usr/bin/ruby -e \"$(/usr/bin/curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)\";brew install ffmpeg;fi"
                        delay 4
                        repeat
                            delay 0.1
                            if not busy of newTab then exit repeat
                        end repeat
                    end tell
                     -- TODO: This needs a better test, i.e., check if ffmpeg is actually accessible on the path
                    display dialog "FFMPEG was successfully installed"
                    -- TODO: This should actually work! (Bring us back to the foreground)
                    activate current application
                on error number error_number
                    display dialog "FFMPEG did not successfully install"
                end try
            end If
            If button returned of result is "Quit" then
                -- Fix!
                current application's NSApp's terminate()
            end If
        end try
    end awakeFromNib

    on btnGetTracks_(sender)
        -- Code to add iTunes tracks to our list
        -- via http://dougscripts.com/itunes/itinfo/info02.php and http://www.randomsequence.com/articles/applescript-to-send-selected-itunes-tracks-using-mail/
        tell application "iTunes"
            set these_titles to {}
            set these_files to {}
            if selection is not {} then -- there ARE tracks selected...
                set mySelection to selection
                repeat with aTrack in mySelection
                    if class of aTrack is file track then
                        set end of these_titles to ((name of aTrack) as string)
                        set end of these_files to (posix path of (get location of aTrack))
                    end if
                end repeat
            end if
        end tell
        -- via http://stackoverflow.com/questions/25537750/setstringvalue-with-applescript-list
        set olddelimeters to AppleScript's text item delimiters
        set AppleScript's text item delimiters to "\n"
        set disp_titles to these_titles as string
        trackTable's setStringValue_(disp_titles)
        set AppleScript's text item delimiters to olddelimeters
    end btnGetTracks_

    on btnConcatenate_(sender)
        repeat with theItem in these_titles
            say theItem
        end repeat
    end btnConcatenate_

	on applicationWillFinishLaunching_(aNotification)
		-- Insert code here to initialize your application before any files are opened
	end applicationWillFinishLaunching_

	on applicationShouldTerminate_(sender)
		-- Insert code here to do any housekeeping before your application quits
		return current application's NSTerminateNow
	end applicationShouldTerminate_

end script

--
--  DASAppDelegate.applescript
--  itunes-concatenator
--
--  Created by David Schlachter on 2014-08-26.
--  Copyright (c) 2014 Red Eft Software. All rights reserved.
--

-- via http://macscripter.net/viewtopic.php?pid=173787 ; apparently needed for using arrays

script DASAppDelegate
	property parent : class "NSObject"

    global these_files, these_titles

	-- IBOutlets
	property window : missing value
    property trackTable : missing value
    property catName : missing value
    property catArtist : missing value
    property catAlbum : missing value
    property catComposer : missing value
    property catGenre : missing value
    property catTrack : missing value
    property catTracks : missing value
    property catDisc : missing value
    property catDiscs : missing value

    -- Again, per macscripter, we'll set up bindings for the options
    property pcatName : ""
    property pcatArtist : ""
    property pcatAlbum : ""
    property pcatComposer : ""
    property pcatGenre : ""
    property pcatTrack : ""
    property pcatTracks : ""
    property pcatDisc : ""
    property pcatDiscs : ""

    -- Empty strings for each file name and location
    property pEachName : ""
    property pEachLocation : ""

    property these_titles : {}
    property these_files : {}

    on awakeFromNib()
        --
        -- Check for FFMPEG
        --
        -- (This works, but it's ugly!)
        --
        --
        try
            do shell script "if [[ -r /etc/profile ]];then . /etc/profile;fi;if [[ -r ~/.bashrc ]];then . ~/.bashrc;fi;if [[ -r ~/.bash_profile ]];then . ~/.bash_profile;fi; if [ -x \"`/usr/bin/which ffmpeg`\" ];then exit 0;else exit 1;fi"
        on error number error_number
            display dialog "You must install FFMPEG to continue. \n\nYou may have to install Xcode Command Line Tools and Homebrew first. If you continue, we'll attempt to install them for you if they are not already present. \n\nIf you have already installed FFMPEG, ensure that it is in your bash path." buttons {"Quit","Install FFMPEG"} default button 2
            If button returned of result is "Install FFMPEG" then
                try
                    tell application "Terminal"
                        -- TODO: This should be cleaner -- Terminal in front, only one window, focus back to the cat'er afterwards
                        set newTab to do script "if [[ -r /etc/profile ]];then . /etc/profile;fi;if [[ -r ~/.bashrc ]];then . ~/.bashrc;fi;if [[ -r ~/.bash_profile ]];then . ~/.bash_profile;fi;if [[ -x `which brew` ]];then brew install ffmpeg;else /usr/bin/ruby -e \"$(/usr/bin/curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)\";brew install ffmpeg;fi"
                        delay 4
                        repeat
                            delay 0.1
                            if not busy of newTab then exit repeat
                        end repeat
                    end tell
                     -- TODO: This needs a better test, i.e., check if ffmpeg is actually accessible on the path
                    display dialog "FFMPEG was successfully installed"
                    -- TODO: This should actually work! (Bring us back to the foreground)
                    activate current application
                on error number error_number
                    display dialog "FFMPEG did not successfully install"
                end try
            end If
            If button returned of result is "Quit" then
                -- Fix!
                current application's NSApp's terminate()
            end If
        end try
    end awakeFromNib

    on btnGetTracks_(sender)
        -- Code to add iTunes tracks to our list
        -- via http://dougscripts.com/itunes/itinfo/info02.php and http://www.randomsequence.com/articles/applescript-to-send-selected-itunes-tracks-using-mail/
        tell application "iTunes"
            set these_titles to {}
            set these_files to {}
            if selection is not {} then -- there ARE tracks selected...
                set mySelection to selection
                repeat with aTrack in mySelection
                    if class of aTrack is file track then
                        set end of these_titles to ((name of aTrack) as string)
                        set end of these_files to (posix path of (get location of aTrack))
                    end if
                end repeat
            end if
        end tell
        -- via http://stackoverflow.com/questions/25537750/setstringvalue-with-applescript-list
        set olddelimeters to AppleScript's text item delimiters
        set AppleScript's text item delimiters to "\n"
        set these_titles to these_titles as string
        set AppleScript's text item delimiters to ""
        trackTable's setStringValue_(these_titles)
        set AppleScript's text item delimiters to olddelimeters
    end btnGetTracks_

    on btnConcatenate_(sender)
        repeat with theItem in these_titles
            say theItem
        end repeat
    end btnConcatenate_

	on applicationWillFinishLaunching_(aNotification)
		-- Insert code here to initialize your application before any files are opened
	end applicationWillFinishLaunching_

	on applicationShouldTerminate_(sender)
		-- Insert code here to do any housekeeping before your application quits
		return current application's NSTerminateNow
	end applicationShouldTerminate_

end script


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

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

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


I did not change this file ?? But somehow it showed up in my changelist.

FasdUAS 1.101.10
k
l
O
r

m
boovtrue
l
n

1

pvis
2

prcs
	msevsalisMacintosh HDΗH+-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

r

J

m
Finder
mTerminal
o0
white_list
lv
Qv
km!!"#
"O,$%
$r+&'
&6)()
(l *
*n +,
+1

pnam
,2

prcs
)=!(-.
-1"$

pvis
.m%'
boovtrue
'o0process_list
%m//MACSalistMacintosh HDΗH+-
Finder.app%xa6	 CoreServicesΗa'-*)6Macintosh HD:System:Library:CoreServices:Finder.app
Finder.appMacintosh HD&System/Library/CoreServices/Finder.app/#01
0Y-`234
2k<[5567
6r<B89
8n<@:;
:4=@<

cobj
<o>?0i
;l<==
=o<=0process_list
9o0this_process7>
>ZC[?@
?HCGA
AECFBC
BoCD0
white_list
CoDE0this_process
@OJWDE
DIQV
.aevtquitnullnull
E4JNF

capp
FoLM0this_process0i
3m01
4l17G
Gn17HI
Hm46

nmbr
In14JK
J224

cobj
Ko120process_list1L
LOamMN
MIelO
.aevtquitnullnull
O2eh

cwin
NmabPPMACSalistMacintosh HDΗH+-
Finder.app%xa6	 CoreServicesΗa'-*)6Macintosh HD:System:Library:CoreServices:Finder.app
Finder.appMacintosh HD&System/Library/CoreServices/Finder.app/
 R
.ascrerr ********QRSTUQ
.aevtoappnull****0
white_list0process_list0this_processRVWX
.aevtoappnull****
VkvYYZZ[[W0iX/\

prcs

pvis0
white_list

pnam\0process_list

cobj

nmbr0this_process

capp
.aevtquitnullnull

cwinw	e*-,FUOlvEO[*-,[,\Ze81EUO2k-,Ekh/EO*/*jUYh[OYO	*-jUWXhS]]T^
^
_`abcdefghijU_kkMail`llSafariammMessagesbnnphpstormcooTerminaldppSpotifyeqqFinderfrr
SkypegssGoogle ChromehttBitTorrentiuu Activity MonitorjvviTunesUwwVLCascrޭ

FasdUAS 1.101.10
k
l
O
r

m
boovtrue
l
n

1

pvis
2

prcs
	msevsalisMacintosh HDΗH+-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

r

J

m
Finder
mTerminal
o0
white_list
lv
Qv
km!!"#
"O,$%
$r+&'
&6)()
(l *
*n +,
+1

pnam
,2

prcs
)=!(-.
-1"$

pvis
.m%'
boovtrue
'o0process_list
%m//MACSalistMacintosh HDΗH+-
Finder.app%xa6	 CoreServicesΗa'-*)6Macintosh HD:System:Library:CoreServices:Finder.app
Finder.appMacintosh HD&System/Library/CoreServices/Finder.app/#01
0Y-`234
2k<[5567
6r<B89
8n<@:;
:4=@<

cobj
<o>?0i
;l<==
=o<=0process_list
9o0this_process7>
>ZC[?@
?HCGA
AECFBC
BoCD0
white_list
CoDE0this_process
@OJWDE
DIQV
.aevtquitnullnull
E4JNF

capp
FoLM0this_process0i
3m01
4l17G
Gn17HI
Hm46

nmbr
In14JK
J224

cobj
Ko120process_list1L
LOamMN
MIelO
.aevtquitnullnull
O2eh

cwin
NmabPPMACSalistMacintosh HDΗH+-
Finder.app%xa6	 CoreServicesΗa'-*)6Macintosh HD:System:Library:CoreServices:Finder.app
Finder.appMacintosh HD&System/Library/CoreServices/Finder.app/
 R
.ascrerr ********QRSTUQ
.aevtoappnull****0
white_list0process_list0this_processRVWX
.aevtoappnull****
VkvYYZZ[[W0iX/\

prcs

pvis0
white_list

pnam\0process_list

cobj

nmbr0this_process

capp
.aevtquitnullnull

cwinw	e*-,FUOlvEO[*-,[,\Ze81EUO2k-,Ekh/EO*/*jUYh[OYO	*-jUWXhS]]T^
^
_U`abcdefghij_kkFinderUllChocolat`mmSequentialannphpstormboorubyminecppSpotifydqqTerminalerrMessagesfss
SkypegttGoogle ChromehuufirefoxivvSafarijwwiTunesascrޭ


Windows

Windows

FasdUAS 1.101.10
k
i
I	0resize_app_window

o0app_name

o0win_position

o0win_size
Z=
=
n
1

prun
4

capp
o0app_name
m
boovtrue
O9
O8
k7
r&
J  !
 n"#
"4$

cobj
$m
#o0win_position!%
%n&'
&4(

cobj
(m
'o0win_position
n)*
)1#%

posn
*l #+
+2 #

cwin,
,r'7-.
-J'1//01
0n'+23
24(+4

cobj
4m)*
3o'(0win_size15
5n+/67
64,/8

cobj
8m-.
7o+,0win_size
.n9:
9146

ptsz
:l14;
;214

cwin
4<

prcs
<o0app_name
m==sevsalis\Macintosh HDBDSystem Events.app
 cuCoreServices0/:System:Library:CoreServices:System Events.app/$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/>?
>l?@A
@lB
BrCD
CJEEFG
FmGH
Hm(
Do0wide_center_positionAIJ
Il
K
Kr
LM
LJNNOP
OmPQ
Qm	Q
Mo0wide_center_sizeJRS
RlSTU
TlV
VIW0resize_app_windowWXY
XmZZ[[1PasswordY\]
\o0wide_center_position]^
^o0wide_center_sizeU_`
_la
aIb0resize_app_windowbcd
cmeeffCalendardgh
go0wide_center_positionhi
io0wide_center_size`jk
jl (l
lI (m0resize_app_windowmno
nm!"ppqqDiscordors
ro"#0wide_center_positionst
to#$0wide_center_sizekuv
ul)1w
wI)1x0resize_app_windowxyz
ym*+{{||Fantasticalz}~
}o+,0wide_center_position~
o,-0wide_center_sizev
l2:
I2:0resize_app_window
m34Google Chrome
o450wide_center_position
o560wide_center_size
l;C
I;C0resize_app_window
m<=Linear
o=>0wide_center_position
o>?0wide_center_size
lDL
IDL0resize_app_window
mEFMail
oFG0wide_center_position
oGH0wide_center_size
lM[
IM[0resize_app_window
mNOMessages
JOS
mOP
mPQ(
JSW
mST?
mTUQ
l\f
I\f0resize_app_window
m]`
Music
o`a0wide_center_position
oab0wide_center_size
lgq
Igq0resize_app_window
mhk
Notes
okl0wide_center_position
olm~~0wide_center_size
lr|}|
Ir|{z{0resize_app_window
msvPreview
ovwyy0wide_center_positionx
owxww0wide_center_sizexz}|
l}vu
I}tst0resize_app_window
m~Reflect
orr0wide_center_positionq
opp0wide_center_sizeqsvu
lon
Imlm0resize_app_window
mSafari
okk0wide_center_positionj
oii0wide_center_sizejlon
lhg
Ifef0resize_app_window
mSiftie
odd0wide_center_positionc
obb0wide_center_sizecehg
la`
I_^_0resize_app_window
m
Slack
o]]0wide_center_position\
o[[0wide_center_size\^a`
lZY
IXWX0resize_app_window
mSpotify

	oVV0wide_center_position
U
oTT0wide_center_sizeUWZY

lSR
IQPQ0resize_app_window
mTextEdit
J
mOON
mMMNL
J
mKKJ
mIIJLPSR
H
l GF
 IE!DE0resize_app_window!"#
"m$$%%Tweetbot#&'
&J(()*
)mCC*+B
+mAA(B',@
,J--./
.m???/0>
0m==Q>@DGFH<12345<1;:98;0resize_app_window
:.aevtoappnull****90wide_center_position80wide_center_size276567470resize_app_window6383821020app_name10win_position00win_size56/.-/0app_name.0win_position-0win_size7,+=*)('&
,
capp
+
prun
*
prcs
)
cobj
(
cwin
'
posn
&
ptsz4>*/,e3+*/#k/l/lv*-,FOk/l/lv*-,FUUYh3%9$#:;"
%.aevtoappnull****
9k<<@==I>>T??_@@jAAuBBCCDDEEFFGGHHIIJJKKLLMMNNOO!!$#:; Zep{$ (0wide_center_positionQ0wide_center_size0resize_app_window?"lvEOlvEO*m+O*m+O*m+O*m+O*m+O*m+O*m+O*lvlvm+O*am+O*am+O*am+O*am+O*am+O*am+O*am+O*am+O*aalvaalvm+O*alvlvm+4PP(5QQQascr
ޭ

FasdUAS 1.101.10
k
i
I	0resize_app_window

o0app_name

o0win_position

o0win_size
Z=
=
n
1

prun
4

capp
o0app_name
m
boovtrue
O9
O8
k7
r&
J  !
 n"#
"4$

cobj
$m
#o0win_position!%
%n&'
&4(

cobj
(m
'o0win_position
n)*
)1#%

posn
*l #+
+2 #

cwin,
,r'7-.
-J'1//01
0n'+23
24(+4

cobj
4m)*
3o'(0win_size15
5n+/67
64,/8

cobj
8m-.
7o+,0win_size
.n9:
9146

ptsz
:l14;
;214

cwin
4<

prcs
<o0app_name
m==sevsalis\Macintosh HDBDSystem Events.app
 cuCoreServices0/:System:Library:CoreServices:System Events.app/$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/>?
>l?@A
@lB
BrCD
CJEEFG
FmGH
Hm(
Do0wide_center_positionAIJ
Il
K
Kr
LM
LJNNOP
OmPQ
Qm	Q
Mo0wide_center_sizeJRS
RlSTU
TlV
VIW0resize_app_windowWXY
XmZZ[[1Password 7Y\]
\o0wide_center_position]^
^o0wide_center_sizeU_`
_la
aIb0resize_app_windowbcd
cmeeffCalendardgh
go0wide_center_positionhi
io0wide_center_size`jk
jl (l
lI (m0resize_app_windowmno
nm!"ppqqDiscordors
ro"#0wide_center_positionst
to#$0wide_center_sizekuv
ul)1w
wI)1x0resize_app_windowxyz
ym*+{{||Fantasticalz}~
}o+,0wide_center_position~
o,-0wide_center_sizev
l2:
I2:0resize_app_window
m34Google Chrome
o450wide_center_position
o560wide_center_size
l;C
I;C0resize_app_window
m<=Linear
o=>0wide_center_position
o>?0wide_center_size
lDL
IDL0resize_app_window
mEFMail
oFG0wide_center_position
oGH0wide_center_size
lM[
IM[0resize_app_window
mNOMessages
JOS
mOP
mPQ(
JSW
mST?
mTUQ
l\f
I\f0resize_app_window
m]`
Music
o`a0wide_center_position
oab0wide_center_size
lgq
Igq0resize_app_window
mhk
Notes
okl0wide_center_position
olm~~0wide_center_size
lr|}|
Ir|{z{0resize_app_window
msvPreview
ovwyy0wide_center_positionx
owxww0wide_center_sizexz}|
l}vu
I}tst0resize_app_window
m~Reflect
orr0wide_center_positionq
opp0wide_center_sizeqsvu
lon
Imlm0resize_app_window
mSafari
okk0wide_center_positionj
oii0wide_center_sizejlon
lhg
Ifef0resize_app_window
mSiftie
odd0wide_center_positionc
obb0wide_center_sizecehg
la`
I_^_0resize_app_window
m
Slack
o]]0wide_center_position\
o[[0wide_center_size\^a`
lZY
IXWX0resize_app_window
mSpotify

	oVV0wide_center_position
U
oTT0wide_center_sizeUWZY

lSR
IQPQ0resize_app_window
mTextEdit
J
mOON
mMMNL
J
mKKJ
mIIJLPSR
H
l GF
 IE!DE0resize_app_window!"#
"m$$%%Tweetbot#&'
&J(()*
)mCC*+B
+mAA(B',@
,J--./
.m???/0>
0m==Q>@DGFH<12345<1;:98;0resize_app_window
:.aevtoappnull****90wide_center_position80wide_center_size276567470resize_app_window6383821020app_name10win_position00win_size56/.-/0app_name.0win_position-0win_size7,+=*)('&
,
capp
+
prun
*
prcs
)
cobj
(
cwin
'
posn
&
ptsz4>*/,e3+*/#k/l/lv*-,FOk/l/lv*-,FUUYh3%9$#:;"
%.aevtoappnull****
9k<<@==I>>T??_@@jAAuBBCCDDEEFFGGHHIIJJKKLLMMNNOO!!$#:; Zep{$ (0wide_center_positionQ0wide_center_size0resize_app_window?"lvEOlvEO*m+O*m+O*m+O*m+O*m+O*m+O*m+O*lvlvm+O*am+O*am+O*am+O*am+O*am+O*am+O*am+O*am+O*aalvaalvm+O*alvlvm+4PP(5QQQascr
ޭ


Update openQnA.scpt

Update openQnA.scpt

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


Fix simulator script

Fix simulator script

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

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


Fix potential text delimiter bug

Fix potential text delimiter bug

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

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


Add myGetRemote

Add myGetRemote

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

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


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.

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

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


Update pictureit.scpt

Update pictureit.scpt

Best to put click in /usr/local/bin

#
# 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 & "\""

#
# 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 & "\""


bug fix in Loop Script Steps

bug fix in Loop Script Steps

Scripts/fmClip - Loop Script Steps.applescript


[#67] updated the Mac packager to latest version

on run (volumeName)
	tell application "Finder"
		tell disk (volumeName as string)
			open

			set theXOrigin to WINX
			set theYOrigin to WINY
			set theWidth to WINW
			set theHeight to WINH

			set theBottomRightX to (theXOrigin + theWidth)
			set theBottomRightY to (theYOrigin + theHeight)
			set dsStore to "\"" & "/Volumes/" & volumeName & "/" & ".DS_STORE\""

			tell container window
				set current view to icon view
				set toolbar visible to false
				set statusbar visible to false
				set the bounds to {theXOrigin, theYOrigin, theBottomRightX, theBottomRightY}
				set statusbar visible to false
				REPOSITION_HIDDEN_FILES_CLAUSE
			end tell

			set opts to the icon view options of container window
			tell opts
				set icon size to ICON_SIZE
				set text size to TEXT_SIZE
				set arrangement to not arranged
			end tell
			BACKGROUND_CLAUSE

			-- Positioning
			POSITION_CLAUSE

			-- Hiding
			HIDING_CLAUSE

			-- Application Link Clause
			APPLICATION_CLAUSE
            close
            open

			update without registering applications
			-- Force saving of the size
			delay 1

			tell container window
				set statusbar visible to false
				set the bounds to {theXOrigin, theYOrigin, theBottomRightX - 10, theBottomRightY - 10}
			end tell

			update without registering applications
		end tell

		delay 1

		tell disk (volumeName as string)
			tell container window
				set statusbar visible to false
				set the bounds to {theXOrigin, theYOrigin, theBottomRightX, theBottomRightY}
			end tell

			update without registering applications
		end tell

		--give the finder some time to write the .DS_Store file
		delay 3

		set waitTime to 0
		set ejectMe to false
		repeat while ejectMe is false
			delay 1
			set waitTime to waitTime + 1

			if (do shell script "[ -f " & dsStore & " ]; echo $?") = "0" then set ejectMe to true
		end repeat
		log "waited " & waitTime & " seconds for .DS_STORE to be created."
	end tell
end run

on run (volumeName)
	tell application "Finder"
		tell disk (volumeName as string)
			open

			set theXOrigin to WINX
			set theYOrigin to WINY
			set theWidth to WINW
			set theHeight to WINH

			set theBottomRightX to (theXOrigin + theWidth)
			set theBottomRightY to (theYOrigin + theHeight)
			set dsStore to "\"" & "/Volumes/" & volumeName & "/" & ".DS_STORE\""

			tell container window
				set current view to icon view
				set toolbar visible to false
				set statusbar visible to false
				-- set position of every item to {theBottomRightX + 100, 100}
				set the bounds to {theXOrigin, theYOrigin, theBottomRightX, theBottomRightY}
				set statusbar visible to false
			end tell

			set opts to the icon view options of container window
			tell opts
				set icon size to ICON_SIZE
				set text size to TEXT_SIZE
				set arrangement to not arranged
			end tell
			BACKGROUND_CLAUSE

			-- Positioning
			POSITION_CLAUSE

			-- Hiding
			HIDING_CLAUSE

			-- Application Link Clause
			APPLICATION_CLAUSE
            close
            open

			update without registering applications
			-- Force saving of the size
			delay 1

			tell container window
				set statusbar visible to false
				set the bounds to {theXOrigin, theYOrigin, theBottomRightX - 10, theBottomRightY - 10}
			end tell

			update without registering applications
		end tell

		delay 1

		tell disk (volumeName as string)
			tell container window
				set statusbar visible to false
				set the bounds to {theXOrigin, theYOrigin, theBottomRightX, theBottomRightY}
			end tell

			update without registering applications
		end tell

		--give the finder some time to write the .DS_Store file
		delay 3

		set waitTime to 0
		set ejectMe to false
		repeat while ejectMe is false
			delay 1
			set waitTime to waitTime + 1

			if (do shell script "[ -f " & dsStore & " ]; echo $?") = "0" then set ejectMe to true
		end repeat
		log "waited " & waitTime & " seconds for .DS_STORE to be created."
	end tell
end run


cordova/lib/start-emulator - ask for "Access for assistive devices" GUI scripting permission

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

tell application "iPhone Simulator"
    activate
end tell

tell application "System Events"
    tell process "iPhone Simulator"
    click menu item "$DEVICE_NAME" of menu 1 of menu item "Device" of menu 1 of menu bar item "Hardware" of menu bar 1
    click menu item "Home" of menu 1 of menu bar item "Hardware" of menu bar 1
    end tell
end tell