• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: 10.3.9 Broke something
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 10.3.9 Broke something


  • Subject: Re: 10.3.9 Broke something
  • From: kai <email@hidden>
  • Date: Sun, 24 Apr 2005 20:06:13 +0100


On Fri Apr 22, 2005 8:30:14 am Europe/London, Lee Noble wrote:

I've used WireTap to record a WMP stream every weekday for over a year. For the last three days the script has failed while selecting the save folder. This part of the script uses UI Scripting as there is no alternative. Here's the script.

[snip: script]

The script has always run from the login screen (logged in...switched out) without issue. Now it stops after the Go To box pops up and the field is left unpopulated. I tested the script yesterday by setting it to go off in 5 minutes and switched out to the login screen. It worked flawlessly. So it seems that the length of delay, since I leave it overnight, is affecting it.

Seems something may have changed with navigation services, Lee. The script also fails on a pre-10.3 system at about the same point - presumably for similar reasons.


While UI Scripting in the WMP part of the script is probably unavoidable, I wondered if an alternative approach might be possible for the initial WireTap routine. After all, it's essentially a pref-setting process, and WireTap's pList isn't too complex. It could therefore be worth trying to make the script less susceptible to UI variations, by modifying the pList directly.

Obviously, attempting to change an open application's pList (other than from the app itself) is not a particularly good idea. So it's advisable to include a mechanism for quitting the app concerned (if already open), making the required changes - and then relaunching. (This precaution may not be essential for your current circumstances, but incorporating it is a fairly trivial matter anyway.)

The suggestion below aims to achieve pretty much the same as your original, with perhaps one or two tweaks intended to make it slightly more portable and efficient.

For example, if the specified folders don't already exist, they can be created on the fly. To locate standard folders on virtually any Mac, paths have been specified using Standard Additions' 'path to' command. Also, while the WMP *application* name is "Windows Media Player", the name of the *process* OMM is "WindowsMediaPlayer" (no spaces). Judging from your script, your situation differs - so a workaround for this inconsistency might be helpful. The original 'date' shell script has been avoided by utilising an earlier 'current date' call. Finally, because of the time that WMP takes to launch and connect, calls to it are made much earlier in this suggested version:

--------

property soundLevel : 0.1
property waitTime : 10 -- seconds to allow WMP to do its stuff
property folderName : "Radio" -- primary folder in music folder
property showName : "Breakfast" -- target folder in primary folder
property tgtURL : "http://ms2.capitalinteractive.co.uk/xfm_low";
property endKey : "</key>" & (ASCII character 10) & tab & "<string>"

to connectPlayer()
	launch application "Windows Media Player"
	set volume soundLevel
	tell application "System Events" to tell ¬
		(first process whose creator type is "Ms01")
		repeat until exists
		end repeat
		set frontmost to true
		keystroke "u" using command down
		tell window "Open URL"
			repeat until exists
			end repeat
			keystroke tgtURL & return
		end tell
	end tell
end connectPlayer

to getPath for tgtFolder at ctnrFolder
	tell application "Finder"
		tell folder tgtFolder of folder ctnrFolder to ¬
			if it exists then return it as Unicode text
		(make new folder at ctnrFolder with properties ¬
			{name:tgtFolder}) as Unicode text
	end tell
end getPath

to getDates for showTitle
	tell (current date)'s {year, month, day, weekday} to {¬
		(item 1 as string) & "-" & item 2 & "-" & item 3 & "_", ¬
		showTitle & " " & item 4 & " " & item 2 & " " & item 3}
end getDates

to quitApp()
	tell application "System Events" to ¬
		tell process "WireTap" to if exists then
			ignoring application responses
				tell application "WireTap" to quit
			end ignoring
			repeat while exists
			end repeat
		end if
	false
end quitApp

to matchpList to l
	set d to text item delimiters
	set q to true
	set f to (path to "pref" as Unicode text) & ¬
		"com.ambrosiasw.wiretap.plist"
	set o to open for access file f with write permission
	set e to read o
	repeat with i in l
		set text item delimiters to "<key>" & i's k & endKey
		set e to e's text from text item 2 to -1
		set m to (get eof o) - (count e)
		set text item delimiters to "</string>"
		set t to e's text item 1
		set e to e's text from text item 2 to -1
		if t is not i's t then
			if q then set q to quitApp()
			set eof o to m
			write ({get i's t, e} as string) to o
		end if
	end repeat
	close access o
	set text item delimiters to d
end matchpList

to recordShow from showIntro
	launch application "WireTap"
	say showIntro
	delay waitTime
	tell application "WireTap" to start recording
end recordShow

to run
	connectPlayer()
	set savePath to getPath for folderName at ¬
		(path to "µdoc" as Unicode text)
	set saveFolder to (POSIX path of ¬
		(getPath for showName at savePath))'s text 1 thru -2
	set {filePrefix, showIntro} to ¬
		(getDates for showName & " Show")
	matchpList to ¬
		{{k:"FilePrefix", t:filePrefix}, {k:"SaveFolder", t:saveFolder}}
	recordShow from showIntro
end run

--------

---
kai

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: The Pyramid - a challenge...
  • Next by Date: Re: The Pyramid - a challenge...
  • Previous by thread: Re: 10.3.9 Broke something
  • Next by thread: apple script error
  • Index(es):
    • Date
    • Thread