Revert

Revert


fixed more typos in comments

fixed more typos in comments

Scripts/fmClip - Smart Paste Functions.applescript


Simple check for warnings

Simple check for warnings

Very naive check to see if message is a warning instead of error.

Need to revisit to see if this can be done more reliably.

-- Go AppleScript library

property package : "Go"
property packageRoot : missing value

-- Get working directory for a given document
on getWorkingDirectory(doc)
	tell application "Finder"
		return POSIX path of ((container of ((file of doc) as alias) as string))
	end tell
end getWorkingDirectory

-- Find Go.bbpackage root
-- Assumption: this is *always* run from within the package!
on getPackageRoot()
	tell application "Finder"
		set cwd to ((container of (path to me)) as alias)
		repeat until name of cwd is "Go.bbpackage"
			set cwd to (container of cwd as alias)
		end repeat
	end tell
	return POSIX path of (cwd as string)
end getPackageRoot

on exec(doc, cmd)
	tell application "BBEdit"
		if source language of doc is not "Go" then
			error "Not a Go source file"
		end if
	end tell

	if packageRoot is missing value then
		set packageRoot to getPackageRoot()
	end if

	set runner to quoted form of (POSIX path of (packageRoot as string) & "Contents/Resources/gorunner")
	set shellCmd to runner & space & "-d " & POSIX path of ((file of doc) as alias) & space & cmd
	return do shell script (shellCmd)
end exec

on execCommands(doc, commands)
	set output to {}
	repeat with cmd in commands
		set entry to exec(doc, cmd)
		if length of entry > 0 then
			copy entry to the end of output
		end if
	end repeat
	return output
end execCommands

on packagePath(doc)
	return quoted form of exec(doc, "go list")
end packagePath

-- Parse message into result browser entry
--
-- Format:
--     [/path/to/file]:[line]:(col): [message]
on makeEntry(itemData, cwd)
	try
		-- Get source path
		set src to text 1 thru ((offset of ":" in itemData) - 1) of itemData
		if src starts with "./" then
			set srcFile to POSIX file (cwd & text 3 thru -1 of src)
		else
			set srcFile to POSIX file (src)
		end if

		-- Get line:column
		set lineColumn to text ((offset of ":" in itemData) + 1) thru ((offset of ": " in itemData) - 1) of itemData
		set lineNumber to (text 1 thru ((offset of ":" in lineColumn) - 1) of lineColumn) as number
		set columnNumber to (text ((offset of ":" in lineColumn) + 1) thru -1 of lineColumn) as number

		-- Get message
		set msg to text ((offset of ": " in itemData) + 2) thru -1 of itemData

		tell application "BBEdit"
			set resultKind to error_kind

			-- TODO: Improve filter for warnings vs errors
			if "should" is in msg then
				set resultKind to warning_kind
			end if

			--	if resultType is "note" then
			--		set resultKind to note_kind
			--	else if resultType is "warning" then
			--		set resultKind to warning_kind
			--	else
			--		set resultKind to error_kind
			--	end if

			set entry to {result_kind:resultKind, result_file:srcFile, result_line:lineNumber, message:msg}
		end tell
		return entry
	on error msg
		log "Error: " & msg
		return missing value
	end try
end makeEntry

-- Filter and sort incoming messages
on prepareMessages(messages)
	set prevDelimiter to AppleScript's text item delimiters
	set AppleScript's text item delimiters to {ASCII character 10}
	set filteredString to do shell script ("echo " & quoted form of (messages as string) & " | sort -f | uniq")
	set AppleScript's text item delimiters to prevDelimiter
	return paragraphs of filteredString
end prepareMessages

on showResults(title, doc, messages)
	tell application "Finder"
		set cwd to POSIX path of ((container of (doc as alias) as string))
	end tell

	set errorList to {}
	set messageList to prepareMessages(messages)

	repeat with msg in messageList
		if msg does not start with "#" then
			set entry to makeEntry(msg, cwd)
			if entry is not missing value then
				copy entry to the end of errorList
			end if
		end if
	end repeat

	if (count of errorList) > 0 then
		try
			tell application "BBEdit"
				make new results browser with data errorList with properties {name:title}
			end tell
		on error msg
			log "Error: " & msg
		end try
	end if
end showResults

on handleDocumentDidSave(doc)
	try
		set docPath to POSIX path of ((file of doc) as string)
		set pkgPath to packagePath(doc)
		set goCommands to {"goimports -w " & quoted form of docPath, "golint " & quoted form of docPath, "go build", "go test"}
		set output to execCommands(doc, goCommands)
		if output is not missing value then
			showResults("Save " & (name of doc), POSIX file (docPath), output)
		end if
	on error msg
		log "Error handleDocumentDidSave: " & msg
	end try
end handleDocumentDidSave

(*
on run
	tell application "BBEdit" to set doc to active document of window 1
	handleDocumentDidSave(doc)
end run
*)

-- Go AppleScript library

property package : "Go"
property packageRoot : missing value

-- Get working directory for a given document
on getWorkingDirectory(doc)
	tell application "Finder"
		return POSIX path of ((container of ((file of doc) as alias) as string))
	end tell
end getWorkingDirectory

-- Find Go.bbpackage root
-- Assumption: this is *always* run from within the package!
on getPackageRoot()
	tell application "Finder"
		set cwd to ((container of (path to me)) as alias)
		repeat until name of cwd is "Go.bbpackage"
			set cwd to (container of cwd as alias)
		end repeat
	end tell
	return POSIX path of (cwd as string)
end getPackageRoot

on exec(doc, cmd)
	tell application "BBEdit"
		if source language of doc is not "Go" then
			error "Not a Go source file"
		end if
	end tell

	if packageRoot is missing value then
		set packageRoot to getPackageRoot()
	end if

	set runner to quoted form of (POSIX path of (packageRoot as string) & "Contents/Resources/gorunner")
	set shellCmd to runner & space & "-d " & POSIX path of ((file of doc) as alias) & space & cmd
	return do shell script (shellCmd)
end exec

on execCommands(doc, commands)
	set output to {}
	repeat with cmd in commands
		set entry to exec(doc, cmd)
		if length of entry > 0 then
			copy entry to the end of output
		end if
	end repeat
	return output
end execCommands

on packagePath(doc)
	return quoted form of exec(doc, "go list")
end packagePath

-- Parse message into result browser entry
--
-- Format:
--     [/path/to/file]:[line]:(col): [message]
on makeEntry(itemData, cwd)
	try
		-- Get source path
		set src to text 1 thru ((offset of ":" in itemData) - 1) of itemData
		if src starts with "./" then
			set srcFile to POSIX file (cwd & text 3 thru -1 of src)
		else
			set srcFile to POSIX file (src)
		end if

		-- Get line:column
		set lineColumn to text ((offset of ":" in itemData) + 1) thru ((offset of ": " in itemData) - 1) of itemData
		set lineNumber to (text 1 thru ((offset of ":" in lineColumn) - 1) of lineColumn) as number
		set columnNumber to (text ((offset of ":" in lineColumn) + 1) thru -1 of lineColumn) as number

		-- Get message
		set msg to text ((offset of ": " in itemData) + 2) thru -1 of itemData

		tell application "BBEdit"
			set resultKind to error_kind
			--	if resultType is "note" then
			--		set resultKind to note_kind
			--	else if resultType is "warning" then
			--		set resultKind to warning_kind
			--	else
			--		set resultKind to error_kind
			--	end if

			set entry to {result_kind:resultKind, result_file:srcFile, result_line:lineNumber, message:msg}
		end tell
		return entry
	on error msg
		log "Error: " & msg
		return missing value
	end try
end makeEntry

-- Filter and sort incoming messages
on prepareMessages(messages)
	set prevDelimiter to AppleScript's text item delimiters
	set AppleScript's text item delimiters to {ASCII character 10}
	set filteredString to do shell script ("echo " & quoted form of (messages as string) & " | sort -f | uniq")
	set AppleScript's text item delimiters to prevDelimiter
	return paragraphs of filteredString
end prepareMessages

on showResults(title, doc, messages)
	tell application "Finder"
		set cwd to POSIX path of ((container of (doc as alias) as string))
	end tell

	set errorList to {}
	set messageList to prepareMessages(messages)

	repeat with msg in messageList
		if msg does not start with "#" then
			set entry to makeEntry(msg, cwd)
			if entry is not missing value then
				copy entry to the end of errorList
			end if
		end if
	end repeat

	if (count of errorList) > 0 then
		try
			tell application "BBEdit"
				make new results browser with data errorList with properties {name:title}
			end tell
		on error msg
			log "Error: " & msg
		end try
	end if
end showResults

on handleDocumentDidSave(doc)
	try
		set docPath to POSIX path of ((file of doc) as string)
		set pkgPath to packagePath(doc)
		set goCommands to {"goimports -w " & quoted form of docPath, "golint " & quoted form of docPath, "go build", "go test"}
		set output to execCommands(doc, goCommands)
		if output is not missing value then
			showResults("Save " & (name of doc), POSIX file (docPath), output)
		end if
	on error msg
		log "Error handleDocumentDidSave: " & msg
	end try
end handleDocumentDidSave

(*
on run
	tell application "BBEdit" to set doc to active document of window 1
	handleDocumentDidSave(doc)
end run
*)


Added shellshock test

Added shellshock test

Cleaned up dns cache flushing for Yosemite, made OS version checking clearer, and added function to run some shellshock tests.

-- This is the master machq script to replace all others!
-- First find out the version of OS X

global osVersion
global externalIP
global SWUpdateServer
global store

set osVersion to do shell script "/usr/bin/sw_vers -productVersion | /usr/bin/awk -F . '{print $2}'"

try
	set externalIP to do shell script "/usr/bin/curl http://icanhazip.com/"

	set test1 to do shell script "/usr/bin/dig +short 001.machq.com"
	set test2 to do shell script "/usr/bin/dig +short 002.machq.com"
	set test3 to do shell script "/usr/bin/dig +short 003.machq.com"

	if externalIP is test1 then
		set store to "001"
		set SWUpdateServer to "mhq-swupdate.local:8088"
	else if externalIP is test2 then
		set store to "002"
		set SWUpdateServer to "xserve.local:8088"
	else if externalIP is test3 then
		set store to "003"
		set SWUpdateServer to "servercdr.local:8088"
	end if

on error
	--can't determine which store automatically
	set theStoreList to {"St. Louis", "O'Fallon", "Cedar Rapids"}
	set theStore to choose from list theStoreList with title "Help!" with prompt "Where are we?"

	if theStore as string is "St. Louis" then
		set SWUpdateServer to "mhq-swupdate.local:8088"
	else if theStore as string is "O'Fallon" then
		set SWUpdateServer to "xserve.local:8088"
	else if theStore as string is "Cedar Rapids" then
		set SWUpdateServer to "servercdr.local:8088"
	end if

end try

--display dialog osVersion buttons {"OK"}

--display dialog SWUpdateServer buttons {"OK"}

set theButtonNames to {"Set Used Prefs (all *'ed items)", "Set SWUpdateServer*", "List SWUpdateServer", "Remove SWUpdateServer", "Set MacHQ homepage*", "Disable Sleep*", "Rename HD by Size*", "Install MHQ Reset Script", "Remove Current User & Reset CPU", "Install Tech User Reset Script", "Test for Flashback Trojan", "Test for ShellShock vulnerability", "Rebuild Launch Services DB", "Flush DNS Cache", "Reinstall default Fake preferences", "Update Fake Workflows from Server", "Install SWUpdate StartupItem", "Save System Profiler Report to server"}

repeat
	set theChoice to choose from list theButtonNames
	if theChoice is false then
		exit repeat
	else if theChoice as string is "Set SWUpdateServer*" then
		setSWUpdateServer()
	else if theChoice as string is "List SWUpdateServer" then
		listSWUpdateServer()
	else if theChoice as string is "Remove SWUpdateServer" then
		resetSWUpdateServer()
	else if theChoice as string is "Set MacHQ homepage*" then
		setHomePage()
	else if theChoice as string is "Set Used Prefs (all *'ed items)" then
		setUsedPrefs()
	else if theChoice as string is "Disable Sleep*" then
		disableSleep()
	else if theChoice as string is "Rename HD by Size*" then
		renameHDbySize()
	else if theChoice as string is "Install MHQ Reset Script" then
		installResetScript()
	else if theChoice as string is "Remove MHQ User & Reset CPU" then
		if resetUserCPU() = -128 then
			return
		end if
	else if theChoice as string is "Remove Current User & Reset CPU" then
		if resetThisUserCPU() = -128 then
			return
		end if
	else if theChoice as string is "Install Tech User Reset Script" then
		installTechResetScript()
	else if theChoice as string is "Test for Flashback Trojan" then
		testForFlashbackTrojan()
	else if theChoice as string is "Rebuild Launch Services DB" then
		rebuildLaunchServicesDB()
	else if theChoice as string is "Reinstall default Fake preferences" then
		reinstallDefaultFakePreferences()
	else if theChoice as string is "Reinstall Fake Workflows" then
		reinstallFakeWorkflows()
	else if theChoice as string is "Install SWUpdate StartupItem" then
		InstallSWUpdatePlist()
	else if theChoice as string is "Flush DNS Cache" then
		FlushDNSCache()
	else if theChoice as string is "Save System Profiler Report to server" then
		SystemProfilerReport()
	else if theChoice as string is "Update Fake Workflows from Server" then
		UpdateWorkflowsFromServer()
	else if theChoice as string is "Test for ShellShock vulnerability" then
		testForShellShockVulnerability()
	else
		tell me to quit
	end if

end repeat

on setUsedPrefs()
	disableSleep()
	setSWUpdateServer()
	setHomePage()
	renameHDbySize()
end setUsedPrefs

on setHomePage()
	set fileTarget to (path to library folder from user domain as text) & "Preferences:com.apple.Safari.plist"

	try
		-- we don't really need the alias; we're just checking to see if it exists
		fileTarget as alias
	on error
		tell application "Safari"
			activate
		end tell
	end try
	if running of application "Safari" then
		tell application "Safari"
			quit
		end tell
		repeat while (running of application "Safari")
			delay 1
		end repeat
		delay 2
	end if
	do shell script "defaults write com.apple.Safari HomePage http://twitter.com/machq; defaults write com.apple.Safari NewWindowBehavior 0"
	delay 2
	tell application "Safari"
		activate
		delay 2
		close every window
		quit
	end tell
end setHomePage

on listSWUpdateServer()
	try
		set server_name to do shell script "defaults read /Library/Preferences/com.apple.SoftwareUpdate CatalogURL"
		display dialog "SW update server is: " & server_name buttons {"OK"}
	on error
		display dialog "Using default Apple SW Update Server" buttons {"OK"}
	end try
end listSWUpdateServer

on resetSWUpdateServer()
	try
		--if running in 10.7 or later we need to supply password

		if (osVersion as number > 7) then
			do shell script "defaults delete /Library/Preferences/com.apple.SoftwareUpdate CatalogURL" with administrator privileges
		else
			do shell script "/usr/bin/defaults delete /Library/Preferences/com.apple.SoftwareUpdate CatalogURL"
		end if

		--do shell script "defaults delete /Library/Preferences/com.apple.SoftwareUpdate CatalogURL"
	end try
end resetSWUpdateServer

on disableSleep()
	try
		do shell script "pmset -c displaysleep 0 sleep 0 disksleep 0" with administrator privileges
	end try
end disableSleep

on renameHDbySize()
	set theSetScript to "

#!/bin/bash

boot_vol=`bless --getBoot`

boot_disk=`diskutil info ${boot_vol} |sed '/^ *Volume Name: */!d;s###'`

disk_size=`system_profiler SPSerialATADataType |sed '/^ *Capacity: */!d;s###' | awk '{print int($1+0.5)  $2\" HD\"}' | head -n 1 `

diskutil rename \"${boot_disk}\" \"${disk_size}\"

# Show icons for hard drives, servers, and removable media on the desktop
#defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true
#defaults write com.apple.finder ShowMountedServersOnDesktop -bool true
#defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true

killall Finder

"
	do shell script theSetScript

end renameHDbySize

on setSWUpdateServer()

	set theSetScript to "

#!/bin/bash

URL1='http://" & SWUpdateServer & "'
    case `/usr/bin/sw_vers -productVersion | /usr/bin/awk -F . '{print $2}'` in
      4) URL=\"${URL1}/index.sucatalog\" ;;
      5) URL=\"${URL1}/index-leopard.merged-1.sucatalog\" ;;
      6) URL=\"${URL1}/index-leopard-snowleopard.merged-1.sucatalog\" ;;
	7) URL=\"${URL1}/index-lion-snowleopard-leopard.merged-1.sucatalog\" ;;
	8) URL=\"${URL1}/index-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog\" ;;
	9) URL=\"${URL1}/index-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog\" ;;
	10) URL=\"${URL1}/index-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog\" ;;
      *) echo \"Unsupported client OS\"; exit 1 ;;
    esac

/usr/bin/defaults write /Library/Preferences/com.apple.SoftwareUpdate CatalogURL \"${URL}\"

	"
	--if running in 10.7 or 10.8 we need to supply password
	try
		if (osVersion as number > 7) then
			do shell script theSetScript with administrator privileges
		else
			do shell script theSetScript
		end if
	end try
end setSWUpdateServer

on installResetScript()
	try
		set TheFile to ((path to me as string) & "Contents:Resources:mhqreset.sh") as alias
		tell application "Finder"
			duplicate TheFile to the startup disk with replacing
		end tell
	end try
end installResetScript

on resetUserCPU()
	try
		display dialog "This will install the MHQ reset script and restart the computer into single user mode, then run the reset script automatically. Do you wish to continue?" buttons {"Quit", "Continue"} default button "Continue" cancel button "Quit"
		installResetScript()
		if osVersion is "10" then
			do shell script "echo \"sh /mhqreset.sh\" >> /private/var/root/.bashrc" with administrator privileges
		else
			do shell script "echo \"sh /mhqreset.sh\" >> /private/var/root/.profile" with administrator privileges
		end if
		do shell script "nvram boot-args=\"-s\"" with administrator privileges
		tell application "Finder" to restart
		return -128
	end try
end resetUserCPU

on resetThisUserCPU()
	try
		tell application "System Events"
			set current_user to get the name of current user
		end tell

		display dialog "This will install the MHQ reset script and restart the computer into single user mode, then run the reset script automatically. The user \"" & current_user & "\" will be deleted with all it's files. Do you wish to continue?" buttons {"Quit", "Continue"} default button "Continue" cancel button "Quit"
		display dialog "Are you absolutely certain?. The user \"" & current_user & "\" will be deleted with all it's files. Do you wish to continue?" buttons {"Quit", "Continue"} default button "Continue" cancel button "Quit"
		installResetScript()
		if osVersion is "10" then
			do shell script "echo \"sh /mhqreset.sh\" >> /private/var/root/.bashrc" with administrator privileges
		else
			do shell script "echo \"sh /mhqreset.sh\" >> /private/var/root/.profile" with administrator privileges
		end if
		do shell script "nvram boot-args=\"-s\"" with administrator privileges
		tell application "Finder" to restart
		return -128
	end try
end resetThisUserCPU

on installTechResetScript()
	set TheFile to ((path to me as string) & "Contents:Resources:techreset.sh") as alias
	tell application "Finder"
		duplicate TheFile to the startup disk with replacing
	end tell

end installTechResetScript

on InstallSWUpdatePlist()

	set TheFile to ((path to me as string) & "Contents:Resources:Set SWUpdate Server") as alias

	if (osVersion as number > 7) then

		tell application "Finder"
			duplicate TheFile to (path to startup items from local domain as alias) with replacing
		end tell
	else

		set theScript to "

		#!/bin/bash

		if [ ! -e '/Library/StartupItems/Set SWUpdate Server' ]; then
		    mkdir '/Library/StartupItems/Set SWUpdate Server'
		fi
		cp -R '" & (the POSIX path of TheFile) & "' '/Library/StartupItems/Set SWUpdate Server/.'
		"
		do shell script theScript with administrator privileges

	end if

	do shell script "chmod -R 755 '/Library/StartupItems/Set SWUpdate Server'; sudo chown -R root:wheel '/Library/StartupItems/Set SWUpdate Server'" with administrator privileges

end InstallSWUpdatePlist

on testForFlashbackTrojan()
	display alert ("Beginning test") message "Testing for presence of Flashback trojan. Keep in mind this is NOT a definitive test!"

	try
		set check1 to do shell script "defaults read /Applications/Safari.app/Contents/Info LSEnvironment"
		display alert ("Possible infection!") message "Recommend running full antivirus scan with up to date scanner. Please note this test is a first release and may produce false positives."

	on error error_message number error_number
		if error_number is equal to 1 then
			display alert ("Alert!") message "First check appears okay"
		end if
	end try

	try
		set check2 to do shell script "defaults read ~/.MacOSX/environment DYLD_INSERT_LIBRARIES"
		display alert ("Possible infection!") message "Recommend running full antivirus scan with up to date scanner. Please note this test is a first release and may produce false positives."

	on error error_message number error_number
		if error_number is equal to 1 then
			display alert ("Alert!") message "Second check appears okay"
		end if
	end try
end testForFlashbackTrojan

on rebuildLaunchServicesDB()
	display alert ("Alert!") message "The Finder must be quit and will relaunch when complete."

	try
		tell application "Finder" to quit
		do shell script "/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user"
		tell application "Finder" to activate

	end try
end rebuildLaunchServicesDB

on reinstallDefaultFakePreferences()
	set TheFile to ((path to me as string) & "Contents:Resources:com.fakeapp.Fake.plist") as alias
	tell application "Finder"
		duplicate TheFile to ((path to preferences folder) as alias) with replacing
	end tell
	set theSetScript to "
#!/bin/bash

defaults delete com.fakeapp.Fake \"FUWindowFrameString\"
defaults delete com.fakeapp.Fake \"NSWindow Frame ActionLibrary\"
defaults delete com.fakeapp.Fake \"NSWindow Frame FUWindow\"
defaults delete com.fakeapp.Fake \"NSWindow Frame Preferences\"
defaults delete com.fakeapp.Fake \"WebDatabaseDirectory\"
defaults write com.fakeapp.Fake \"FakeDelayBetweenRunningActions\" '0'
"
	do shell script theSetScript

end reinstallDefaultFakePreferences

on reinstallFakeWorkflows()
	set oldFolder to (path to application support from user domain as text) & "Fake:Workflows:"
	set fakeFolder to (path to application support from user domain as text) & "Fake:"
	set newFolder to ((path to me as string) & "Contents:Resources:Workflows") as alias
	--	display dialog oldFolder buttons {"OK"}
	tell application "Finder"
		try
			delete oldFolder
		end try
		duplicate newFolder to fakeFolder
	end tell
end reinstallFakeWorkflows

on FlushDNSCache()
	set theSetScript to "

#!/bin/bash

case `/usr/bin/sw_vers -productVersion | /usr/bin/awk -F . '{print $2}'` in
    4) lookupd -flushcache ;;
   [56]) dscacheutil -flushcache ;;
    [78]) sudo killall -HUP mDNSResponder ;;
    9) dscacheutil -flushcache; sudo killall -HUP mDNSResponder ;;
  10) dscacheutil -flushcache; sudo discoveryutil mdnsflushcache ;;
      *) echo \"Unsupported client OS\"; exit 1 ;;
esac

	"
	--if running in 10.7 or 10.8 we need to supply password

	if (osVersion as number > 7) then
		do shell script theSetScript with administrator privileges
	else
		do shell script theSetScript
	end if
end FlushDNSCache

on SystemProfilerReport()

	if (store = "001") then
		set destination to "/Volumes/MHQ/Backed Up/System Profiler Reports/"
		set dest_volume to "afp://mhq-swupdate.local/MHQ"
	else if (store = "002") then
		set destination to "/Volumes/Service/System Profiler Reports/"
		set dest_volume to "afp://xserve.local/Service"
	else if (store = "003") then
		set destination to "/Volumes/Service/System Profiler Reports/"
		set dest_volume to "afp://servercdr.local/Service"
	end if

	--	display dialog oldFolder

	tell application "Finder"
		try
			mount volume dest_volume
		on error
			return "Error mounting server volume \"" & dest_volume & "\". Please connect to server manually and try again."
			tell me to quit
		end try
	end tell

	--this shell script will generate a system profiler report and save it to the server
	do shell script "#!/bin/sh

# the location includes a folder based on the date in yyyy-mm-dd format
report_location=\"" & destination & "`date \"+%Y-%m-%d\"`/\"

if [ ! -d \"${report_location}\" ]; then
	mkdir \"${report_location}\"
fi

serial=`system_profiler SPHardwareDataType | grep \"Serial Number\" | awk  '{print $4}'`

SPDataTypes=\"SPHardwareDataType SPMemoryDataType SPPowerDataType SPSerialATADataType SPSoftwareDataType SPThunderboltDataType SPUSBDataType SPAirPortDataType SPFireWireDataType SPParallelATADataType SPAudioDataType SPBluetoothDataType SPNetworkDataType\"

system_profiler -xml $SPDataTypes > $report_location$serial\".spx\"
"

end SystemProfilerReport

on UpdateWorkflowsFromServer()

	set destination to POSIX path of ((path to application support from user domain as text) & "Fake:Workflows:")

	if (store = "001") then
		set source to "/Volumes/MHQ/Backed Up/Retail Stuff/Current Workflows/"
		set dest_volume to "afp://mhq-swupdate.local/MHQ"
	else if (store = "002") then
		set source to "/Volumes/Retail/Current Workflows/"
		set dest_volume to "afp://xserve.local/Retail"
	else if (store = "003") then
		set source to "/Volumes/Retail/Current Workflows/"
		set dest_volume to "afp://servercdr.local/Retail"
	end if

	--	display dialog oldFolder buttons {"OK"}

	tell application "Finder"
		try
			mount volume dest_volume
		on error
			return "Error mounting server volume \"" & dest_volume & "\". Please connect to server manually and try again."
			tell me to quit
		end try
	end tell

	try
		set theScript to "
	#!/bin/bash

	/usr/bin/rsync -a '" & source & "' '" & destination & "'
	" --shell script

		do shell script theScript --with administrator privileges
	on error
		return "Error syncronizing folders."
	end try

end UpdateWorkflowsFromServer

on testForShellShockVulnerability()

	set test_1 to "
#!/bin/bash

EXPLOIT_1=`env x='() { :;}; echo vulnerable' bash -c \"echo this is a test\"`
if [ \"${EXPLOIT_1}\" = \"vulnerable\" ]; then
    echo \"Test 1 (CVE-2014-6271):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 1 (CVE-2014-6271):	Machine doesn't appear to be vulnerable\"
fi
"
	set test_2 to "
#!/bin/bash

EXPLOIT_2=`env X='() { (shellshocker.net)=>\\' bash -c \"echo date\"; cat echo; rm ./echo `
if [ \"${EXPLOIT_2}\" != \"date\" ]; then
    echo \"Test 2 (CVE-2014-7169):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 2 (CVE-2014-7169):	Machine doesn't appear to be vulnerable\"
fi
"
	set test_3 to "
#!/bin/bash

EXPLOIT_3=`env X=' () { }; echo hello' bash -c 'date'`
if [ \"${EXPLOIT_3}\" = \"hello\" ]; then
    echo \"Test 3 (CVE-??):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 3 (CVE-??):	Machine doesn't appear to be vulnerable\"
fi

"

	set test_4 to "
#!/bin/bash

EXPLOIT_4=`bash -c 'true <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF' || echo \"CVE-2014-7186 vulnerable, redir_stack\"`
if [ \"${EXPLOIT_4}\" = \"CVE-2014-7186 vulnerable, redir_stack\" ]; then
    echo \"Test 4 (CVE-2014-7186):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 4 (CVE-2014-7186):	Machine doesn't appear to be vulnerable\"
fi

"

	set test_5 to "
#!/bin/bash

EXPLOIT_5=`(for x in {1..200} ; do echo \"for x$x in ; do :\"; done; for x in {1..200} ; do echo done ; done) | bash || echo \"CVE-2014-7187 vulnerable, word_lineno\"`
if [ \"${EXPLOIT_5}\" = \"CVE-2014-7187 vulnerable, word_lineno\" ]; then
    echo \"Test 5 (CVE-2014-7187):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 5 (CVE-2014-7187):	Machine doesn't appear to be vulnerable\"
fi

"
	set test_6 to "
#!/bin/bash

EXPLOIT_6=`shellshocker='() { echo You are vulnerable; }' bash -c shellshocker`
if [ \"${EXPLOIT_6}\" = \"You are vulnerable\" ]; then
    echo \"Test 6 (CVE-2014-6278):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 6 (CVE-2014-6278):	Machine doesn't appear to be vulnerable\"
fi

"
	set test_7 to "
#!/bin/bash

EXPLOIT_7=`bash -c \"f() { x() { _;}; x() { _;} <<a; }\" 2>/dev/null || echo vulnerable`
if [ \"${EXPLOIT_7}\" = \"vulnerable\" ]; then
    echo \"Test 7 (CVE-2014-6277):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 7 (CVE-2014-6277):	Machine doesn't appear to be vulnerable\"
fi

"

	set result_1 to do shell script test_1
	set result_2 to do shell script test_2
	set result_3 to do shell script test_3
	set result_4 to do shell script test_4
	set result_5 to do shell script test_5
	set result_6 to do shell script test_6
	set result_7 to do shell script test_7

	try
		display dialog result_1 & return & result_2 & return & result_3 & return & result_4 & return & result_6 & return & result_6 & return & result_7 & return buttons {"OK"}
	end try
end testForShellShockVulnerability

-- This is the master machq script to replace all others!
-- First find out the version of OS X

global osVersion
global externalIP
global SWUpdateServer
global store

set osVersion to do shell script "/usr/bin/sw_vers -productVersion | /usr/bin/awk -F . '{print $2}'"

try
	set externalIP to do shell script "/usr/bin/curl http://icanhazip.com/"

	set test1 to do shell script "/usr/bin/dig +short 001.machq.com"
	set test2 to do shell script "/usr/bin/dig +short 002.machq.com"
	set test3 to do shell script "/usr/bin/dig +short 003.machq.com"

	if externalIP is test1 then
		set store to "001"
		set SWUpdateServer to "mhq-swupdate.local:8088"
	else if externalIP is test2 then
		set store to "002"
		set SWUpdateServer to "xserve.local:8088"
	else if externalIP is test3 then
		set store to "003"
		set SWUpdateServer to "servercdr.local:8088"
	end if

on error
	--can't determine which store automatically
	set theStoreList to {"St. Louis", "O'Fallon", "Cedar Rapids"}
	set theStore to choose from list theStoreList with title "Help!" with prompt "Where are we?"

	if theStore as string is "St. Louis" then
		set SWUpdateServer to "mhq-swupdate.local:8088"
	else if theStore as string is "O'Fallon" then
		set SWUpdateServer to "xserve.local:8088"
	else if theStore as string is "Cedar Rapids" then
		set SWUpdateServer to "servercdr.local:8088"
	end if

end try

--display dialog osVersion

--display dialog SWUpdateServer

set theButtonNames to {"Set Used Prefs (all *'ed items)", "Set SWUpdateServer*", "List SWUpdateServer", "Remove SWUpdateServer", "Set MacHQ homepage*", "Disable Sleep*", "Rename HD by Size*", "Install MHQ Reset Script", "Remove MHQ User & Reset CPU", "Remove Current User & Reset CPU", "Install Tech User Reset Script", "Test for Flashback Trojan", "Rebuild Launch Services DB", "Flush DNS Cache", "Reinstall default Fake preferences", "Update Fake Workflows from Server", "Install SWUpdate StartupItem", "Save System Profiler Report to server"}

repeat
	set theChoice to choose from list theButtonNames
	if theChoice is false then
		exit repeat
	else if theChoice as string is "Set SWUpdateServer*" then
		setSWUpdateServer()
	else if theChoice as string is "List SWUpdateServer" then
		listSWUpdateServer()
	else if theChoice as string is "Remove SWUpdateServer" then
		resetSWUpdateServer()
	else if theChoice as string is "Set MacHQ homepage*" then
		setHomePage()
	else if theChoice as string is "Set Used Prefs (all *'ed items)" then
		setUsedPrefs()
	else if theChoice as string is "Disable Sleep*" then
		disableSleep()
	else if theChoice as string is "Rename HD by Size*" then
		renameHDbySize()
	else if theChoice as string is "Install MHQ Reset Script" then
		installResetScript()
	else if theChoice as string is "Remove MHQ User & Reset CPU" then
		if resetUserCPU() = -128 then
			return
		end if
	else if theChoice as string is "Remove Current User & Reset CPU" then
		if resetThisUserCPU() = -128 then
			return
		end if
	else if theChoice as string is "Install Tech User Reset Script" then
		installTechResetScript()
	else if theChoice as string is "Test for Flashback Trojan" then
		testForFlashbackTrojan()
	else if theChoice as string is "Rebuild Launch Services DB" then
		rebuildLaunchServicesDB()
	else if theChoice as string is "Reinstall default Fake preferences" then
		reinstallDefaultFakePreferences()
	else if theChoice as string is "Reinstall Fake Workflows" then
		reinstallFakeWorkflows()
	else if theChoice as string is "Install SWUpdate StartupItem" then
		InstallSWUpdatePlist()
	else if theChoice as string is "Flush DNS Cache" then
		FlushDNSCache()
	else if theChoice as string is "Save System Profiler Report to server" then
		SystemProfilerReport()
	else if theChoice as string is "Update Fake Workflows from Server" then
		UpdateWorkflowsFromServer()
	else
		tell me to quit
	end if

end repeat

on setUsedPrefs()
	disableSleep()
	setSWUpdateServer()
	setHomePage()
	renameHDbySize()
end setUsedPrefs

on setHomePage()
	set fileTarget to (path to library folder from user domain as text) & "Preferences:com.apple.Safari.plist"

	try
		-- we don't really need the alias; we're just checking to see if it exists
		fileTarget as alias
	on error
		tell application "Safari"
			activate
		end tell
	end try
	if running of application "Safari" then
		tell application "Safari"
			quit
		end tell
		repeat while (running of application "Safari")
			delay 1
		end repeat
		delay 2
	end if
	do shell script "defaults write com.apple.Safari HomePage http://twitter.com/machq; defaults write com.apple.Safari NewWindowBehavior 0"
	delay 2
	tell application "Safari"
		activate
		delay 2
		close every window
		quit
	end tell
end setHomePage

on listSWUpdateServer()
	try
		set server_name to do shell script "defaults read /Library/Preferences/com.apple.SoftwareUpdate CatalogURL"
		display dialog "SW update server is: " & server_name
	on error
		display dialog "Using default Apple SW Update Server"
	end try
end listSWUpdateServer

on resetSWUpdateServer()
	try
		--if running in 10.7 or later we need to supply password

		if (osVersion < "7" and osVersion > "3") then
			do shell script "/usr/bin/defaults delete /Library/Preferences/com.apple.SoftwareUpdate CatalogURL"
		else
			do shell script "defaults delete /Library/Preferences/com.apple.SoftwareUpdate CatalogURL" with administrator privileges
		end if

		--do shell script "defaults delete /Library/Preferences/com.apple.SoftwareUpdate CatalogURL"
	end try
end resetSWUpdateServer

on disableSleep()
	try
		do shell script "pmset -c displaysleep 0 sleep 0 disksleep 0" with administrator privileges
	end try
end disableSleep

on renameHDbySize()
	set theSetScript to "

#!/bin/bash

boot_vol=`bless --getBoot`

boot_disk=`diskutil info ${boot_vol} |sed '/^ *Volume Name: */!d;s###'`

disk_size=`system_profiler SPSerialATADataType |sed '/^ *Capacity: */!d;s###' | awk '{print int($1+0.5)  $2\" HD\"}' | head -n 1 `

diskutil rename \"${boot_disk}\" \"${disk_size}\"

# Show icons for hard drives, servers, and removable media on the desktop
#defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true
#defaults write com.apple.finder ShowMountedServersOnDesktop -bool true
#defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true

killall Finder

"
	do shell script theSetScript

end renameHDbySize

on setSWUpdateServer()

	set theSetScript to "

#!/bin/bash

URL1='http://" & SWUpdateServer & "'
    case `/usr/bin/sw_vers -productVersion | /usr/bin/awk -F . '{print $2}'` in
      4) URL=\"${URL1}/index.sucatalog\" ;;
      5) URL=\"${URL1}/index-leopard.merged-1.sucatalog\" ;;
      6) URL=\"${URL1}/index-leopard-snowleopard.merged-1.sucatalog\" ;;
	7) URL=\"${URL1}/index-lion-snowleopard-leopard.merged-1.sucatalog\" ;;
	8) URL=\"${URL1}/index-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog\" ;;
	9) URL=\"${URL1}/index-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog\" ;;
	10) URL=\"${URL1}/index-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog\" ;;
      *) echo \"Unsupported client OS\"; exit 1 ;;
    esac

/usr/bin/defaults write /Library/Preferences/com.apple.SoftwareUpdate CatalogURL \"${URL}\"

	"
	--if running in 10.7 or 10.8 we need to supply password

	if (osVersion < "7" and osVersion > "3") then
		do shell script theSetScript
	else
		do shell script theSetScript with administrator privileges
	end if

end setSWUpdateServer

on installResetScript()
	try
		set TheFile to ((path to me as string) & "Contents:Resources:mhqreset.sh") as alias
		tell application "Finder"
			duplicate TheFile to the startup disk with replacing
		end tell
	end try
end installResetScript

on resetUserCPU()
	try
		display dialog "This will install the MHQ reset script and restart the computer into single user mode, then run the reset script automatically. Do you wish to continue?" buttons {"Quit", "Continue"} default button "Continue" cancel button "Quit"
		installResetScript()
		if osVersion is "10" then
			do shell script "echo \"sh /mhqreset.sh\" >> /private/var/root/.bashrc" with administrator privileges
		else
			do shell script "echo \"sh /mhqreset.sh\" >> /private/var/root/.profile" with administrator privileges
		end if
		do shell script "nvram boot-args=\"-s\"" with administrator privileges
		tell application "Finder" to restart
		return -128
	end try
end resetUserCPU

on resetThisUserCPU()
	try
		tell application "System Events"
			set current_user to get the name of current user
		end tell

		display dialog "This will install the MHQ reset script and restart the computer into single user mode, then run the reset script automatically. The user \"" & current_user & "\" will be deleted with all it's files. Do you wish to continue?" buttons {"Quit", "Continue"} default button "Continue" cancel button "Quit"
		display dialog "Are you absolutely certain?. The user \"" & current_user & "\" will be deleted with all it's files. Do you wish to continue?" buttons {"Quit", "Continue"} default button "Continue" cancel button "Quit"
		installResetScript()
		if osVersion is "10" then
			do shell script "echo \"sh /mhqreset.sh\" >> /private/var/root/.bashrc" with administrator privileges
		else
			do shell script "echo \"sh /mhqreset.sh\" >> /private/var/root/.profile" with administrator privileges
		end if
		do shell script "nvram boot-args=\"-s\"" with administrator privileges
		tell application "Finder" to restart
		return -128
	end try
end resetThisUserCPU

on installTechResetScript()
	set TheFile to ((path to me as string) & "Contents:Resources:techreset.sh") as alias
	tell application "Finder"
		duplicate TheFile to the startup disk with replacing
	end tell

end installTechResetScript

on InstallSWUpdatePlist()

	set TheFile to ((path to me as string) & "Contents:Resources:Set SWUpdate Server") as alias

	if (osVersion < "7" and osVersion > "3") then
		set theScript to "

		#!/bin/bash

		if [ ! -e '/Library/StartupItems/Set SWUpdate Server' ]; then
		    mkdir '/Library/StartupItems/Set SWUpdate Server'
		fi
		cp -R '" & (the POSIX path of TheFile) & "' '/Library/StartupItems/Set SWUpdate Server/.'
		"
		do shell script theScript with administrator privileges

	else
		tell application "Finder"
			duplicate TheFile to (path to startup items from local domain as alias) with replacing
		end tell
	end if

	do shell script "chmod -R 755 '/Library/StartupItems/Set SWUpdate Server'; sudo chown -R root:wheel '/Library/StartupItems/Set SWUpdate Server'" with administrator privileges

end InstallSWUpdatePlist

on testForFlashbackTrojan()
	display alert ("Beginning test") message "Testing for presence of Flashback trojan. Keep in mind this is NOT a definitive test!"

	try
		set check1 to do shell script "defaults read /Applications/Safari.app/Contents/Info LSEnvironment"
		display alert ("Possible infection!") message "Recommend running full antivirus scan with up to date scanner. Please note this test is a first release and may produce false positives."

	on error error_message number error_number
		if error_number is equal to 1 then
			display alert ("Alert!") message "First check appears okay"
		end if
	end try

	try
		set check2 to do shell script "defaults read ~/.MacOSX/environment DYLD_INSERT_LIBRARIES"
		display alert ("Possible infection!") message "Recommend running full antivirus scan with up to date scanner. Please note this test is a first release and may produce false positives."

	on error error_message number error_number
		if error_number is equal to 1 then
			display alert ("Alert!") message "Second check appears okay"
		end if
	end try
end testForFlashbackTrojan

on rebuildLaunchServicesDB()
	display alert ("Alert!") message "The Finder must be quit and will relaunch when complete."

	try
		tell application "Finder" to quit
		do shell script "/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user"
		tell application "Finder" to activate

	end try
end rebuildLaunchServicesDB

on reinstallDefaultFakePreferences()
	set TheFile to ((path to me as string) & "Contents:Resources:com.fakeapp.Fake.plist") as alias
	tell application "Finder"
		duplicate TheFile to ((path to preferences folder) as alias) with replacing
	end tell
	set theSetScript to "
#!/bin/bash

defaults delete com.fakeapp.Fake \"FUWindowFrameString\"
defaults delete com.fakeapp.Fake \"NSWindow Frame ActionLibrary\"
defaults delete com.fakeapp.Fake \"NSWindow Frame FUWindow\"
defaults delete com.fakeapp.Fake \"NSWindow Frame Preferences\"
defaults delete com.fakeapp.Fake \"WebDatabaseDirectory\"
defaults write com.fakeapp.Fake \"FakeDelayBetweenRunningActions\" '0'
"
	do shell script theSetScript

end reinstallDefaultFakePreferences

on reinstallFakeWorkflows()
	set oldFolder to (path to application support from user domain as text) & "Fake:Workflows:"
	set fakeFolder to (path to application support from user domain as text) & "Fake:"
	set newFolder to ((path to me as string) & "Contents:Resources:Workflows") as alias
	--	display dialog oldFolder
	tell application "Finder"
		try
			delete oldFolder
		end try
		duplicate newFolder to fakeFolder
	end tell
end reinstallFakeWorkflows

on FlushDNSCache()
	set theSetScript to "

#!/bin/bash

case `/usr/bin/sw_vers -productVersion | /usr/bin/awk -F . '{print $2}'` in
    4) lookupd -flushcache ;;
   [56]) dscacheutil -flushcache ;;
    [78]) sudo killall -HUP mDNSResponder ;;
    9 | 10) dscacheutil -flushcache;sudo killall -HUP mDNSResponder ;;
      *) echo \"Unsupported client OS\"; exit 1 ;;
esac

	"
	--if running in 10.7 or 10.8 we need to supply password

	if (osVersion < "7" and osVersion > "3") then
		do shell script theSetScript
	else
		do shell script theSetScript with administrator privileges
	end if
end FlushDNSCache

on SystemProfilerReport()

	if (store = "001") then
		set destination to "/Volumes/MHQ/Backed Up/System Profiler Reports/"
		set dest_volume to "afp://mhq-swupdate.local/MHQ"
	else if (store = "002") then
		set destination to "/Volumes/Service/System Profiler Reports/"
		set dest_volume to "afp://xserve.local/Service"
	else if (store = "003") then
		set destination to "/Volumes/Service/System Profiler Reports/"
		set dest_volume to "afp://servercdr.local/Service"
	end if

	--	display dialog oldFolder

	tell application "Finder"
		try
			mount volume dest_volume
		on error
			return "Error mounting server volume \"" & dest_volume & "\". Please connect to server manually and try again."
			tell me to quit
		end try
	end tell

	--this shell script will generate a system profiler report and save it to the server
	do shell script "#!/bin/sh

# the location includes a folder based on the date in yyyy-mm-dd format
report_location=\"" & destination & "`date \"+%Y-%m-%d\"`/\"

if [ ! -d \"${report_location}\" ]; then
	mkdir \"${report_location}\"
fi

serial=`system_profiler SPHardwareDataType | grep \"Serial Number\" | awk  '{print $4}'`

SPDataTypes=\"SPHardwareDataType SPMemoryDataType SPPowerDataType SPSerialATADataType SPSoftwareDataType SPThunderboltDataType SPUSBDataType SPAirPortDataType SPFireWireDataType SPParallelATADataType SPAudioDataType SPBluetoothDataType SPNetworkDataType\"

system_profiler -xml $SPDataTypes > $report_location$serial\".spx\"
"

end SystemProfilerReport

on UpdateWorkflowsFromServer()

	set destination to POSIX path of ((path to application support from user domain as text) & "Fake:Workflows:")

	if (store = "001") then
		set source to "/Volumes/MHQ/Backed Up/Retail Stuff/Current Workflows/"
		set dest_volume to "afp://mhq-swupdate.local/MHQ"
	else if (store = "002") then
		set source to "/Volumes/Retail/Current Workflows/"
		set dest_volume to "afp://xserve.local/Retail"
	else if (store = "003") then
		set source to "/Volumes/Retail/Current Workflows/"
		set dest_volume to "afp://servercdr.local/Retail"
	end if

	--	display dialog oldFolder

	tell application "Finder"
		try
			mount volume dest_volume
		on error
			return "Error mounting server volume \"" & dest_volume & "\". Please connect to server manually and try again."
			tell me to quit
		end try
	end tell

	try
		set theScript to "
	#!/bin/bash

	/usr/bin/rsync -a '" & source & "' '" & destination & "'
	" --shell script

		do shell script theScript --with administrator privileges
	on error
		return "Error syncronizing folders."
	end try

end UpdateWorkflowsFromServer


Fixed first run check.

Fixed first run check.

A typo in the plist file path prevented isTheFirstRun() from returning
the correct value.

property debug : false
property currentVolume : null
property idleTime: 0.3

if (isTheFirstRun() and not isInLoginItems()) then
    set userAnswer to the button returned of (display dialog "Hi, thanks for installing Spotifree!" & ¬
        return & "Just so you know, Spotifree has no interface yet, and will work silently in the background." & return & return ¬
        & "BTW, do you want it to run automatically on startup?" with title ¬
        "You are awesome!" with icon 1 buttons {"No, thanks", "OK"} default button 2)
    if (userAnswer = "OK") then
        try
            my addToLoginItems()
        end try
    end if
    try
        -- Save in the preferences that Spotifree has already ran.
        do shell script "defaults write com.ArtemGordinsky.Spotifree 'hasRanBefore' 'true'"
    end try
end if

on idle
    try
        -- Adding a 5 seconds timeout instead of default 2 min. Prevents long unresponsiveness of the app.
        with timeout of (5) seconds
            if (isRunning() and isPlaying() and isAnAd()) then
                try
                    mute()
					set idleTime to 0.3
                end try
                repeat
                    set idleTime to 0.3
                    try
                        if (isRunning() and not isAnAd()) then
                            -- Have to delay a little bit, because Spotify may tell us about the next track too early,
                            -- and a user may to hear the last half-second of an ad.
                            delay 0.8
                            unmute()
                            exit repeat
                        end if
                    end try
                end repeat
            else
                -- Delaying, to get less of the crashing "connection is invalid" errors.
                set idleTime to 1
            end if
        end timeout
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "Somewhere in the outer loop.")
    end try
    -- This is how fast we are polling Spotify.
    -- The only speed at which you will hear almost no sounds passing through.
    -- Fortunately, even combined with the added load on Spotify, the CPU usage is rather miniscule.
    return idleTime
end idle

on mute()
    try
        tell application "Spotify"
            set currentVolume to sound volume
            -- This is the only way possible to mute Spotify during an advertisement.
            -- Otherwise it pauses when you mute the sound.
            pause
            set sound volume to 0
            play
        end tell
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "mute()")
    end try
    return
end mute

on unmute()
    try
        tell application "Spotify"
            -- Restore the volume to the level supplied to the parameter.
            set sound volume to currentVolume
        end tell
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "unmute()")
    end try
    return
end unmute

on isAnAd()
    local currentTrackPopularity, currentTrackDuration
    set currentTrackPopularity to null
    set currentTrackDuration to null
    # Nesting "try" blocks is the only way to handle multiple errors in AppleScript
    try
        try
            try
                tell application "Spotify"
                    set currentTrackPopularity to popularity of current track
                    set currentTrackDuration to duration of current track
                end tell
            on error number -1728
                # Ignoring "can't get current track" error
            end try
        on error number -609
            # Ignoring the "invalid connection errors"
        end try
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "isAnAd()")
        return false
    end try
    if ((currentTrackPopularity ≠ null and currentTrackDuration ≠ null) and (currentTrackPopularity = 0 and currentTrackDuration ≤ 40)) then
        return true
    else
        return false
    end if
end isAnAd

on isPlaying()
    local playerState
    set playerState to null
    # Nesting "try" blocks is the only way to handle multiple errors in AppleScript
    try
        try
            tell application "Spotify"
                set playerState to player state
            end tell
        on error -609
            # Ignoring the "invalid connection" errors
        end try
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "isRunning()")
        return false
    end try
    if (playerState ≠ null and playerState = «constant ****kPSP») then
        return true
    else
        return false
    end if
end isPlaying

on isRunning()
    local spotifyProcesses
    # Nesting "try" blocks is the only way to handle multiple errors in AppleScript
    try
        try
            tell application "System Events"
                set spotifyProcesses to (count of (every process whose name is "Spotify"))
            end tell
        on error number -609
            # Ignoring the "invalid connection" errors
        end try
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "isRunning()")
        return false
    end try
    if spotifyProcesses is 1 then
        return true
    else
        return false
    end if
end isRunning

on addToLoginItems()
    try
        tell application "System Events"
            -- Add Spotifree to the Login Items.
            make login item at end with properties {name:"Spotifree", path:"/Applications/Spotifree.app", hidden:true}
        end tell
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "addToLoginItems()")
        return
    end try
end addToLoginItems

on isTheFirstRun()
    local isPrefFileExists, prefFilePath
    set prefFilePath to "~/Library/Preferences/com.ArtemGordinsky.Spotifree.plist"
    try
        tell application "System Events"
            if exists file prefFilePath then
                set isPrefFileExists to true
            else
                set isPrefFileExists to false
            end if
        end tell
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "isTheFirstRun()")
        return true
    end try
    # "not" works like a bang sign here
    return not isPrefFileExists
end isTheFirstRun

on isInLoginItems()
    try
        tell application "System Events"
            if login item "Spotifree" exists then
                return true
            else
                return false
            end if
        end tell
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "isInLoginItems()")
        return false
    end try
end isInLoginItems

on log_message(message)
    local content
    set content to (return & ¬
        "-----------------------------------------------------------" & ¬
        return & my dateAndTime() & return & message & return ¬
        & "-----------------------------------------------------------" & return)
    set log_file to ("Mountain Lion:Users:Mephistopelus:Developer:The Stuff:AppleScript:SpotiFree:Spotifree_log.txt")
    my write_to_file(content, log_file, true)
end log_message

on log_error(error_number, error_message, _where)
    local content
    if (debug) then
        set content to (return & "-----------------------------------------------------------" & ¬
            return & my dateAndTime() & return & "Error number: " & error_number ¬
            & return & "Error message: " & error_message & return & ¬
            "Where: " & _where & return ¬
            & "-----------------------------------------------------------" & return)
        set log_file to ("Mountain Lion:Users:Mephistopelus:Developer:The Stuff:AppleScript:SpotiFree:Spotifree_log.txt")
        my write_to_file(content, log_file, true)
    end if
end log_error

on write_to_file(this_data, target_file, append_data) -- (string, file path as string, boolean)
    try
        set the target_file to the target_file as text
        set the open_target_file to ¬
            open for access file target_file with write permission
        if append_data is false then ¬
            set eof of the open_target_file to 0
        write this_data to the open_target_file starting at eof
        close access the open_target_file
        return true
    on error
        try
            close access file target_file
        end try
    end try
end write_to_file

on dateAndTime()
    set currentDateAndTime to (current date) as string
    return currentDateAndTime
end dateAndTime

property debug : false
property currentVolume : null
property idleTime: 0.3

if (isTheFirstRun() and not isInLoginItems()) then
    set userAnswer to the button returned of (display dialog "Hi, thanks for installing Spotifree!" & ¬
        return & "Just so you know, Spotifree has no interface yet, and will work silently in the background." & return & return ¬
        & "BTW, do you want it to run automatically on startup?" with title ¬
        "You are awesome!" with icon 1 buttons {"No, thanks", "OK"} default button 2)
    if (userAnswer = "OK") then
        try
            my addToLoginItems()
        end try
    end if
    try
        -- Save in the preferences that Spotifree has already ran.
        do shell script "defaults write com.ArtemGordinsky.Spotifree 'hasRanBefore' 'true'"
    end try
end if

on idle
    try
        -- Adding a 5 seconds timeout instead of default 2 min. Prevents long unresponsiveness of the app.
        with timeout of (5) seconds
            if (isRunning() and isPlaying() and isAnAd()) then
                try
                    mute()
					set idleTime to 0.3
                end try
                repeat
                    set idleTime to 0.3
                    try
                        if (isRunning() and not isAnAd()) then
                            -- Have to delay a little bit, because Spotify may tell us about the next track too early,
                            -- and a user may to hear the last half-second of an ad.
                            delay 0.8
                            unmute()
                            exit repeat
                        end if
                    end try
                end repeat
            else
                -- Delaying, to get less of the crashing "connection is invalid" errors.
                set idleTime to 1
            end if
        end timeout
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "Somewhere in the outer loop.")
    end try
    -- This is how fast we are polling Spotify.
    -- The only speed at which you will hear almost no sounds passing through.
    -- Fortunately, even combined with the added load on Spotify, the CPU usage is rather miniscule.
    return idleTime
end idle

on mute()
    try
        tell application "Spotify"
            set currentVolume to sound volume
            -- This is the only way possible to mute Spotify during an advertisement.
            -- Otherwise it pauses when you mute the sound.
            pause
            set sound volume to 0
            play
        end tell
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "mute()")
    end try
    return
end mute

on unmute()
    try
        tell application "Spotify"
            -- Restore the volume to the level supplied to the parameter.
            set sound volume to currentVolume
        end tell
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "unmute()")
    end try
    return
end unmute

on isAnAd()
    local currentTrackPopularity, currentTrackDuration
    set currentTrackPopularity to null
    set currentTrackDuration to null
    # Nesting "try" blocks is the only way to handle multiple errors in AppleScript
    try
        try
            try
                tell application "Spotify"
                    set currentTrackPopularity to popularity of current track
                    set currentTrackDuration to duration of current track
                end tell
            on error number -1728
                # Ignoring "can't get current track" error
            end try
        on error number -609
            # Ignoring the "invalid connection errors"
        end try
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "isAnAd()")
        return false
    end try
    if ((currentTrackPopularity ≠ null and currentTrackDuration ≠ null) and (currentTrackPopularity = 0 and currentTrackDuration ≤ 40)) then
        return true
    else
        return false
    end if
end isAnAd

on isPlaying()
    local playerState
    set playerState to null
    # Nesting "try" blocks is the only way to handle multiple errors in AppleScript
    try
        try
            tell application "Spotify"
                set playerState to player state
            end tell
        on error -609
            # Ignoring the "invalid connection" errors
        end try
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "isRunning()")
        return false
    end try
    if (playerState ≠ null and playerState = «constant ****kPSP») then
        return true
    else
        return false
    end if
end isPlaying

on isRunning()
    local spotifyProcesses
    # Nesting "try" blocks is the only way to handle multiple errors in AppleScript
    try
        try
            tell application "System Events"
                set spotifyProcesses to (count of (every process whose name is "Spotify"))
            end tell
        on error number -609
            # Ignoring the "invalid connection" errors
        end try
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "isRunning()")
        return false
    end try
    if spotifyProcesses is 1 then
        return true
    else
        return false
    end if
end isRunning

on addToLoginItems()
    try
        tell application "System Events"
            -- Add Spotifree to the Login Items.
            make login item at end with properties {name:"Spotifree", path:"/Applications/Spotifree.app", hidden:true}
        end tell
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "addToLoginItems()")
        return
    end try
end addToLoginItems

on isTheFirstRun()
    local isPrefFileExists, prefFilePath
    set prefFilePath to "~/Library/Preferences/com.ArtemGordinsky.Spotifree"
    try
        tell application "System Events"
            if exists file prefFilePath then
                set isPrefFileExists to true
            else
                set isPrefFileExists to false
            end if
        end tell
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "isTheFirstRun()")
        return true
    end try
    # "not" works like a bang sign here
    return not isPrefFileExists
end isTheFirstRun

on isInLoginItems()
    try
        tell application "System Events"
            if login item "Spotifree" exists then
                return true
            else
                return false
            end if
        end tell
    on error errorMessage number errorNumber
        my log_error(errorNumber, errorMessage, "isInLoginItems()")
        return false
    end try
end isInLoginItems

on log_message(message)
    local content
    set content to (return & ¬
        "-----------------------------------------------------------" & ¬
        return & my dateAndTime() & return & message & return ¬
        & "-----------------------------------------------------------" & return)
    set log_file to ("Mountain Lion:Users:Mephistopelus:Developer:The Stuff:AppleScript:SpotiFree:Spotifree_log.txt")
    my write_to_file(content, log_file, true)
end log_message

on log_error(error_number, error_message, _where)
    local content
    if (debug) then
        set content to (return & "-----------------------------------------------------------" & ¬
            return & my dateAndTime() & return & "Error number: " & error_number ¬
            & return & "Error message: " & error_message & return & ¬
            "Where: " & _where & return ¬
            & "-----------------------------------------------------------" & return)
        set log_file to ("Mountain Lion:Users:Mephistopelus:Developer:The Stuff:AppleScript:SpotiFree:Spotifree_log.txt")
        my write_to_file(content, log_file, true)
    end if
end log_error

on write_to_file(this_data, target_file, append_data) -- (string, file path as string, boolean)
    try
        set the target_file to the target_file as text
        set the open_target_file to ¬
            open for access file target_file with write permission
        if append_data is false then ¬
            set eof of the open_target_file to 0
        write this_data to the open_target_file starting at eof
        close access the open_target_file
        return true
    on error
        try
            close access file target_file
        end try
    end try
end write_to_file

on dateAndTime()
    set currentDateAndTime to (current date) as string
    return currentDateAndTime
end dateAndTime


Modifying the script to actually show the entourage icon

--HG--
extra : convert_revision : svn%3A99687598-2e92-11dd-8019-fe7b9d601d1b/trunk%40474

FasdUAS 1.101.10
k
l

	Display a notification of email in Growl. This is designed to be added as a rule that applies to all messages. It will be processed after spam has been filtered.

	Made by Cowboy - www.cowboyscripts.org

l

l

l5
O5
k4
l
r

n
4

cobj
m

l
e
1

CMgs
o0msg
r
l!
!n"#
"1

subj
#o0msg
 o0
thesubject
theSubject$%
$r&'
&n()
(1

dspn
)n*+
*1

sndr
+o0msg
'o0	thesender	theSender%,-
,l-./
.O201
0I 12
.notifygrnullnull234

titl
3m"#55
Incoming Mail467

desc
6b$)89
8b$':;
:o$%0	thesender	theSender
;m%&<<	:
9o'(0
thesubject
theSubject7=

iapp
=m*+>>Microsoft Entourage
1m??Fnull߀;lGrowlHelperApp.app7ݰ0 P)( GRRRaliskremit=)H+;lGrowlHelperApp.app;npi\	 	ResourcesÃyp;l;k;jPO|_kremit:Users:chris:Library:PreferencePanes:Growl.prefPane:Contents:Resources:GrowlHelperApp.app&GrowlHelperApp.appkremitXUsers/chris/Library/PreferencePanes/Growl.prefPane/Contents/Resources/GrowlHelperApp.app//@
@l33AAys
	display dialog "from: " & theSender & ", subject: " & theSubject with icon 2 buttons "Bloops!" default button 1

mBBnull߀	Microsoft Entourageapplies to all messages. It will be processeOPIMaliskremit=)H+	Microsoft Entourage	bAPPLOPIM	 Microsoft Office 2004Ãy	^=kremit:Applications:Microsoft Office 2004:Microsoft Entourage(Microsoft Entouragekremit6Applications/Microsoft Office 2004/Microsoft Entourage/
C
ClDED
.aevtoappnull****EFGH
.aevtoappnull****
Fk5IIGHB?5<>

CMgs

cobj0msg

subj0
thesubject
theSubject

sndr

dspn0	thesender	theSender

titl

desc

iapp
.notifygrnullnull62*,Ek/EO,EO,,EO*%%aUOPUascrޭ

FasdUAS 1.101.10
k
l

	Display a notification of email in Growl. This is designed to be added as a rule that applies to all messages. It will be processed after spam has been filtered.

	Made by Cowboy - www.cowboyscripts.org

l

l

l5
O5
k4
l
r

n
4

cobj
m

l
e
1

CMgs
o0msg
r
l!
!n"#
"1

subj
#o0msg
 o0
thesubject
theSubject$%
$r&'
&n()
(1

dspn
)n*+
*1

sndr
+o0msg
'o0	thesender	theSender%,-
,l-./
.O201
0I 12
.notifygrnullnull234

titl
3m"#55
Incoming Mail467

desc
6b$)89
8b$':;
:o$%0	thesender	theSender
;m%&<<	:
9o'(0
thesubject
theSubject7=

iapp
=m*+>>Microsoft Entourage.app
1m??Fnull߀;lGrowlHelperApp.app7ݰ0 P)( GRRRaliskremit=)H+;lGrowlHelperApp.app;npi\	 	ResourcesÃyp;l;k;jPO|_kremit:Users:chris:Library:PreferencePanes:Growl.prefPane:Contents:Resources:GrowlHelperApp.app&GrowlHelperApp.appkremitXUsers/chris/Library/PreferencePanes/Growl.prefPane/Contents/Resources/GrowlHelperApp.app//@
@l33AAys
	display dialog "from: " & theSender & ", subject: " & theSubject with icon 2 buttons "Bloops!" default button 1

mBBnull߀	Microsoft Entourageapplies to all messages. It will be processeOPIMaliskremit=)H+	Microsoft Entourage	bAPPLOPIM	 Microsoft Office 2004Ãy	^=kremit:Applications:Microsoft Office 2004:Microsoft Entourage(Microsoft Entouragekremit6Applications/Microsoft Office 2004/Microsoft Entourage/
C
ClDED
.aevtoappnull****EFGH
.aevtoappnull****
Fk5IIGHB?5<>

CMgs

cobj0msg

subj0
thesubject
theSubject

sndr

dspn0	thesender	theSender

titl

desc

iapp
.notifygrnullnull62*,Ek/EO,EO,,EO*%%aUOPUascrޭ


fixed bugs where the other layers name would be appended

-- export all layers to image files
-- Copyright (c) 2011, Charles-Axel Dein

-- Settings
property exportFileExtension : "png"
property ADD_CANVAS_NUMBER : true
-- End of Settings

on file_exists(FileOrFolderToCheckString)
   try
       alias FileOrFolderToCheckString
       return true
   on error
       return false
   end try
end file_exists

tell application "OmniGraffle Professional 5"
	set theWindow to front window
	set theDocument to document of theWindow
	set theFilename to name of theDocument
    -- remove .graffle
    set theFilename to text 1 thru ((offset of "." in theFilename) - 1) of theFilename

	set export_folder to (choose folder with prompt "Pick the destination folder") as string
	set export_folder to export_folder & theFilename & ":"

	-- create folder
	if file_exists(export_folder) of me then
		try
			display alert "The file already exists. Do you want to replace it?" buttons {"Cancel", "Erase"} cancel button 1
		on error errText number errNum
			if (errNum is equal to -128) then
				return
			end if
		end try

		-- deletes the folder (necessary because some layers may have been renamed
		do shell script "rm -rf " & quoted form of POSIX path of export_folder

	else
		-- creates the folder
		do shell script "mkdir -p " & quoted form of POSIX path of export_folder
	end if

	set canvasCount to count of canvases of theDocument

	set i to 0
	repeat with canvasNumber from 1 to canvasCount
		set theCanvas to canvas canvasNumber of theDocument
		set canvas_name to name of theCanvas
		set canvas of theWindow to theCanvas
		set layerCount to count of layers of theCanvas

		-- hide all layers, except those beginning with "*"
		-- also check if there is only one layer to be exported
		repeat with layerNumber from 1 to layerCount
			set theLayer to layer layerNumber of theCanvas
			set number_of_layer_to_be_exported to 0

			if theLayer is prints and class of theLayer is not shared layer then
				set layer_name to name of theLayer as string
				if character 1 of layer_name is not "*" then
					set visible of theLayer to false
					set number_of_layer_to_be_exported to number_of_layer_to_be_exported + 1
				else
					set visible of theLayer to true
				end if
			end if

		end repeat

		set area type of current export settings to current canvas
        set draws background of current export settings to false
        set include border of current export settings to false

		set canvas_filename to ""
		if ADD_CANVAS_NUMBER then
			set canvas_filename to canvasNumber & "- "
		end if
		set canvas_filename to canvas_filename & canvas_name

		repeat with layerNumber from 1 to layerCount
			set theLayer to layer layerNumber of theCanvas

			if (theLayer is prints) and (class of theLayer is not shared layer) then
				set layer_name to name of theLayer as string
				set filename to canvas_filename & " - " & layer_name & "." & exportFileExtension
				set export_filename to export_folder & filename

				-- show the layer, export, then hide the layer
				if character 1 of layer_name is not "*" then
					set visible of theLayer to true
					save theDocument in export_filename
					set visible of theLayer to false
				end if

			end if

		end repeat

	end repeat
end tell

-- export all layers to image files
-- Copyright (c) 2011, Charles-Axel Dein

-- Settings
property exportFileExtension : "png"
property ADD_CANVAS_NUMBER : true
-- End of Settings

on file_exists(FileOrFolderToCheckString)
   try
       alias FileOrFolderToCheckString
       return true
   on error
       return false
   end try
end file_exists

tell application "OmniGraffle Professional 5"
	set theWindow to front window
	set theDocument to document of theWindow
	set theFilename to name of theDocument
    -- remove .graffle
    set theFilename to text 1 thru ((offset of "." in theFilename) - 1) of theFilename

	set export_folder to (choose folder with prompt "Pick the destination folder") as string
	set export_folder to export_folder & theFilename & ":"

	-- create folder
	if file_exists(export_folder) of me then
		try
			display alert "The file already exists. Do you want to replace it?" buttons {"Cancel", "Erase"} cancel button 1
		on error errText number errNum
			if (errNum is equal to -128) then
				return
			end if
		end try

		-- deletes the folder (necessary because some layers may have been renamed
		do shell script "rm -rf " & quoted form of POSIX path of export_folder

	else
		-- creates the folder
		do shell script "mkdir -p " & quoted form of POSIX path of export_folder
	end if

	set canvasCount to count of canvases of theDocument

	set i to 0
	repeat with canvasNumber from 1 to canvasCount
		set theCanvas to canvas canvasNumber of theDocument
		set canvas_name to name of theCanvas
		set canvas of theWindow to theCanvas
		set layerCount to count of layers of theCanvas

		-- hide all layers, except those beginning with "*"
		-- also check if there is only one layer to be exported
		repeat with layerNumber from 1 to layerCount
			set theLayer to layer layerNumber of theCanvas
			set number_of_layer_to_be_exported to 0

			if theLayer is prints and class of theLayer is not shared layer then
				set layer_name to name of theLayer as string
				if character 1 of layer_name is not "*" then
					set visible of theLayer to false
					set number_of_layer_to_be_exported to number_of_layer_to_be_exported + 1
				else
					set visible of theLayer to true
				end if
			end if

		end repeat

		set area type of current export settings to current canvas
        set draws background of current export settings to false
        set include border of current export settings to false

		set filename to ""
		if ADD_CANVAS_NUMBER then
			set filename to canvasNumber & "- "
		end if
		set filename to filename & canvas_name

		repeat with layerNumber from 1 to layerCount
			set theLayer to layer layerNumber of theCanvas

			if (theLayer is prints) and (class of theLayer is not shared layer) then
				set layer_name to name of theLayer as string
				set filename to filename & " - " & layer_name & "." & exportFileExtension
				set export_filename to export_folder & filename

				-- show the layer, export, then hide the layer
				if character 1 of layer_name is not "*" then
					set visible of theLayer to true
					save theDocument in export_filename
					set visible of theLayer to false
				end if

			end if

		end repeat

	end repeat
end tell


change file path

change file path

FasdUAS 1.101.10
k
i
I0reset_simulator
Qx

	kk

I
.ascrcmnt********
m8BEGIN:Reset iPhone Simulator
O
I

.miscactvnullnull
m
P@alisMacintosh HDuH+iPhone Simulator.appw3	 Applicationsv@J٣LeMacintosh HD:Developer:Platforms:iPhoneSimulator.platform:Developer:Applications:iPhone Simulator.app*iPhone Simulator.appMacintosh HDXDeveloper/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/
OX
OW
kV
O? !
 O&>"#
"O-=$%
$I4<&
.prcsclicuieluiel
&448'

menI
'm67(())6Reset Content and Settings &
%4-1*

menE
*m/0++,,iOs Simulator
#4&*-

mbri
-m()..//iOs Simulator
!4#0

mbar
0m!"1
1O@V23
2kGU4456
5IGS7
.prcsclicuieluiel
74GO8

butT
8mKN99::
Reset6;
;lTT
34@D<

cwin
<mBC
4=

prcs
=m>>?? iPhone Simulator
m@@sevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/AB
AOYcCD
CI]b
.aevtquitnullnull
DmYZEEP@alisMacintosh HDuH+iPhone Simulator.appw3	 Applicationsv@J٣LeMacintosh HD:Developer:Platforms:iPhoneSimulator.platform:Developer:Applications:iPhone Simulator.app*iPhone Simulator.appMacintosh HDXDeveloper/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/BF
FIdkG
.ascrcmnt********
GmdgHHII8DONE: RESET SIMULATOR & QUIT

RJ
.ascrerr ********
Jo0e
IsxK
.ascrcmnt********
Kost0eLM
LlMNO
NiPQ
PIR0waitRS
So0sec
QkTTUV
UI	W
.ascrcmnt********
WbXY
XbZ[
Zm\\]]wait for
[o0sec
Ym^^__secondsV`
`I
a
.sysodelanullnmbr
ao
0secObc
blcde
difg
fIh0open_instrumentshi
io0filepath
gk+jjkl
kQ%mno
mkppqr
qr
st
sbuv
umwwxx
open
vnyz
y1

strq
zo0filepath
to0commandr{|
{I}
.ascrcmnt********
}b~
~mJBEGIN: Open instruments with command:
o
0command|
I
.sysoexecTEXTTEXT
o0command
nR
.ascrerr ********
o0e
oI %
.ascrcmnt********
o !0el
I&+
.ascrcmnt********
m&',DONE: oepn instrumentse
l
i
I0click_instruments_menu
o
0	menu_item
k8
O

I
.miscactvnullnull
m@alisxMacintosh HDuH+^Instruments.app5Iϳ	 Applicationsv@Jl^L3Macintosh HD:Developer:Applications:Instruments.app Instruments.appMacintosh HD&Developer/Applications/Instruments.app/
O8
O7
O6
O5
O$4
I+3
.prcsclicuieluiel
4+/

menI
o-.
0	menu_item
4$(

menE
m&'File
4!

mbri
m File
4

mbar
m
4

prcs
mInstruments
msevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/
l
i
I0wait_for_menu_and_click
o
0	menu_item
kw
I
.ascrcmnt********
b
m Begin: Wait for
o
0	menu_item
l
I

.sysodelanullnmbr
m
O
I
.miscactvnullnull
m@alisxMacintosh HDuH+^Instruments.app5Iϳ	 Applicationsv@Jl^L3Macintosh HD:Developer:Applications:Instruments.app Instruments.appMacintosh HD&Developer/Applications/Instruments.app/
Tu
Op
O"o
O)n
O0m
O7l
k>k
Z>a
E>F
l>D
e>D
n>D
1AC

pnam
2>A

menI
oDE
0	menu_item
kI]
lII
IIQ~
.prcsclicuieluiel
4IM}
}
menI
oKL||
0	menu_item~
IR[{z
{.ascrcmnt********
bRW
mRUclick on
oUVyy
0	menu_itemzx
S\]xw
Ibkvu
v.ascrcmnt********
bbg
mbe,still waiting for ...
oeftt
0	menu_itemuw
47;s
s
menE
m9:File
404r
r
mbri
m23File
4)-q
q
mbar
m+,pp
4"&o
o
prcs
m$%Instruments
msevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/
lvvnmlnmlk
lvvjihjihk
lgfegfe
i

	Idcbd0restart_record_tracecb

kQ

O

I	a`_
a.miscactvnullnull`_
m@alisxMacintosh HDuH+^Instruments.app5Iϳ	 Applicationsv@Jl^L3Macintosh HD:Developer:Applications:Instruments.app Instruments.appMacintosh HD&Developer/Applications/Instruments.app/

OO
ON
kM
I^]
^.sysodelanullnmbr
m?ٙ]\
OM
O#L
O*K!"
!k1J##$%
$I19[&Z
[.prcsclicuieluiel
&415Y'
Y
menI
'm34(())Stop TraceZ%*+
*I:?X,W
X.sysodelanullnmbr
,m:;VVW+-U
-I@JT.S
T.prcsclicuieluiel
.4@FR/
R
menI
/mBE0011Record TraceSU
"4*.Q2
Q
menE
2m,-3344File
 4#'P5
P
mbri
5m%&6677File
4 O8
O
mbar
8mNN\
4M9
M
prcs
9m::;;Instruments
m<<sevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/=L
=lPPKJIKJIL>?
>i@A
@IHGFH0zoomGF
AO.BC
BO-DE
Dk,FFGH
GIEID
E.sysodelanullnmbr
ImJJ?ٙDHKC
KO,LM
LO+NO
Nk*PPQR
QO(ST
Sl&&BUVBUclick menu item "Zoom"VWW,click menu item "Zoom"
T4#AX
A
menE
Xm!"YYZZWindowR[@
[l))?>=?>=@
O4<\
<
mbri
\m]]^^Window
M4;_
;
mbar
_m::C
E49`
9
prcs
`maabbInstruments
CmccsevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/?de
dl876876efg
fihi
hI54350export_instruments_log43
ikjjkl
kO
mn
mI	210
2.miscactvnullnull10
nmoo@alisxMacintosh HDuH+^Instruments.app5Iϳ	 Applicationsv@Jl^L3Macintosh HD:Developer:Applications:Instruments.app Instruments.appMacintosh HD&Developer/Applications/Instruments.app/lpq
pOFrs
rOEtu
tkDvvwx
wI*/y.
/.prcsclicuieluiel
yn&z{
z4#&-|
-
butT
|m$%}}~~.Export All Results Now &
{n#
4 #,
,
scra
m!"++
n
4 *
*
splg
m))
n
4(
(
splg
m''
4&
&
cwin
m*sampleApp_instruments.x
I+0%$
%.sysodelanullnmbr
m+,?333333$
I1<#"
#.prcsclicuieluiel
n18
458!
!
butT
m67Open
415

cwin
m34Export"
I=D
.ascrcmnt********
m=@*exporting .. log file
u4

prcs
mInstruments
smsevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/q
IGM0wait
mHI
ONZ
kRY
IRW
.aevtquitnullnull
lXX
mNO@alisxMacintosh HDuH+^Instruments.app5Iϳ	 Applicationsv@Jl^L3Macintosh HD:Developer:Applications:Instruments.app Instruments.appMacintosh HD&Developer/Applications/Instruments.app/
O[
O_
Ih
.prcsclicuieluiel
nh
4z

butT
m{~Don t Save
nhz
4uz

sheE
mxy
nhu
4pu

cwin
mqt*sampleApp_instruments
nhp
4ip

pcap
mloInstruments
mhisevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/
4_e

prcs
madInstruments
m[\sevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/
I
.ascrcmnt********
m8quit application Instrumentsg
l
i #
I0wait_for_script_to_finish
kX
O

I
.miscactvnullnull
m@alisxMacintosh HDuH+^Instruments.app5Iϳ	 Applicationsv@Jl^L3Macintosh HD:Developer:Applications:Instruments.app Instruments.appMacintosh HD&Developer/Applications/Instruments.app/
OQ
OP
lO
OO
k)N
T)L
k.G
I.3
.sysodelanullnmbr
m./
l44
Z4G
=49
147

enaB
m78
boovfals
S<=
k@G
I@E
.ascrcmnt********
m@APscript is running ... try again in 3 sec
lFF
lMM
lMM,&click button "Open" of window "Export"Lclick button "Open" of window "Export"
lMM
n&
4#&

butT
	m$%

Stop Script
n#

4 #

scra
m!"

n
4

splg
m
n
4

splg
m
4

cwin
m*sampleApp_instruments stop script stop script
4

prcs
mInstruments
msevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/
IRX0wait
mST !
 l!"#
"i$'$%
$I0click_ignore
%k&&'(
'I)
.ascrcmnt********
)m**++,Click on ignore button(,
,O-.
-I
/
.prcsclicuieluiel/0

insh
0J1123
2m
34
4m
m
.m55sevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/#67
6l789
8l:
:I;
.ascrcmnt********
;m<<==(Start gui-autoscript9>?
>l@
@I0reset_simulator?AB
AlBCD
ClEFEset filepath to POSIX path of "Macintosh HD:Users:blue:work:socialize:socialize-sdk-ios:SampleSdkApp:testrunner:sampleApp_instruments.trace"FGGset filepath to POSIX path of "Macintosh HD:Users:blue:work:socialize:socialize-sdk-ios:SampleSdkApp:testrunner:sampleApp_instruments.trace"DHI
HlJ
JrKL
KnMN
M1

psxp
Nm
OOPPMacintosh HD:Users:pointabout:champ-test:socialize-sdk-ios:SampleSdkApp:testrunner:sampleApp_instruments.trace
Lo0filepathIQR
QlRST
SlU
UIV0open_instrumentsVW
Wo0filepathTXY
XlZ
ZI[
.sysodelanullnmbr
[mY\]
\l%^
^I%_0wait_for_menu_and_click_`
`m !aabbRecord Trace]cd
cl&+e
eI&+0wait_for_script_to_finishdfg
fl,1h
hI,10click_ignoregij
il28k
kI28l0wait_for_menu_and_clicklm
mm34nnooStop Tracejpq
pl9?r
rI9?s0wait_for_menu_and_clickst
tm:;uuvvRecord Traceqwx
wl@Ey
yI@E0wait_for_script_to_finishxz{
zlFK|
|IFK0export_instruments_log{}~
}l~~
l}|{}|{~
zzyxwvutsrqpoy0reset_simulatorx0waitw0open_instrumentsv0click_instruments_menuu0wait_for_menu_and_clickt0restart_record_traces0zoomr0export_instruments_logq0wait_for_script_to_finishp0click_ignore
o.aevtoappnull****nmlkn0reset_simulatormljj0eih@g>fe.d+c(ba`9_H^]
i.ascrcmnt********
h.miscactvnullnull
g
prcs
f
mbar
e
mbri
d
menE
c
menI
b.prcsclicuieluiel
a
cwin
`
butT
_.aevtquitnullnull^0e]kymjO*jUOA*/9*k/*/*/
*/jUUUO*k/*aa/jOPUUUO*jUOajWXj\Q[ZY\0wait[XXWW0secZVV0sec\^UT
U.ascrcmnt********
T.sysodelanullnmbrY%%jOjSgRQPS0open_instrumentsROONN0filepathQMLKM0filepathL0commandK0ewJIHGF
J
strq
I.ascrcmnt********
H.sysoexecTEXTTEXTG0eFP,,%EO%jOjWXjOjEDCBE0click_instruments_menuDAA@@
0	menu_itemC??
0	menu_item>=<;:98
>.miscactvnullnull
=
prcs
<
mbar
;
mbri
:
menE
9
menI
8.prcsclicuieluielB9*jUO**/"*k/*/*/
*/jUUUUU765470wait_for_menu_and_click63322
0	menu_item511
0	menu_item0/.-,+*)('
0.ascrcmnt********
/.sysodelanullnmbr
..miscactvnullnull
-
prcs
,
mbar
+
mbri
*
menE
)
menI
(
pnam
'.prcsclicuieluiel4x%jOkjO*jUO[hZO*/G*k/?*/7*//*-,E*/jOa%jOYhOa%jUUUUU[OYOP&
%$#&0restart_record_trace%$"<!: 63(0
".miscactvnullnull
!
prcs
 .sysodelanullnmbr

mbar

mbri

menE

menI
.prcsclicuieluiel#R*jUOA*/9jO*k/+*/#*/*/jOjO*a/jUUUUUOPA0zoom
caJ]Y

prcs
.sysodelanullnmbr

mbar

mbri

menE/+*/#jO*k/*/
*/hUOPUUUUi
0export_instruments_logo
	}
.miscactvnullnull

prcs

cwin

splg

scra

butT
.prcsclicuieluiel
.sysodelanullnmbr
.ascrcmnt********0wait
.aevtquitnullnull

pcap

sheE
*jUO8*/0*/k/k/m//jOj
O*//jOajUUO*kk+O	*jOPUO'*a/aa/a/ak/a/jUUOaj0wait_for_script_to_finish

.miscactvnullnull

prcs

cwin

splg

scra

butT
.sysodelanullnmbr

enaB
.ascrcmnt********0waitY*jUOC*/;*/k/k/m//'"hZljO*,fY	jOP[OYOPUUUO*kk+%0click_ignore*5
.ascrcmnt********

inshm
.prcsclicuieluieljO*lvlU
.aevtoappnull****
kK8>HSX\cfipwz<Oanu
.ascrcmnt********0reset_simulator

psxp0filepath0open_instruments
.sysodelanullnmbr0wait_for_menu_and_click0wait_for_script_to_finish0click_ignore0export_instruments_logLjO*j+O,EO*k+OkjO*k+	O*j+
O*j+O*k+	O*k+	O*j+
O*j+ascr
ޭ

FasdUAS 1.101.10
k
i
I0reset_simulator
Qx

	kk

I
.ascrcmnt********
m8BEGIN:Reset iPhone Simulator
O
I

.miscactvnullnull
m
P@alisMacintosh HDuH+iPhone Simulator.appw3	 Applicationsv@J٣LeMacintosh HD:Developer:Platforms:iPhoneSimulator.platform:Developer:Applications:iPhone Simulator.app*iPhone Simulator.appMacintosh HDXDeveloper/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/
OX
OW
kV
O? !
 O&>"#
"O-=$%
$I4<&
.prcsclicuieluiel
&448'

menI
'm67(())6Reset Content and Settings &
%4-1*

menE
*m/0++,,iOs Simulator
#4&*-

mbri
-m()..//iOs Simulator
!4#0

mbar
0m!"1
1O@V23
2kGU4456
5IGS7
.prcsclicuieluiel
74GO8

butT
8mKN99::
Reset6;
;lTT
34@D<

cwin
<mBC
4=

prcs
=m>>?? iPhone Simulator
m@@sevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/AB
AOYcCD
CI]b
.aevtquitnullnull
DmYZEEP@alisMacintosh HDuH+iPhone Simulator.appw3	 Applicationsv@J٣LeMacintosh HD:Developer:Platforms:iPhoneSimulator.platform:Developer:Applications:iPhone Simulator.app*iPhone Simulator.appMacintosh HDXDeveloper/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/BF
FIdkG
.ascrcmnt********
GmdgHHII8DONE: RESET SIMULATOR & QUIT

RJ
.ascrerr ********
Jo0e
IsxK
.ascrcmnt********
Kost0eLM
LlMNO
NiPQ
PIR0waitRS
So0sec
QkTTUV
UI	W
.ascrcmnt********
WbXY
XbZ[
Zm\\]]wait for
[o0sec
Ym^^__secondsV`
`I
a
.sysodelanullnmbr
ao
0secObc
blcde
difg
fIh0open_instrumentshi
io0filepath
gk+jjkl
kQ%mno
mkppqr
qr
st
sbuv
umwwxx
open
vnyz
y1

strq
zo0filepath
to0commandr{|
{I}
.ascrcmnt********
}b~
~mJBEGIN: Open instruments with command:
o
0command|
I
.sysoexecTEXTTEXT
o0command
nR
.ascrerr ********
o0e
oI %
.ascrcmnt********
o !0el
I&+
.ascrcmnt********
m&',DONE: oepn instrumentse
l
i
I0click_instruments_menu
o
0	menu_item
k8
O

I
.miscactvnullnull
m@alisxMacintosh HDuH+^Instruments.app5Iϳ	 Applicationsv@Jl^L3Macintosh HD:Developer:Applications:Instruments.app Instruments.appMacintosh HD&Developer/Applications/Instruments.app/
O8
O7
O6
O5
O$4
I+3
.prcsclicuieluiel
4+/

menI
o-.
0	menu_item
4$(

menE
m&'File
4!

mbri
m File
4

mbar
m
4

prcs
mInstruments
msevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/
l
i
I0wait_for_menu_and_click
o
0	menu_item
kw
I
.ascrcmnt********
b
m Begin: Wait for
o
0	menu_item
l
I

.sysodelanullnmbr
m
O
I
.miscactvnullnull
m@alisxMacintosh HDuH+^Instruments.app5Iϳ	 Applicationsv@Jl^L3Macintosh HD:Developer:Applications:Instruments.app Instruments.appMacintosh HD&Developer/Applications/Instruments.app/
Tu
Op
O"o
O)n
O0m
O7l
k>k
Z>a
E>F
l>D
e>D
n>D
1AC

pnam
2>A

menI
oDE
0	menu_item
kI]
lII
IIQ~
.prcsclicuieluiel
4IM}
}
menI
oKL||
0	menu_item~
IR[{z
{.ascrcmnt********
bRW
mRUclick on
oUVyy
0	menu_itemzx
S\]xw
Ibkvu
v.ascrcmnt********
bbg
mbe,still waiting for ...
oeftt
0	menu_itemuw
47;s
s
menE
m9:File
404r
r
mbri
m23File
4)-q
q
mbar
m+,pp
4"&o
o
prcs
m$%Instruments
msevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/
lvvnmlnmlk
lvvjihjihk
lgfegfe
i

	Idcbd0restart_record_tracecb

kQ

O

I	a`_
a.miscactvnullnull`_
m@alisxMacintosh HDuH+^Instruments.app5Iϳ	 Applicationsv@Jl^L3Macintosh HD:Developer:Applications:Instruments.app Instruments.appMacintosh HD&Developer/Applications/Instruments.app/

OO
ON
kM
I^]
^.sysodelanullnmbr
m?ٙ]\
OM
O#L
O*K!"
!k1J##$%
$I19[&Z
[.prcsclicuieluiel
&415Y'
Y
menI
'm34(())Stop TraceZ%*+
*I:?X,W
X.sysodelanullnmbr
,m:;VVW+-U
-I@JT.S
T.prcsclicuieluiel
.4@FR/
R
menI
/mBE0011Record TraceSU
"4*.Q2
Q
menE
2m,-3344File
 4#'P5
P
mbri
5m%&6677File
4 O8
O
mbar
8mNN\
4M9
M
prcs
9m::;;Instruments
m<<sevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/=L
=lPPKJIKJIL>?
>i@A
@IHGFH0zoomGF
AO.BC
BO-DE
Dk,FFGH
GIEID
E.sysodelanullnmbr
ImJJ?ٙDHKC
KO,LM
LO+NO
Nk*PPQR
QO(ST
Sl&&BUVBUclick menu item "Zoom"VWW,click menu item "Zoom"
T4#AX
A
menE
Xm!"YYZZWindowR[@
[l))?>=?>=@
O4<\
<
mbri
\m]]^^Window
M4;_
;
mbar
_m::C
E49`
9
prcs
`maabbInstruments
CmccsevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/?de
dl876876efg
fihi
hI54350export_instruments_log43
ikjjkl
kO
mn
mI	210
2.miscactvnullnull10
nmoo@alisxMacintosh HDuH+^Instruments.app5Iϳ	 Applicationsv@Jl^L3Macintosh HD:Developer:Applications:Instruments.app Instruments.appMacintosh HD&Developer/Applications/Instruments.app/lpq
pOFrs
rOEtu
tkDvvwx
wI*/y.
/.prcsclicuieluiel
yn&z{
z4#&-|
-
butT
|m$%}}~~.Export All Results Now &
{n#
4 #,
,
scra
m!"++
n
4 *
*
splg
m))
n
4(
(
splg
m''
4&
&
cwin
m*sampleApp_instruments.x
I+0%$
%.sysodelanullnmbr
m+,?333333$
I1<#"
#.prcsclicuieluiel
n18
458!
!
butT
m67Open
415

cwin
m34Export"
I=D
.ascrcmnt********
m=@*exporting .. log file
u4

prcs
mInstruments
smsevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/q
IGM0wait
mHI
ONZ
kRY
IRW
.aevtquitnullnull
lXX
mNO@alisxMacintosh HDuH+^Instruments.app5Iϳ	 Applicationsv@Jl^L3Macintosh HD:Developer:Applications:Instruments.app Instruments.appMacintosh HD&Developer/Applications/Instruments.app/
O[
O_
Ih
.prcsclicuieluiel
nh
4z

butT
m{~Don t Save
nhz
4uz

sheE
mxy
nhu
4pu

cwin
mqt*sampleApp_instruments
nhp
4ip

pcap
mloInstruments
mhisevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/
4_e

prcs
madInstruments
m[\sevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/
I
.ascrcmnt********
m8quit application Instrumentsg
l
i #
I0wait_for_script_to_finish
kX
O

I
.miscactvnullnull
m@alisxMacintosh HDuH+^Instruments.app5Iϳ	 Applicationsv@Jl^L3Macintosh HD:Developer:Applications:Instruments.app Instruments.appMacintosh HD&Developer/Applications/Instruments.app/
OQ
OP
lO
OO
k)N
T)L
k.G
I.3
.sysodelanullnmbr
m./
l44
Z4G
=49
147

enaB
m78
boovfals
S<=
k@G
I@E
.ascrcmnt********
m@APscript is running ... try again in 3 sec
lFF
lMM
lMM,&click button "Open" of window "Export"Lclick button "Open" of window "Export"
lMM
n&
4#&

butT
	m$%

Stop Script
n#

4 #

scra
m!"

n
4

splg
m
n
4

splg
m
4

cwin
m*sampleApp_instruments stop script stop script
4

prcs
mInstruments
msevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/
IRX0wait
mST !
 l!"#
"i$'$%
$I0click_ignore
%k&&'(
'I)
.ascrcmnt********
)m**++,Click on ignore button(,
,O-.
-I
/
.prcsclicuieluiel/0

insh
0J1123
2m
34
4m
m
.m55sevsalisMacintosh HDuH+ͪSystem Events.app<'uͦ	 CoreServicesv@Jv>&ͪff:Macintosh HD:System:Library:CoreServices:System Events.app$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/#67
6l789
8l:
:I;
.ascrcmnt********
;m<<==(Start gui-autoscript9>?
>l@
@I0reset_simulator?AB
AlBCD
ClE
ErFG
FnHI
H1

psxp
Im
JJKKMacintosh HD:Users:blue:work:socialize:socialize-sdk-ios:SampleSdkApp:testrunner:sampleApp_instruments.trace
Go0filepathDLM
LlN
NIO0open_instrumentsOP
Po0filepathMQR
QlS
SIT
.sysodelanullnmbr
TmRUV
Ul%W
WI%X0wait_for_menu_and_clickXY
Ym !ZZ[[Record TraceV\]
\l&+^
^I&+0wait_for_script_to_finish]_`
_l,1a
aI,10click_ignore`bc
bl28d
dI28e0wait_for_menu_and_clickef
fm34gghhStop Tracecij
il9?k
kI9?l0wait_for_menu_and_clicklm
mm:;nnooRecord Tracejpq
pl@Er
rI@E0wait_for_script_to_finishqst
slFKu
uIFK0export_instruments_logtvw
vlwx
xl~yz{|}~}|{zyxwvut~ysrqponmlkjihgfedcba`_^s0reset_simulatorr0waitq0open_instrumentsp0click_instruments_menuo0wait_for_menu_and_clickn0restart_record_tracem0zooml0export_instruments_logk0wait_for_script_to_finishj0click_ignore
i.aevtoappnull****h0filepathgfedcba`_^z]\[Z]0reset_simulator\[YY0eXW@V>UT.S+R(QPO9NHML
X.ascrcmnt********
W.miscactvnullnull
V
prcs
U
mbar
T
mbri
S
menE
R
menI
Q.prcsclicuieluiel
P
cwin
O
butT
N.aevtquitnullnullM0eLZymjO*jUOA*/9*k/*/*/
*/jUUUO*k/*aa/jOPUUUO*jUOajWXj{KQJIHK0waitJGGFF0secIEE0sec\^DC
D.ascrcmnt********
C.sysodelanullnmbrH%%jOj|BgA@?B0open_instrumentsA>>==0filepath@<;:<0filepath;0command:0ew98765
9
strq
8.ascrcmnt********
7.sysoexecTEXTTEXT60e5?,,%EO%jOjWXjOj}432140click_instruments_menu300//
0	menu_item2..
0	menu_item-,+*)('
-.miscactvnullnull
,
prcs
+
mbar
*
mbri
)
menE
(
menI
'.prcsclicuieluiel19*jUO**/"*k/*/*/
*/jUUUUU~&%$#&0wait_for_menu_and_click%""!!
0	menu_item$
0	menu_item
.ascrcmnt********
.sysodelanullnmbr
.miscactvnullnull

prcs

mbar

mbri

menE

menI

pnam
.prcsclicuieluiel#x%jOkjO*jUO[hZO*/G*k/?*/7*//*-,E*/jOa%jOYhOa%jUUUUU[OYOP
0restart_record_trace<:
63(
	0
.miscactvnullnull

prcs
.sysodelanullnmbr

mbar

mbri

menE

menI

.prcsclicuieluiel	R*jUOA*/9jO*k/+*/#*/*/jOjO*a/jUUUUUOPA0zoom
caJ]Y

prcs
.sysodelanullnmbr

mbar

mbri

menE/+*/#jO*k/*/
*/hUOPUUUUi0export_instruments_logo}
.miscactvnullnull

prcs

cwin

splg

scra

butT
.prcsclicuieluiel
.sysodelanullnmbr
.ascrcmnt********0wait
.aevtquitnullnull

pcap

sheE*jUO8*/0*/k/k/m//jOj
O*//jOajUUO*kk+O	*jOPUO'*a/aa/a/ak/a/jUUOaj0wait_for_script_to_finish

.miscactvnullnull

prcs

cwin

splg

scra

butT
.sysodelanullnmbr

enaB
.ascrcmnt********0waitY*jUOC*/;*/k/k/m//'"hZljO*,fY	jOP[OYOPUUUO*kk+%0click_ignore*5
.ascrcmnt********

inshm
.prcsclicuieluieljO*lvlU
.aevtoappnull****
kK8>CLQU\_bips<JZgn
.ascrcmnt********0reset_simulator

psxp0filepath0open_instruments
.sysodelanullnmbr0wait_for_menu_and_click0wait_for_script_to_finish0click_ignore0export_instruments_logLjO*j+O,EO*k+OkjO*k+	O*j+
O*j+O*k+	O*k+	O*j+
O*j+/Users/blue/work/socialize/socialize-sdk-ios/SampleSdkApp/testrunner/sampleApp_instruments.trace}|{zyxwvutascrޭ