Help with Applescript, calling a function in a framework

Below not a complete script:

#!/usr/bin/osascript use framework "CoreWLAN"

calling a function, such as scanForNetworks(withSSID ssid)

Any pointer to documentation would be very helpful. I cannot find any guidance so far. I am reading the AppleScriptObjCQuickTranslationGuide page and it is helpful but I am still struggling.

Replies

AppleScript lets you call most Objective-C APIs via a technology known as AppleScriptObjC. In Objective-C you might write this:

@import CoreWLAN;

CWWiFiClient * client = [CWWiFiClient sharedWiFiClient];
CWInterface * interface = client.interface;
NSSet<CWNetwork *> * networks = [interface scanForNetworksWithSSID:nil error:nil];

which looks like this in AppleScript:

use framework "CoreWLAN"

set client to current application's CWWiFiClient's sharedWiFiClient
set interface to client's interface
set networks to interface's scanForNetworksWithSSID:(missing value) |error|:(missing value)

The go-to reference for this is the Objective-C to AppleScript Quick Translation Guide appendix in the Mac Automation Scripting Guide.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"