Showing posts with label xGestures. Show all posts
Showing posts with label xGestures. Show all posts

Wednesday, June 17, 2009

Closing the tab that you gestured over

Hey, remember this blog?  I barely do.

I just solved an interesting xGestures problem someone posed to me: how can they get it so that the tab they gesture over is closed, rather than making a gesture type Command-W, thus closing whichever tab is active?  Furthermore, how can they close tabs when Safari is in the background?

To solve it, I wrote an AppleScript that should do exactly that.  Maybe someone else will find it interesting.  The thing to remember about xGestures is that it can have practically any behavior you want by using AppleScript.  The problem is that writing AppleScripts is really only an option for people who are already programmers and have the time and inclination to learn to write them.  So I'll keep posting the interesting ones I write.

Here's the script:

set x to mouse x
set y to mouse y
tell application "Safari"
set targetWindow to {}
set theWindows to the windows
repeat with i from 1 to the count of theWindows
set theBounds to bounds of item i of theWindows
if x ≥ item 1 of theBounds and x ≤ item 3 of theBounds and y ≥ item 2 of theBounds and y ≤ item 4 of theBounds then
if targetWindow ≠ {} then
if index of item i of theWindows <>
set targetWindow to item i of theWindows
end if
else
set targetWindow to item i of theWindows
end if
end if
end repeat
if targetWindow ≠ {} then
close current tab of targetWindow
end if
end tell

This script requires the XTools scripting addition because otherwise there's no way to get the mouse location in an AppleScript.  XTools can be downloaded here: http://osaxen.com/files/xtool1.1.html

Monday, November 26, 2007

Updated xGestures again / USB Overdrive trick

New version of xGestures - 1.73.  It's a bug fix release, so no new awesome features this time.  This version should fix all of the hot corners and Dock related problems Leopard users have been having, as well as several other Leopard bugs.

I still haven't had a chance to fix the Wacom tablet problem, but it's still on my list of things to do, as well as several other things.  I plan to release at least one more version of xGestures in the not too distant future that fixes the rest of the bugs people have been complaining about off and on, as well as adding some Leopard specific features for things like Spaces and Time Machine.

(Incidentally, if you want to have gestures for those now, you can set xGestures to keystroke any of the various Spaces keystrokes.  You will have to temporarily change them to something different before you enter them into the xGestures pref pane, since otherwise they'll just switch the screen space and the pref pane won't register the keystroke.  But just change the Spaces keystrokes back again afterwards and it should work great.)

Also, for users using USB Overdrive:  Someone recently emailed me asking how they could use one of their really auxilery mouse buttons with xGestures and USB Overdrive at the same time.  (In this case it was mouse button #7.)  The problem is, USB Overdrive only allows mouse clicks up to button #5.  But you can work around that by having USB Overdrive do a keystroke for the button you want to use, and then set xGestures to use that keystroke for gesturing.  It works great!

Granted there's probably not a lot of people who'll find that tip useful, since it involves using both USB Overdrive and wanting to use an abnormally high button number to gesture.  But I thought it was especially clever, and it was useful to at least one person out there.