How to perform actions on the 'unstable' wifi menu

Hi Guys,

I'm struggling to find a way to automate an action I want to perform on the Wifi menu in the top menu bar and wondered if anyone could help.

I have a Cisco Homekit network box which for various reasons can only be accessed using the 'Join other network' menu at the bottom of the dropdown list of wifi networks you see when you click on the Wifi icon in the top menu bar.

I'm trying to create a macro which will allow me to automatically open this box and enter the details I want, but I'm struggling to find a way to open the menu using KM. My initial thought was to use the 'move and click mouse' action but the wifi menu is always getting longer and shorter as new networks are discovered and lost (I live in a built up area and my machine is always picking up and losing my neighbours' wifi networks). This means it's impossible to get an absolute pixel depth on where the 'Join other Networks' button should be relative to the main screen.

I haven't had any luck using the 'Click at Found image' with a screen grab of the button either, but I'm not too experienced with this approach so it may be something I'm doing wrong.

For what it's worth I've had a look to see if there are any AppleScript methods to open this dialogue box but I think it's too obscure to warrant inclusion in AppleScript dictionaries,

Anyway, any thoughts/pointers gratefully received.

Thanks in advance for any help (and keep up the good work in the forum)


Hey Rob,

If you're on an English Language system then this should get you started.


Download ⇢ Join Another Network via WiFi Menu.kmmacros (5.5 KB)

1 Like

Am I right in thinking you wish to join a wireless network by SSID name ? I wonder if this AppleScript will negate the need to open the Join Other Network... dialog box or type in your network SSID.

I cannot guarantee it will as I have no way to test it under similar conditions to your own, as my Wi-Fi network broadcasts its SSID and I don't wish to change that setting right now.

Judging from the name of the method being invoked, namely scanForNetworksWithName, I'm fearful it won't work. But it can't hurt to try.

use framework "CoreWLAN"

property SSID : "foo bar" -- The name of the Wi-Fi network to join
property pw : "password"  -- The password for the Wi-Fi network

set currentInterface to current application's CWInterface's interface()
-- Turn Wi-Fi power on:
currentIntegerface's setPower:true |error|:(missing value)

set [Network] to (currentInterface's scanForNetworksWithName:SSID ¬
	|error|:(missing value))'s allObjects()

currentInterface's associateToNetwork:Network password:pw ¬
	|error|:(missing value)

Hi Chris,

That's great - works a treat. Thanks so much. I clearly underestimated AppleScript, It's impressive how deep it's tendrils go. This will save a whole bunch of fiddling around, so a very big thank you to you.

Thanks also to CJK for your response. I haven't dug into your code too much as Chris' one worked out of the box, but thanks anyway for taking the time to give an alternative.

Cheers to you both and all the best


1 Like

I just found another method, which will scan for hidden networks as well, so that should do what I feared the method before would not:

set [Network] to (currentInterface's scanForNetworksWithName:SSID ¬
	includeHidden:true |error|:(missing value))'s allObjects()