I use Alfred to do a plethora of things on my mac, and while it works well as an application launcher, that's merely the tip of the iceberg. I could go into a laundry list of things I use it for, but this particular post I'll focus on Screen Sharing. I've used Screen Sharing a lot as a time saver for either technical support for friends, or to access other computers on my local network. It's easy enough to go to that networked computer in Finder, click Screen Share, enter your password, and viola! However, doing that hundreds of times grew cumbersome. Knowing I wasn't the first person to think of using AppleScripting to do this, I turned to the internets and found someone who'd beat me to it. Thankfully Alfred can also run those scripts from itself with a simple key command, so it was a matter of copy/paste, change computer name, and good to go.
However in Mountain Lion, they've changed something with the way that System Events calls windows, and suddenly all my (two-dozen or so Screen Share commands don't work anymore. After some tinkering and trial & error I discovered this fix:
Turns out, if you call the application Screen Sharing twice, it will bring the dialog box back to front focus so it can allow System Events to run it's magic and get you logged in. I've also added a bit at the end that runs after a 2-Second delay that turns it to a fullscreen instance so it's able to run at maximum resolution. If you've got it setup properly in Alfred it should look something like this:
That's it, I hope it was helpful, and again I'm by no means anything more than a tinkerer when it comes to this kind of stuff, so if you know of a better way, I'd love your insight.
➤ Update
Jeroen let me know in his comment of a way he'd made his AppleScripts work in Mountain Lion to get Screen Sharing working, and it got me thinking of ways that I could do this in a different way on a deeper level without having to do the login auth. I discovered you can actually cut out a ton of the rigamarole by doing the following:
Not sure why I hadn't thought of it before, but you can use vnc:// almost anywhere in OS X to start a Screen Sharing session (you can even type it into Safari). This cuts out a ton of the lines from my original script, launches instantly without the dialog box, and I wouldn't have thought of it without Jeroen's comment.
Thanks again man!