• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Keystroke question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Keystroke question


  • Subject: Re: Keystroke question
  • From: Yvan KOENIG <email@hidden>
  • Date: Sun, 22 Nov 2015 19:24:56 +0100


Le 2015/11/22 à 18:38, Robert Poland <email@hidden> a écrit :


On Nov 22, 2015, at 10:10:AM, Yvan KOENIG <email@hidden> wrote:


Le 2015/11/22 à 18:05, Robert Poland <email@hidden> a écrit :

Hi,

The line;
tell application “System Events” to keystroke “f” using {option down}

gets me the Application ‘Searching “This Mac”’ rather than typing a Option f.

What I’m trying to do is add an Option F to the name of a folder in a Finder window whose name is selected with the entry point set to the end of the name

TIA.

As you failed to tell it which process must be targeted, System Events send the keystroke to the frontmost one which appear to be the Finder.

Use :
tell application “System Events” to tell process "theProcessSupposedToTreatTheKeystroke"
set frontmost to true
keystroke “f” using {option down}
end


Yvan KOENIG (VALLAURIS, France) dimanche 22 novembre 2015 18:10:50

Here’s the entire script. It still gets ‘Searching “This Mac”.


(* test, with Finder item selected and ready for editing name. *)
tell application “Finder”
activate
set x to selection
if length of x ≠ 0 then
tell application "System Events" to tell process "Finder"
set frontmost to true
keystroke "f" using {option down}
end tell
else
tell application "Mail" to activate
delay 1
repeat 1 times
tell application "System Events"
keystroke "f" using {option down}
end tell
end repeat
end if
end tell


Would be a good idea to apply the change where it is useful!
Try the script edited according to my original answer.

(* test, with Finder item selected and ready for editing name. *)
tell application "Finder"
activate
set x to selection --as text
end tell

if length of x ≠ 0 then
tell application "System Events" to tell process "Finder"
set frontmost to true
keystroke "f" using {option down} # what is it supposed to achieve ?
end tell
else
tell application "Mail" to activate
--delay 1
--repeat 1 times
tell application "System Events" to tell process "Mail"
set frontmost to true
keystroke "f" using {option down} # Insert ƒ in the window of the mail to edit
end tell
--end repeat
end if


When nothing is selected from Finder's point of view, the script inserts ƒ in the mail which is to be edited.
When something is selected from Finder's point of view, the keystroke is received by the Finder but I don't know what it does with it.


Yvan KOENIG running El Capitan 10.11.1 in French (VALLAURIS, France) dimanche 22 novembre 2015 19:22:58



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Keystroke question (From: Robert Poland <email@hidden>)
 >Re: Keystroke question (From: Yvan KOENIG <email@hidden>)
 >Re: Keystroke question (From: Robert Poland <email@hidden>)

  • Prev by Date: Re: Keystroke question
  • Next by Date: AppleScript-Users Digest, Vol 12, Issue 576, Reply to message 2 - Send port for process has no send right
  • Previous by thread: Re: Keystroke question
  • Next by thread: Re: Keystroke question
  • Index(es):
    • Date
    • Thread