Re: keystroke command
Re: keystroke command
- Subject: Re: keystroke command
- From: Bill Cheeseman <email@hidden>
- Date: Mon, 29 May 2006 13:34:30 -0400
- Thread-topic: keystroke command
on 2006-05-29 1:03 PM, Robert Poland at email@hidden wrote:
> In my quest to improve a script to set index labels I have hit a new snag...
>
> tell application "Finder"
> activate
> if (keys pressed) contains "Option" then beep -- this line
> breaks the following
>
> -- the following assumes a window is open in the Finder
> -- this is used as the command "Select all" doesn't seem to
> work with a finder window
> tell application "System Events"
> keystroke "a" using {command down} -- select all
> end tell
> end tell
>
> Why isn't the keystroke command allowed?
What Michelle said is the best solution.
But to answer the question you actually asked, you neglected to nest a 'tell
process "Finder"' block inside the 'tell application "System Events"' block.
You should do this whenever you use GUI Scripting, including the 'keystroke'
command.
Leaving out the 'keys pressed' test, this works:
activate application "Finder"
tell application "System Events"
tell process "Finder"
keystroke "a" using {command down} -- select all
end tell
end tell
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden