🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #2067

Re: [JS,AS,CS3]running javascript in bridge from applescript

#2067
From: Kasyan Servetsky
Date: Wed, 07 Jan 2009 19:14
93 lines
4053 bytes
Here is my AS script from Xcode project:
Some text is in Russian � don't mind it. Most important that this is a working example.

global myBridgeLabel

on clicked theObject 
	if name of theObject is "b1" then 
		set processName to (StringToUnicode "Начало работы") 
		set myBridgeLabel to "Red" 
		set myLabel to 1 
	else if name of theObject is "b2" then 
		set processName to (StringToUnicode "Сдано на цв-корр") 
		set myBridgeLabel to "Green" 
		set myLabel to 2 
	else if name of theObject is "b3" then 
		set processName to (StringToUnicode "Сдано на ДТП") 
		set myBridgeLabel to "Yellow" 
		set myLabel to 3 
	else if name of theObject is "b4" then 
		set processName to (StringToUnicode "Забрано") 
		set myBridgeLabel to "Blue" 
		set myLabel to 4 
	else if name of theObject is "b5" then 
		set processName to (StringToUnicode "Пересдано") 
		set myBridgeLabel to "Purple" 
		set myLabel to 5 
	end if



	tell application "Adobe InDesign CS2" 
		set mydocument to active document 
		set myDocumentPath to full name of mydocument 
		set workerName to "Сервецкий"

		tell metadata preferences of mydocument 
			set theDate to current date 
			set myWeekday to weekday of theDate as string 
			set myDenNedeli to my convertWeekday(myWeekday) 
			set myRecord to (processName & " � " & workerName & " � ") & myDenNedeli & " " & text 1 thru -4 of time string of theDate & "  
" 
			set myHistory to get property namespace "http://ns.adobe.com/photoshop/1.0/" path "History" 
			set property namespace "http://ns.adobe.com/photoshop/1.0/" path "History" value myHistory & myRecord 
		end tell











		set myJavaScript to "var myLabel =\"" & myBridgeLabel & "\"; app.activate(); var bt = new BridgeTalk; bt.target = \"bridge\"; myScript = 'app.displayDialogs = \"none\"; var t = new Thumbnail (File (\"" & myDocumentPath & "\")); var mdata = t.metadata; mdata.namespace = \"http://ns.adobe.com/xap/1.0/\"; mdata.Label = \"' + myLabel + '\";'; bt.body = myScript; bt.send();"

		do script myJavaScript language javascript

		tell mydocument to save

	end tell

	tell application "Finder" 
		set myFile to a reference to file myDocumentPath 
		set label index of myFile to myLabel 
	end tell





end clicked

on convertWeekday(myWeekday) 
	if myWeekday = "Monday" then 
		return "Пн" 
	else if myWeekday = "Tuesday," then 
		return "Вторник" 
	else if myWeekday = "Wednesday" then 
		return "Среда" 
	else if myWeekday = "Thursday" then 
		return "Четверг" 
	else if myWeekday = "Friday" then 
		return "Пятница" 
	else if myWeekday = "Saturday" then 
		return "Суббота" 
	else if myWeekday = "Sunday" then 
		return "Воскресенье" 
	else 
		return "N/a" 
	end if 
end convertWeekday
Technical Details
Message-ID: <59b7725f.1@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newshub.sdsu.edu!webcrossing
References: <59b7725f.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,8400ccc6b1ede1f
X-Google-Attributes: gidf939a,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII
From: "Kasyan Servetsky" <askoldich@yahoo.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Re: [JS,AS,CS3]running javascript in bridge from applescript
Message-ID: <59b7725f.1@webcrossing.la2eafNXanI>
Date: Wed, 7 Jan 2009 11:14:57 -0800
References: <59b7725f.-1@webcrossing.la2eafNXanI>
Lines: 100
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit