Automator Trouble

Joined
Oct 17, 2013
Messages
88
Reaction score
1
My laptop has had a small glitch for a long time: After having been shut off it doesn’t find my local wifi automatically so I have to scroll down to find the correct system, click on it and enter the password. Not a big deal but a bit annoying. At an Apple store I was told the glitch could not be easily fixed and I’d have to leave the computer for a few days. It’s not worth the trouble. Instead I have recorded an Automator file to open the wifi for me. And here’s my question. Automator works a majority of the time but just a bare majority. Why not all the time? What could cause it to either fail to click on the right wifi system or fail to type in all of the password? And how does one fix errors like that? Yes, I have tried re-recording the file — to no avail.
 
Joined
Jan 25, 2017
Messages
1,266
Reaction score
100
Is the automator file run at boot up or is it started manually? Could you post a listing of your code?
 
Joined
Oct 17, 2013
Messages
88
Reaction score
1
i guess it's a macro, although that term never came up. I turned on Automator and recorded series of actions: Click on the Wifi symbol on the menu bar, scroll down to my network (it's at the bottom of the list) click on it, type in the password when that screen comes up and hitting "Enter." Simple. But half the time Automator doesn't click on my network and half the time it only enters part of the password. And then it sits there and I have to force quit.
 
Joined
Jan 25, 2017
Messages
1,266
Reaction score
100
I tried this out and both manually and with the app as a log in item and it has worked flawlessly every time.
It could be a timing issue, try slowing down the playback to see if that helps.
 
Joined
Jan 25, 2017
Messages
1,266
Reaction score
100
OK, I have sorted out an applescript that will do this.
Copy and paste this code into the applescript editor, change the SSID and Password to your own (leave the quotation marks in) and then export the script as an application. Let me know if you have any problems.

Code:
tell application "System Events"

    tell process "SystemUIServer"
       
        click (menu bar item 1 of menu bar 1 whose description contains "Wi-Fi")

        click menu item "your_SSID_here" of menu 1 of result

        tell text field 1 of window 1


            tell pop up button 1

                delay 0.5 -- wait for password field to appear

                keystroke "your_password_here"

                delay 0.1

            end tell

            keystroke tab
            keystroke tab
            keystroke tab
            keystroke tab
            keystroke tab

            tell application "System Events" to key code 76

        end tell

    end tell

end tell
 
Joined
Oct 17, 2013
Messages
88
Reaction score
1
Hmm, I keep getting an error message. The first few times the quote marks before my network name was highlighted. Dunno why. I deleted it and put in another quote mark and then the error massage had a problem with the password number. The error message says:
"Syntax error. Expected end of line, etc. but found unknown token"
 
Joined
Jan 25, 2017
Messages
1,266
Reaction score
100
What OS are you using? I am using Mojave (10.14.6) if you are on an earlier OS that might account for it. I will do some investigation.
 
Joined
Oct 17, 2013
Messages
88
Reaction score
1
Nope: Mojave 10.14.6. Look, I appreciate your help but please don't waste a lot of time on this -- unless you view it as a challenge -- because it is really not that much of a hardship for me to manually do what Automator or Applescript won't. I can understand, though, that there really is fun in figuring out this kind of challenge.
 
Joined
Jan 25, 2017
Messages
1,266
Reaction score
100
Yes it is a challenge and it is good for learning as it is a real life situation, plus I have a lot of spare time on my hands :p:cool:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top