capturing part of a list item

I am trying to control MPEG Streamclip. It is not scriptable but I found a script that lists the contents of the its GUI in a rather long list. I was able to find the element in the list that contains the information I need but am unable to capture it. I get the error message:

error “Can’t make «class sttx» "0:18:33,01" of window "MPEG Streamclip 1.9.2 © 2004-2008 Squared 5 " of «class pcap» "MPEG Streamclip" of application "System Events" into the expected type.” number -1700 from «class sttx» “0:18:33,01” of window "MPEG Streamclip 1.9.2 © 2004-2008 Squared 5 " of «class pcap» “MPEG Streamclip”

The item appears as :

{static text “0:18:33,01” of window "MPEG Streamclip 1.9.2 © 2004-2008 Squared 5 " of application process “MPEG Streamclip” of application “System Events”}

I need to capture /0:18:33,01/ Every thing I have tried results in the above error.

Any help would be appreciated.

Bill Manley

Here is a quick and dirty answer.

# the beg of your script

try
	# Here put the instruction which generate the error message
on error errMsg
	set maybe to item 2 of my decoupe(errMsg, "«class sttx» " & quote)
	set maybe to item 1 of my decoupe(maybe, quote)
	# maybe is the wanted string
end try

# the end of your script

#=====

on decoupe(t, d)
	local oTIDs, l
	set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
	set l to text items of t
	set AppleScript's text item delimiters to oTIDs
	return l
end decoupe

#=====

Yvan KOENIG (VALLAURIS, France) samedi 1 novembre 2014 18:47:15

Hi.

Your item is a list containing a System Events reference. To get at the reference, you need to get ‘item 1’ of that list.

The reference is a name reference (‘static text “0:18:33,01” .’) and the value you want is its ‘name’. :slight_smile: Something like this.

set theItem to {static text "0:18:33,01" of window "MPEG Streamclip 1.9.2 © 2004-2008 Squared 5 " of application process "MPEG Streamclip" of application "System Events"}

tell application "System Events"
	set theValue to name of item 1 of theItem
end tell

Static texts also have a ‘value’ property, which you could use instead of ‘name’.