Re: AppleScriptObjC oddity
Re: AppleScriptObjC oddity
- Subject: Re: AppleScriptObjC oddity
- From: Shane Stanley <email@hidden>
- Date: Wed, 24 Jun 2015 09:51:29 +1000
On 24 Jun 2015, at 7:40 am, Steve Mills <email@hidden> wrote:
If I run the script from ScriptDebugger, from the system script menu, or from LaunchBar, it works as expected. But if I run it via a global key equiv I've set on a DragThing item, it works wrong. It appears that different apps are returning different values for NSScreen's frame. Could this be because DragThing still appears to be a Carbon app?
I don't think so, but it does sound odd. Try adding a 'use framework "Foundation"' in there -- you should have that in pretty much all scripts (you're calling an NSArray method after all). Since I'm new to AppleScriptObjC, is there some way to have "current application" be the app that is being targeted by the script, so I can ensure it's working with a Cocoa app that will return the correct values? Like:
tell app "Safari" set ss to current application's NSScreen's screens() end tell
From my tests, "current application" always seems to be the app that executed the script.
That's the definition of current application. The parent of a script object is an AppleScript component instance (the constant AppleScript), and the parent of AppleScript is current application Your snippet works precisely because NSScreen is handled by the current application and not Safari -- otherwise you'd get an error.
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden