Re: keystroke command
Re: keystroke command
- Subject: Re: keystroke command
- From: Robert Poland <email@hidden>
- Date: Mon, 29 May 2006 15:50:04 -0600
On 29 May 2006, at 19:18, Michelle Steiner wrote:
On May 29, 2006, at 10:40 AM, Robert Poland wrote:
I have implemented Michelle's suggestion,
For me, your suggestion selects all of the DESKTOP items, even if
I do as follows;
activate application "Finder"
tell application "System Events"
tell process "Finder" to tell window 1
keystroke "a" using {command down} -- select all
end tell
end tell
It will select all in the front window; if there isn't an open
window, it will select all the desktop items.
It will also select all desktop items if a Finder window is open but
isn't frontmost (if you open a Finder window, then click on the
desktop, for example). So, as well as bringing the app to the front,
it's also worth making sure the Finder window is raised to accept
the keystroke command:
----------------
tell application "System Events" to tell process "Finder"
set frontmost to true
tell window 1 to if exists then
perform action "AXRaise"
keystroke "a" using {command down}
end if
end tell
----------------
As Bill says, though, Michelle's original suggested selection method
is preferable.
That said, Bob mentioned that his ultimate goal was to "set index
labels". If you could let us know specifically what you mean by
that, Bob, I have a feeling there might be a way to achieve it
without having to select any items at all.
---
kai
Here is the "Finished" script, I run it with an iKey command.
tell application "Finder"
if exists Finder window 1 then -- make sure there is a window
(* use variable for window so script doesn't get
confused. Use "finder window" instead of "window" so if the front
window in the Finder is an info window, the clipboard, a clipping
window, etc., the script will work properly. *)
set wdw to Finder window 1
if selection is not {} then
set colorchoice to (label index of item 1 in
(get the selection))
set colorchoice to colorchoice + 1
else
set colorchoice to 1 -- no selection, default to "none"
end if
else
tell application "System Events"
activate
beep
display dialog "There is no Finder Window"
buttons "OK" default button 1 giving up after 2
return
end tell
end if
set theColorList to {"none", "orange", "red", "yellow",
"blue", "purple", "green", "gray"}
set theDefaultList to text item colorchoice of theColorList
(* 0 = none , 1 = orange, 2 = red, 3 = yellow, 4 = blue, 5 =
purple, 6 = green, 7 = gray *)
set theChoice to (choose from list theColorList default items
theDefaultList with title "Color Selection" with prompt "Option key
to select entire folder.")
if (theChoice is false) then return -- "User canceled."
-- get color selected
repeat with i from 1 to number of items in theColorList
if item i of theColorList is in theChoice then set
myLabelIndex to i - 1
end repeat
if (keys pressed) contains "Option" then
tell application "Finder"
select items of the front window
end tell
end if
repeat with eachItem in (get selection)
set the label index of eachItem to myLabelIndex
end repeat
select {} -- deselect items
beep
end tell
--
Bob Poland - Fort Collins, CO
http://www.ibrb.org/
_______________________________________________
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