text
stringlengths
0
15.7k
source
stringlengths
6
112
property NSWorkspace : a reference to NSWorkspace of this
+utils.applescript
property interface : a reference to CWWiFiClient's sharedWiFiClient's interface
+utils.applescript
property Workspace : a reference to NSWorkspace's sharedWorkspace
+utils.applescript
property UTF8 : a reference to 4
+utils.applescript
property WEP104 : a reference to 2
+utils.applescript
property WiFiChannels : {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48}
+utils.applescript
on WiFiOn:state
+utils.applescript
tell the interface()
+utils.applescript
if state is not in [true, false, yes, no] ¬
+utils.applescript
then return its powerOn() as boolean
+utils.applescript
its setPower:state |error|:nil
+utils.applescript
WiFiOn_(null)
+utils.applescript
end WiFiOn:
+utils.applescript
on WiFiStrengths()
+utils.applescript
if not (its powerOn() as boolean) then return false
+utils.applescript
its scanForNetworksWithName:nil |error|:nil
+utils.applescript
set networks to the result's allObjects()
+utils.applescript
set SSIDs to networks's valueForKey:"ssid"
+utils.applescript
set RSSIValues to networks's valueForKey:"rssiValue"
+utils.applescript
NSDictionary's dictionaryWithObjects:RSSIValues forKeys:SSIDs
+utils.applescript
result as record
+utils.applescript
end WiFiStrengths
+utils.applescript
to joinNetwork given name:ssid as text, password:pw as text : missing value
+utils.applescript
local ssid, pw
+utils.applescript
set predicate to "self.ssid == %@"
+utils.applescript
set |?| to NSPredicate's predicateWithFormat_(predicate, ssid)
+utils.applescript
its setPower:true |error|:nil
+utils.applescript
set networks to {}
+utils.applescript
tell cachedScanResults() to if it ≠ missing value then ¬
+utils.applescript
set networks to filteredSetUsingPredicate_(|?|)
+utils.applescript
if the number of networks = 0 then set networks to ¬
+utils.applescript
(its scanForNetworksWithName:ssid |error|:nil)
+utils.applescript
set network to (allObjects() in networks)'s firstObject()
+utils.applescript
its associateToNetwork:network |password|:pw |error|:_1
+utils.applescript
set [success, E] to the result
+utils.applescript
if E ≠ missing value then return ¬
+utils.applescript
E's localizedDescription() ¬
+utils.applescript
as text
+utils.applescript
success
+utils.applescript
end joinNetwork
+utils.applescript
to createAdHocNetwork:{name:ssid as text ¬ , password:pw as text ¬ , channel:channel as integer}
+utils.applescript
local ssid, pw, channel
+utils.applescript
if channel is not in WiFiChannels then set ¬
+utils.applescript
channel to some item of WiFiChannels
+utils.applescript
interface()'s startIBSSModeWithSSID:((NSString's ¬
+utils.applescript
stringWithString:ssid)'s ¬
+utils.applescript
dataUsingEncoding:UTF8) ¬
+utils.applescript
security:WEP104 channel:channel ¬
+utils.applescript
|password|:pw |error|:_1
+utils.applescript
if E ≠ missing value then return E's localizedDescription() as text
+utils.applescript
end createAdHocNetwork:
+utils.applescript
on publicIP()
+utils.applescript
(NSString's stringWithContentsOfURL:(NSURL's ¬
+utils.applescript
URLWithString:"https://api.ipify.org/") ¬
+utils.applescript
encoding:UTF8 |error|:nil) as text
+utils.applescript
end publicIP
+utils.applescript
on externalIP()
+utils.applescript
publicIP()
+utils.applescript
end externalIP
+utils.applescript
on battery()
+utils.applescript
script battery
+utils.applescript
use framework "IOKit"
+utils.applescript
property parent : this
+utils.applescript
on info()
+utils.applescript
IOPSCopyPowerSourcesInfo() of this
+utils.applescript
end info
+utils.applescript
end script
+utils.applescript
battery's info()
+utils.applescript
end battery
+utils.applescript
on defaultBrowser()
+utils.applescript
(NSWorkspace's sharedWorkspace()'s ¬
+utils.applescript
URLForApplicationToOpenURL:(NSURL's URLWithString:"http:"))'s ¬
+utils.applescript
lastPathComponent()'s stringByDeletingPathExtension() as text
+utils.applescript
end defaultBrowser
+utils.applescript
on colour at {x, y}
+utils.applescript
local x, y
+utils.applescript
if {x, y} contains null then set {x, y} to {"mouseLoc.x", "mouseLoc.y"}
+utils.applescript
set coords to [x, ",", space, y] as text
+utils.applescript
run script "
+utils.applescript
ObjC.import('Cocoa');
+utils.applescript
var mouseLoc = $.NSEvent.mouseLocation;
+utils.applescript
var screenH = $.NSScreen.mainScreen.frame.size.height;
+utils.applescript
mouseLoc.y = screenH - mouseLoc.y;
+utils.applescript
var image = $.CGDisplayCreateImageForRect(
+utils.applescript
$.CGMainDisplayID(),
+utils.applescript
$.CGRectMake(" & coords & ", 1, 1)
+utils.applescript
);
+utils.applescript
var bitmap = $.NSBitmapImageRep.alloc.initWithCGImage(image);
+utils.applescript
$.CGImageRelease(image);
+utils.applescript
var color = bitmap.colorAtXY(0,0);
+utils.applescript
bitmap.release;
+utils.applescript
var r = Ref(), g = Ref(), b = Ref(), a = Ref();
+utils.applescript
color.getRedGreenBlueAlpha(r,g,b,a);
+utils.applescript
var rgba = [r[0]*255, g[0]*255, b[0]*255, a[0]];
+utils.applescript
rgba;" in "JavaScript"
+utils.applescript
end colour
+utils.applescript
on colorAt(x, y)
+utils.applescript
colour at {x, y}
+utils.applescript
end colorAt
+utils.applescript
on mouse to {x, y}
+utils.applescript