Moving the dock by Shortcut?

Is there a way to to automate moving the dock to another position without going to System Preferences?
When I’m working in Excel I often evoke the Dock by accident when I’m selecting rows on the left (where I have my dock). I was thinking moving the dock to the right side while I’m in Excel would be great. Any ideas?
Not good at automation yet, but willing to learn. Can you do this with Automater?

I believe you can use Keyboard Maestro to trigger a shell script that activates when Excel is launches/quits. So, you could create two macros: one that triggers when excel is launched and one that triggers when it is closed. Of course this assumes that you have Keyboard Maestro. See an example shell script here.

1 Like

I’m eyeing Keyboard Maestro for a while now. This little problem might push me over the fence to finally buy it.
Since some excel window might be open somewhere, I think a keyboard shortcut might be better than a fully automated solution.

gotta check out KM:)

Right Click on the line in the Dock to move it.
Screen Shot 2020-09-01 at 8.50.09 AM

Great that is really fast!!! Thanks WayneG!!!

1 Like

Doh! I assumed you wanted an automated solution. That is my fault for not reading closely. @WayneG’s solution is much simpler if it does not need to be automated. :slight_smile:

No worries, an automated solution is of course more elegant and even better (ie I started a Keyboard Maestro trail…)

1 Like

Here’s an AppleScript which will toggle the position between left and right:

tell application "System Events" to tell dock preferences
	if screen edge is right then
		set screen edge to left
	else if screen edge is left then
		set screen edge to right
	end if
end tell

I use the keyboard shortcut ⌥ D (because ⌘⌥ D is “Show/Hide Dock”) in Keyboard Maestro (c’mon, why don’t you own this app yet?!)

With Keyboard Maestro you could either move it to the right when Excel launches and move it back when Excel quits, or you could just move it when Excel is the front-most app and move it back when it is not.

Or just trigger it manually.

Keyboard Maestro Trial and Discount

Source: https://learnomnifocus.com/app/keyboard-maestro/

Stairways Software , the creators of Keyboard Maestro, have kindly offered a 20% discount to everyone in the Learn OmniFocus community. Enter the coupon code LOF20 when purchasing Keyboard Maestro to apply the discount. You can also download and test drive Keyboard Maestro before purchasing.

My biggest regret of my “Mac Life” is not getting started with Keyboard Maestro sooner.

It has a 30 day trial. Download and use it for 30 days and you’ll happily pay for it.

Also, the two best forums on the Mac web are MPU and http://forum.keyboardmaestro.com

4 Likes

Just did it with Keyboard Maestro!!! Feels like magic!
The fact to have set it up by oneself (with tons of help for you awesome guys) is so gratifying.

Thanks everyone!

1 Like

Great! I agree. I wish I would have started sooner. Now that you are using Keyboard Maestro, you will find all sorts of uses. I would be very sad if it went away.

I’ve updated my AppleScript so that pressing ⌥ D repeatedly will cycle through the options:

left » bottom » right » left, etc

tell application "System Events" to tell dock preferences
	if screen edge is bottom then
		set screen edge to right
	else if screen edge is right then
		set screen edge to left
	else if screen edge is left then
		set screen edge to bottom
	end if
end tell
2 Likes

That is fantastic, really cool! Thanks for the work!

Loving Keyboard Maestro and have made several Safari macros that make it easier to navigate the web apps we use at work!

2 Likes