Macに内蔵/接続されている無線LAN(WiFi)デバイスのパワー(電源)をオン/オフ操作するAppleScriptです。
AppleScript名:WiFiデバイスのパワーを操作 |
— Created 2015-08-18 by Shane Stanley — Modified 2019-03-06 by Takaaki Naganoya use AppleScript version "2.4" –macOS 10.10 or later use scripting additions use framework "Foundation" use framework "CoreWLAN" property CWInterface : a reference to current application’s CWInterface –Power On WiFi set w1Res to powerControlEveryWiFiDevices(true) of me delay 5 –Power Off WiFi set w2Res to powerControlEveryWiFiDevices(false) of me on powerControlEveryWiFiDevices(aFlag as boolean) set allNames to CWInterface’s interfaceNames()’s allObjects() as list if allNames = {} then return false set powerList to {} repeat with i in allNames set j to contents of i set aInterface to (CWInterface’s interfaceWithName:j) set wRes to (aInterface’s setPower:aFlag |error|:(missing value)) –Get Power state and check it set aPower to (aInterface’s powerOn()) as boolean if aPower = (not aFlag) then if aFlag = true then set aStat to " on " else set aStat to " off " end if display notification "Error occured in power" & aStat & "an Wifi deviece ( " & j & " )…." end if set the end of powerList to aPower end repeat return ({aFlag} is in powerList) –return whether some WiFi interface is on/off end powerControlEveryWiFiDevices |