problem: copy as applescript | osascript -
So, I draw a shape in Omnigraffle Pro (in this case a simple text box), and then select Save as applescript from the menu. I get the following results with osascript:
[CODE]$ pbpaste | osascript - 131:138: syntax error: Expected “,” or “}” but found identifier. (-2741) [/CODE]And here is a typical applescript, directly from pbpaste: [CODE] tell application "OmniGraffle Professional" tell canvas of front window make new shape at end of graphics with properties {side padding: 0, fill: no fill, draws stroke: false, draws shadow: false, autosizing: full, size: {20.000000, 14.000000}, text: {text: "abc", alignment: right, text: "abc"}, origin: {69.000000, 132.000000}, vertical padding: 0} end tell end tell [/CODE] This also happens with other shapes such as lines, rectangles, etc. What am I doing wrong? |
The only thing you are doing wrong is expecting OmniGraffle to emit working Applescript code :-)
The first line needs to be [code]tell application "OmniGraffle Professional 5"[/code] and if you make an intermediate stop in a text editor to fix that, I think you'll find that [B]pbpaste | osascript -[/B] will work. |
This bug is a very dear old friend – I think I might miss it if it were ever unaccountably scheduled for decommissioning.
I remember, with great nostalgia, reporting it over two years ago to the Ninjas, and recording it [URL="http://forums.omnigroup.com/showthread.php?t=15962"]here[/URL]. Cue to noble statement of policy on the democratic sequence in which bugs are fixed :-) (or, perhaps, sometimes, not fixed ...) |
Incidentally, if it would just generate:
[CODE]tell application id "OGfl"[/CODE] that would be enough ... |
Thank you. I knew it had to be something simple like that.
And yet, the name of the application (in /Applications, at least), is “OmniGraffle Professional.app”. I never would have found the solution. |
FWIW, I use this, as a LaunchBar script (tapping space-bar to enter part of the name of a running app) to find out how that application can be addressed through Applescript:
[CODE]-- Get creator codes and bundle identifiers for tell applications blocks -- (for applications currently running -- Ver .05 Compatible with LaunchBar - select script, tap space bar and enter string in Launchbar property pTitle : "Tell application id ..." property pDefaultSearch : "omni" property pCodeCopy : "Copy creator code" property pBundleCopy : "Copy bundle identifier" property pNameCopy : "Copy app name" -- System Events on run tell application id "sevs" activate set strSearch to text returned of (display dialog "Enter part of application name: (or leave blank to see all running applications)" default answer pDefaultSearch with title pTitle) end tell handle_string(strSearch) end run on handle_string(strSearch) tell application id "sevs" if (strSearch ≠ "") and (strSearch ≠ "*") then set {lstCode, lstBundle, lstFile} to {creator type, bundle identifier, file} of (application processes where name contains strSearch and bundle identifier is not missing value) set strPrompt to "Applications with \"" & strSearch & "\" in their name:" else set {lstCode, lstBundle, lstName, lstFile} to {creator type, bundle identifier, name, file} of (application processes where bundle identifier is not missing value) set strPrompt to "All currently running applications:" end if repeat with i from 1 to length of lstCode set varFile to item i of lstFile if varFile ≠ missing value then set strName to (name of item i of lstFile) else set strName to item i of lstName end if set item i of lstCode to item i of lstCode & "=" & item i of lstBundle & "=" & strName end repeat set my text item delimiters to linefeed set strApps to lstCode as string set lstApps to paragraphs of (do shell script "echo " & quoted form of strApps & " | sort -t '=' -k 3") if length of lstApps > 0 then set lstDefault to {first item of lstApps} else activate display alert "No running apps have names matching " & strSearch return end if activate set varChoice to choose from list lstApps with prompt strPrompt default items lstDefault with title pTitle if varChoice is false then return set my text item delimiters to "=" set {strID, strBundle, strName} to text items 1 thru 3 of first item of varChoice set {blnCode, blnBundle, blnName} to {true, true, true} -- CREATOR CODE if strID ≠ "????" then set strCode to "tell application id \"" & strID & "\"" else set blnCode to false set strCode to strName & " has no creator code ..." end if -- BUNDLE IDENTIFIER if strBundle ≠ "missing value" then set strBundle to "tell application id \"" & strBundle & "\"" else set blnBundle to false set strBundle to strName & " has no bundle identifier" end if -- APPLICATION NAME if strName ends with ".app" then set strName to text 1 thru -5 of strName set strAppName to "tell application \"" & strName & "\"" else set blnName to false set strAppName to "" end if set strChoice to "CREATOR CODE: " & strCode & " BUNDLE IDENTIFIER: " & strBundle & " APP NAME: " & strAppName set lstBtns to {} if blnName then set end of lstBtns to pNameCopy if blnBundle then set end of lstBtns to pBundleCopy if blnCode then set end of lstBtns to pCodeCopy set lngButtons to length of lstBtns if lngButtons > 0 then set strClip to "-- " & strName & return activate set strBtn to (button returned of (display dialog strChoice buttons lstBtns default button lngButtons with title strName)) if strBtn = pCodeCopy then set strClip to strClip & strCode else if strBtn = pBundleCopy then set strClip to strClip & strBundle else set strClip to strAppName end if set the clipboard to strClip & return & return & "end tell" else activate display alert strName & " is not a scriptable process" end if set my text item delimiters to space end tell end handle_string [/CODE] |
It's hard to see how you didn't immediately recognize the problem from the error message :-)
I'll confess to wasting a bit of time fooling around with converting end of line characters and quoting before taking a completely different approach that led immediately to the solution... |
1 Attachment(s)
A simple pre-breakfast memorisation exercise:
[IMG]http://forums.omnigroup.com/attachment.php?attachmentid=2700&stc=1&d=1359587693[/IMG] You will soon spot the system - OGfl contains a digit in the application title (which may or may not differ from the application name) but not the bundle code, whereas, of course, the OOut pattern is the converse, and none of this is relevant to RSGS, which doesn't start with an O. OFOC. Or something of that general sort. [COLOR="White"]--[/COLOR] |
All times are GMT -8. The time now is 08:48 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.