• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
AppleScriptObjC oddity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: AppleScriptObjC oddity
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Bluetooth headset button click event
  • Next by Date: Re: AppleScriptObjC oddity
  • Previous by thread: Bluetooth headset button click event
  • Next by thread: Re: AppleScriptObjC oddity
  • Index(es):
    • Date
    • Thread