GUI Scripting Pummels Noob

As of today, I’m a UI Browser fiend.
While it’s really helped me identify all the elements in a given window I’m having trouble getting a popup button to do what I want.

Internet Connect gives you the option of connecting to existing wirelss networks or “Other…”
While I’ve succeeded in identifying the popup button and its path (a huge victory for me) I can’t seem to find a way to get it to click on “Other…”
Here’s as far as I’ve come.

tell application "Internet Connect"
	activate
	tell application "System Events"
		tell window 1 of process "Internet Connect"
			select menu item "Other..." of pop up button 1 of menu item 1
		end tell
	end tell
end tell

When I run the script I get the NSReceiverEvaluationScriptError: 4 and the “select menu item…” line comes back highlighted.
After endless variations diddling that line, I’m throwing in the towel.
Thanks

I do see a problem, but I’m not sure how you’re getting that far. That said, this works for me:

tell application "Internet Connect"
	activate
	tell application "System Events"
		tell window 1 of process "Internet Connect"
			click button 2 of tool bar 1
			tell pop up button 1
				perform action "AXPress"
				click menu item "Other." of menu 1
			end tell
		end tell
	end tell
end tell

The problem is you’re not referencing the right menu item. You’re say menu item “Other…” when it’s actually “Other.”. What’s the difference? You’re using three periods, but the menu item uses an ellipsis (try and select, you’ll see it’s only one character). You can type an ellipsis by pressing option+semicolon. (Nearly all menu items and dialogs them.)

Thanks Bruce.
I changed “click button 2 of tool bar 1” to “click button 3 of tool bar 1” so it would bring up the AirPort window instead of the Internal Modem window.
When I ran your script with this modification it did exactly what I’d been trying to accomplish.

Am I correct in assuming that when you’re trying to get a popup button to pay attention that instead of telling it to “click” you tell it to “Perform action AXPress?”
(I tried everything I could find then made up a few of my own commands, to no avail)
If so, where does one find the “perform action” and “AXPress” commands?

You mentioned that you weren’t sure how I got this far.
Maybe this will answer it.
The reason why I’m futzing with this is when our laptops wake up there are times when they can’t reconnect to our wireless network.
I actually think this is an issue with my router and I haven’t figured out how to solve it gracefully–so I just walk upstair and unplug the thing then plug it back in.

But I’ve discovered that the following routine works more often than not and saves me the trip upstairs:
I open Internet Connect, click the “Turn Airport Off” Button, then click “Turn Airport On.”
If I don’t automatically connect I click (or should I say “AXPress”) the Network popup button and select “Other.”
This brings up the Airport window.
I either select my network if it’s listed, or if it’s not listed I type it in manually.
Then I select my security type and manually type in my password.
That does the trick.

If this hasn’t bored you witless yet, I’m trying to script this entire process.
The first stumbling block I hit was not knowing how to write an if/then subroutine that will recognize whether the AirPort Power is on or off.
If it’s off I need to turn it on.
If it connects automatically the script should terminate.
If it doesn’t connect then the script should proceed to the section you supplied me with.
After that I need to figure out how to tell it to automatically fill in the “Network Name” box, select my flavor of security, automatically enter the password, and click OK.

Now that I have the piece you sent me, I plan to flail away at this last bit.
Bravo if you’ve soldiered on this far.
And thanks again.
-G

Sorry to see you are still having wireless trouble.

To add the network name, do this:

tell application "Internet Connect"
	activate
	tell application "System Events"
		tell window 1 of process "Internet Connect"
			click button 2 of tool bar 1
			tell pop up button 1
				perform action "AXPress"
				click menu item "Other." of menu 1
				set theName to "whatever"
				keystroke theName
				delay 1 --you might need this to prevent the next button click from happening too quickly
			end tell
		end tell
	end tell
end tell

I needed the delay in a different situation. If you are interested, see the script in my last post here - http://bbs.applescript.net/viewtopic.php?id=17319

j

If you have Bluetooth enabled, then it needs to be button 3 instead of 2:


tell application "Internet Connect"
   activate
   tell application "System Events"
       tell window 1 of process "Internet Connect"
           click button 3 of tool bar 1
           tell pop up button 1
               perform action "AXPress"
               click menu item "Other." of menu 1
               set theName to "whatever"
               keystroke theName
               delay 1 --you might need this to prevent the next button click from happening too quickly
           end tell
       end tell
   end tell
end tell