• 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
Re: Can one get physical location via Applescript?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can one get physical location via Applescript?


  • Subject: Re: Can one get physical location via Applescript?
  • From: Shane Stanley <email@hidden>
  • Date: Tue, 09 Dec 2014 21:50:54 +1100

On 9 Dec 2014, at 8:06 pm, Paul Fidler <email@hidden> wrote:

I’m terribly sorry that I don’t have time to make this all pretty, but I do have CoreLocation working. A sample project is below

Terrific. So this will work in Script Editor, but it must be run in the foreground (control-command-R). And in an applet, it needs to be stay-open.

use scripting additions
use framework "Foundation"
use framework "CoreLocation"

on locationManager:locationManager didUpdateToLocation:newLocation fromLocation:oldLocation
set myData to current application's NSString's stringWithString:(newLocation's |description|())
set charSet to current application's NSCharacterSet's characterSetWithCharactersInString:"<>,()/@coursepd m"
set myList to myData's componentsSeparatedByCharactersInSet:charSet
myList's removeObjectsInArray:{"", "-", "+"}
set lat to ((myList's objectAtIndex:0) as text)
set lon to ((myList's objectAtIndex:1) as text)
set coords to lat & "," & lon
display dialog coords
locationManager's stopUpdatingLocation()
end locationManager:didUpdateToLocation:fromLocation:

set locationManager to current application's CLLocationManager's alloc()'s init()
locationManager's setDelegate:me
locationManager's startUpdatingLocation()


-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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:
    • Script Editor's control-command-R (branched from Re: Can one get physical location via Applescript?)
      • From: 2551 <email@hidden>
References: 
 >Can one get physical location via Applescript? (From: Charles Arthur <email@hidden>)
 >Re: Can one get physical location via Applescript? (From: Nick Passmore <email@hidden>)
 >Re: Can one get physical location via Applescript? (From: Charles Arthur <email@hidden>)
 >Re: Can one get physical location via Applescript? (From: Shane Stanley <email@hidden>)
 >Re: Can one get physical location via Applescript? (From: Paul Fidler <email@hidden>)

  • Prev by Date: Re: Can one get physical location via Applescript?
  • Next by Date: Script Editor's control-command-R (branched from Re: Can one get physical location via Applescript?)
  • Previous by thread: Re: Can one get physical location via Applescript?
  • Next by thread: Script Editor's control-command-R (branched from Re: Can one get physical location via Applescript?)
  • Index(es):
    • Date
    • Thread