Changing Google Chrome tabs with some Applescript

I have a good old Microsoft trackball with forward/backward thumb and pinkie mouse buttons which I use to move to the next/previous tab in Safari and Terminal.

Living without this functionality on OSX is not possible. The only link I found was not very helpful, so here is the Applescript I wrote:

Next tab:

tell application ”Google Chrome”

 set maxIndex to count tabs of (first window)

 set currentIndex to active tab index of (first window)

 set proposedIndex to currentIndex + 1

if proposedIndex < 1 then set proposedIndex to maxIndex

if proposedIndex > maxIndex then set proposedIndex to 1

set (active tab index of (first window)) to proposedIndex

end tell

Previous tab:

tell application ”Google Chrome”

set maxIndex to count tabs of (first window)

set currentIndex to active tab index of (first window)

set proposedIndex to currentIndex - 1

if proposedIndex < 1 then set proposedIndex to maxIndex

if proposedIndex > maxIndex then set proposedIndex to 1

set (active tab index of (first window)) to proposedIndex

end tell

 

This will cycle around your tabs (useful if you have only one spare mouse button).


To remove that function, simply change the boundary tests to:

 

if proposedIndex < 1 then set proposedIndex to 1

  if proposedIndex > maxIndex then set proposedIndex to maxIndex

3 notes

Show

  1. guylhem posted this

Blog comments powered by Disqus