Faster to write a script than to deal with so many browser windows? Well, certainly more fun :)

AppleScript to move Safari windows up as much as the window closest to the top of the screen will allow.

There’s a bug in Safari 15.0 where it sometimes re-positions open windows when waking from sleep by moving all the windows down an amount such that the bottom of the lowest one is at the bottom of the monitor (or something like that? They all move down a lot).

If happen to place your Safari windows up enough so that another app’s window can be visible on-screen under them (chat in my case), and you have a few too many windows open in Safari (ahem!), then you might be very annoyed to have to over a hundred windows all back up again.

Now, you could go through your heap of open Safari windows, but if you’re a programmer than you might (likely incorrectly ;)) think it’d be faster to write an AppleScript to move them all back up again. Not that I’d do such a thing, you understand, but, purely for educational purposes, here’s the kind of script one might write (or the second version if the first one took 6 minutes process the > 100 Safari windows you had open) :). This one moves all Safari windows up the same amount to keep their relative positioning and moves them up as much as possible while still keeping the window positioned highest on the screen below the menu bar.

Disclaimer: I write zero to two AppleScripts a year and never really learned AppleScript. There’s almost certainly better ways to do this. But it works for me and fixes my windows after Safari munges them again. So GoodEnough‚ĄĘ ūüôā

-- Put in the public domain with zero warranty of any kind
-- only tested on macOS 11.6, with Safari 13.0; ymmv

use scripting additions

tell application "Safari"
  set windlist to windows
  log "Examining " & length of windlist & " windows..."
  set lowestYWindow to first item of windlist
  set lowestYValue to get second item of (get bounds of lowestYWindow)
  repeat with wind in windlist
    set curValue to second item of (get bounds of wind)
    if curValue < lowestYValue then
      copy wind to lowestYWindow
      set lowestYValue to curValue
    end if
  end repeat
  -- subtract out the title bar height (hard coded - bad dog!)
  set yOffset to lowestYValue - 25
  if yOffset > 0 then
    log "moving " & length of windlist & " windows up " & yOffset & " pixels"
    repeat with aWind in windlist
      set aBounds to (get the bounds of aWind)
      set the second item of aBounds to ((get the second item of aBounds as integer) - yOffset)
      set the fourth item of aBounds to ((get the fourth item of aBounds as integer) - yOffset)
      set the bounds of aWind to aBounds
    end repeat
    display alert ("The highest window already at the top!  Not moving any windows!")
  end if
  log "done"
end tell

Here it is in a gist for easier copy/edit, etc.

iOS Email tip: support for email aliases

I don’t know why I didn’t think of this, but I use email aliases pretty extensively for my various businesses – things like,¬†(1) and a few to track which companies sell my email address (such as, which they haven’t sold so they pass the test :)). ¬†This works great on OS X – just put the addresses comma separated in the Email Address field in the account setup in and they all show up as usable “from” addresses you can choose from when composing your emails. ¬†But the cool part is you only have the single root email box to check & look through.

I’d not found a way to do this on iOS (no comma on the keyboard when you enter the Email Address field, just for starters) and my (painful) work-around was to set up dummy email accounts but iOS kept prompting me for passwords for them which was a serious pain in the neck!

Today I griped on twitter about this not being fixed in iOS and @rdsquared pointed out that I was being an idiot and that you simply create the string of email addresses in notepad (or whatever) as,,, then copy this string and paste them into the Email field in the mail account setup screen in Settings. ¬†BINGO! ¬†Works great so I owe¬†@rdsquared a Guinness and you should buy him one also if this is useful to you ūüôā

Thanks @rdsquared!

(1) All email addresses used in this post are fictitious.  Any resemblance to real persons or email addresses, living or dead, is purely coincidental.

Address Book Search Unresponsive Fix

Address Book app in OS X 10.7 Lion stopped working – type in a search string and hit return and nothing happens. VERY annoying. This is synced via iCloud and the fix was to:

  • archive the address book (File -> Export -> AddressBook Archive)
  • go to System Preferences -> iCloud and uncheck Addresses and choose to Delete them from this computer when prompted.
  • Wait a second or two
  • Recheck Addresses in iCloud syncing
  • Wait 20-30 seconds for iCloud to resync them and voila, fixed!

(If you aren’t syncing from iCloud probably the export, then delete the address book file and then import archive will also work, but that’s a guess).

Xcode 4.x tip – how to get a separate working debugger window

Just figured this out today after trying once before. ¬†If you have a multi-monitor setup like I do you may like to have the console & debugger be in a separate window. ¬†Xcode 4 moved to a predominately single window interface which is a bummer for multi-monitor setups. ¬†I tried opening a new window and collapsing all but the debugger / console panes but the console wouldn’t take commands and was effectively useless..

Turns out there is a trick menu item:  View -> Debug Area -> Activate Console 

So with the cursor in the console in the second window, select the above mentioned menu item and Bingo! a working debug / console view in a separate window. sweet!


Now to file an enhancement request for a behavior to open a separate window and configure it like this automatically ūüôā

Indie Developers: Put a link to your website in help menu!

It happens too often: I open an application because I can’t remember the company name or website address and found that there is no place in the application to get to the website. This is crazy!

This usually happens for those small applications that I don’t use often, but that I think are useful (I won’t name any names here, but if you’ve been in a MacHeist bundle you might check your application for this omission).

Put a link to the website in your about box. Put a “Visit” menu item in your Help menu or in your Application menu if you don’t have a help menu. ¬†(ok ok, use your own domain, but you get the idea :-)).

This is a critical element of your marketing campaign. Yes, automatic checking for updates is a good thing and you need that. ¬†But what if I’m wondering if you have any other products I might be interested in? What if I want to tell a friend about your product and want the URL to copy and paste into an email to them?

You should also include a way to report a bug or get support. ¬†Now this might take the user to a forum (as a user I hate forums, especially if I have to “join” or “register”), or open a new email message ¬†in the default mail application, or take me to a form on your website. Whatever it is, you need something easy and visible to the user. ¬†This is how you are going to get ideas for future versions. ¬†This is how you are going to impress your customers with your incredible support – the kind of impression that gets them to talk to their friends about your application and increases your sales.

ok. off my soapbox. have a nice day.

Useful looking utility answers question: “where did all my disk space go?”

OmniDiskSweeper is a utility for quickly finding and deleting big, useless files and thus making space on your hard disks.

I’ve spent time doing this in the finder the slow painful way far too often. ¬†I wonder if this is faster than the Find all files/folders whose size is greater than X Gig/Meg that I’ve used. ¬†Spotlight (on 10.5) isn’t all that fast at these kind of searches…

Well, something I’m going to try out.

And it’s free! Thanks OmniGroup!

Startup Weekend was very fun!

Dad participated in Startup Weekend in Portland last weekend and while it was intense, it was really fun.  They are doing it in Seattle weekend after next, and in cities all over the US; back in Portland in 6 months.

and particularly:

The $75 admission fee is really not bad considering the number of meals they provide.