AppleScriptObjC oddity
AppleScriptObjC oddity
- Subject: AppleScriptObjC oddity
- From: Steve Mills <email@hidden>
- Date: Tue, 23 Jun 2015 21:40:10 +0000 (GMT)
I recently learned about AppleScriptObjC and how you can call Cocoa stuff from AppleScript. Thanks Shane! I noticed something weird though. I have a script that will move some apps' windows to my left screen when I get to the office and have plugged in an external monitor as my main (right) screen.
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?
use scripting additions
use framework "AppKit" -- for NSScreen
set ss to current application's NSScreen's screens()
set leftScreenBox to (ss's objectAtIndex:1)'s frame()
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.
Steve
_______________________________________________
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