|
#1
| ||||
| ||||
| i know that it's so simple, but i can't get to close the current frontmost window using applescript, i'd like to assign this action to a button of my mighty mouse who could help me? thanks
__________________ 3mors ------------------------------------------------------ iMac G5 20"/MacBook Pro 17"/PowerBook G4 ------------------------------------------------------ |
|
#2
| ||||
| ||||
| The easiest way would be to simulate command-W. You can do this in AppleScript using System Events, like so: Code: tell application "System Events" to keystroke "w" using command down |
|
#3
| ||||
| ||||
| i've just tried and it doesn't work, no message error shown [edit] mmm strange, it works if i run it from script editor, but not as app standalone i think it's because it tries to send CMD+W keystroke to the script itself and not to the frontmost window
__________________ 3mors ------------------------------------------------------ iMac G5 20"/MacBook Pro 17"/PowerBook G4 ------------------------------------------------------ |
|
#4
| ||||
| ||||
| Yeah, that would be it. Can't you have it just activate a script, rather than an applet? I'm not all that familiar with Apple's driver. You could use a third-party driver like USB Overdrive to simulate the keystroke itself. I'm not sure launching an applet would be responsive enough for such a task, but there is a way to get around the problem you have: Make your applet an "invisible" app that doesn't show up in the Dock or get focus. You can do this by saving this script as an Application Bundle (not as just "Application"), and then editing its Info.plist to include this right after the first <dict> tag: Code: <key>LSUIElement</key> <string>1</string> But again, I doubt it would be responsive enough. |
|
#5
| ||||
| ||||
| sorry, but i can't get it to work
__________________ 3mors ------------------------------------------------------ iMac G5 20"/MacBook Pro 17"/PowerBook G4 ------------------------------------------------------ |
|
#6
| ||||
| ||||
| What OS version are you running? I think it ought to work in Panther or even Jaguar, but I'm not sure I ever tested it before Tiger. Anyway, try the attached applet. Works for me. |
|
#7
| |||
| |||
| Quote:
__________________ Dennis R. Metzcher MyMacBlog.com: My experiences with the Mac OS, a switcher's point of view. With a new Mac tip each week day. |
|
#8
| ||||
| ||||
| a non-specified frontmost window: i'd like to assign this script to the middle button of my mighty mouse as i've done with my logitech mouse (using the logitech driver) in order to close the frontmost window of the app i'm using otherwise i need to use a third-part apps such as usboverdrive, but i'd like to avoid it the app you posted doesn't work ![]()
__________________ 3mors ------------------------------------------------------ iMac G5 20"/MacBook Pro 17"/PowerBook G4 ------------------------------------------------------ |
![]() |
| Thread Tools | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Applescript detecting file or app open/close? | driftwolf | Software Programming & Web Scripting | 3 | September 18th, 2005 12:58 AM |
| applescript to close and trash topmost document | tench | Mac OS X System & Mac Software | 0 | May 20th, 2004 04:28 AM |
| How to close the Terminal window after a while using AppleScript? | voice- | Software Programming & Web Scripting | 3 | December 23rd, 2003 01:37 PM |
| Does anyone else wish they could close a window with expose? | Fahrvergnuugen | Mac OS X System & Mac Software | 17 | July 27th, 2003 06:54 PM |