Create keyboard shortcut for duplicated action

Hello everyone:


I've tried this for a while yet I can't manage to do it... Since the Apple Geniuses decided to remove the handy save as instruction in Pages for lion (i know its called duplicate but its not the same). I've tried to set up a keyboard shortcut for Duplicate yet the thing is that there is a duplicate command under both Edit AND File on the menu bar. When I go to create the shortcut, it creates the shortcut for Duplicate under edit, but what I want is for the shortcut to create a duplicate of the fille (what would happen if i clicked File->Duplicate)


Anyone knows how to set it up so that i create the shortcut for the menu title under File and NOT under Edit?




I'm incredibly sorry this question is SO ambiguous its crazy... Tell me if you want me to explain clearer.


Thanks


Juan

MacBook Pro 13', Mac OS X (10.7)

Posted on Sep 25, 2011 8:40 AM

Reply
37 replies

Sep 26, 2011 10:52 PM in response to William Donelson

I have Automator.app in my Applications folder, and it runs itself, so should appear in the list of apps in itself, yes? But it does NOT appear in the list of apps in the left-hand column.


From Automator choose the View > Arrange Actions by > Application menu command.


2. When I go back into Automator, how do I find the previous "service" document that I created in your & Peggy's steps?


Does the File > Open Recent menu command show it?


If not, it'll be saved in your ~/Library/Services folder.

Sep 27, 2011 5:14 AM in response to Dale Gillard

Thanks a lot Dale.

Triggering : View > Arrange Actions by > Application

was the trick.


When I scanned the menus contents, given the wording, I assumed that this item was designed to organize the 2nd column, the one with actions.


Yvan KOENIG (VALLAURIS, France) mardi 27 septembre 2011 14:14:03

iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0

My iDisk is : <http://public.me.com/koenigyvan>

Please : Search for questions similar to your own before submitting them to the community



Oct 26, 2011 4:43 PM in response to Peggy

Many thanks Peggy for the hints and to Yvan for the script -- lots to play with there


I have downloaded your workflow file and placed it in Library/Services


Activated the workflow in SysPrefs


Added App-specific shortcut for Preview

User uploaded file


In Preview, the Save_As workflow is shown in the Services menu and if manually selected it runs just fine.

here is a screen shot from Preview - do not worry about the file name

User uploaded file

Trouble is, the shift-Command-S short cut does not work. umm?

Oct 26, 2011 10:19 PM in response to Peggy

Well there is some movement


If you assign the shortcut key to "All Applications" the shortcut works in Preview.

User uploaded file

Now I will have determine what shortcut key combination is not going to conflict with Native Save As in other applications.


BUT: have you noticed that there is another bug? in Preview?

When you Duplicate a file, the destination folder is always the Desktop --- regardless of where the source file is located.

TextEdit follows the convention expected - duplicated is by default placed in the source file folder.

Mar 27, 2012 7:15 PM in response to Peggy

Peggy, Yvan, et al:


Many thanks for this thread and your work. Peggy, I went to your iDisk & downloaded, unzipped, and let the OS install the Script. It became available to Pages immediately (hooray!). When I ran the script from the Services menu, I ended up successfully with a copy of my document.


One question: Is it possible to modify the script such that it would prompt me to name the new file (so as not to end up with " copy" or " copy 1" and so forth)?


I can look into it myself, but thought someone here might have a quick answer.


At any rate, thanks again -- I was absolutely horrified when presented only with "Save a Version" and "Duplicate". Sheesh.


Patrick

Apr 15, 2012 10:48 AM in response to Steve Maximus

I don't guess what you made wrongly.


My late script was :

--{code}

(*

Yvan KOENIG (VALLAURIS, France)

2011/09/26

*)


property triggerSave : true

(*

true = trigger Duplicate then trigger Save…

false == trigger only Duplicate

*)

on run


(*

Use the property triggerSave

*)

local theApp, miDuplicate, sourceName


(*

Get the name of the frontmost application *)

tell application "System Events" to set theApp to name of first application process whose frontmost is true


(*

Define the index of the menu in which we will trigger an item.

The File menu is the 3rd one. *)

set mtFile to 3


(*

Define the index of the menu item to trigger *)

if theApp is "Pages" then

set miDuplicate to 10

else if theApp is in {"Numbers", "Keynote", "Preview"} then

set miDuplicate to 9

else if theApp is "TextEdit" then

set miDuplicate to 8

else

error number -128 (* Exit silently if the app isn’t one of the five treated ones *)

end if


tell applicationtheApp to activate

tell application "System Events" to tell process theApp

if triggerSave then

(*

Get name of current document *)

set sourceName to name of first window whose subrole is "AXStandardWindow"

(*

Prepare the loop which would close the sheet "Your document has been changed… " *)

set nbw to count of (every window whose subrole is "AXStandardWindow")

end if


(*

Trigger the menu item Duplicate *)

tell menu bar 1 to tell menu bar itemmtFile to tell menu 1 to clickmenu itemmiDuplicate


(*

Try to click the button Duplicate in a possible sheet "Your document has been changed… " *)

if triggerSave then

repeat 5 times

delay 0.1

try

click first button of first sheet of window sourceName

exit repeat

end try

end repeat

(*

Wait for the availability of the replicate document.

CAUTION : Preview doesn't add the word 'copy' to the replicate's name *)

repeat while nbw = (count of (every window whose subrole is "AXStandardWindow"))

--

end repeat

(*

Trigger the menu item Save… *)


keystroke "s" using {command down}

end if -- triggerSave

end tell


end run

--{code}



and it compiles flawlessly.


To pack it in a Service, yout must edit it a bit :


--{code}

(*

Yvan KOENIG (VALLAURIS, France)

2011/09/26

*)


property triggerSave : true

(*

true = trigger Duplicate then trigger Save…

false == trigger only Duplicate

*)

on run {input, parameters} -- the list is required for Services


(*

Use the property triggerSave

*)

local theApp, miDuplicate, sourceName


(*

Get the name of the frontmost application *)

tell application "System Events" to set theApp to name of first application process whose frontmost is true


(*

Define the index of the menu in which we will trigger an item.

The File menu is the 3rd one. *)

set mtFile to 3


(*

Define the index of the menu item to trigger *)

if theApp is "Pages" then

set miDuplicate to 10

else if theApp is in {"Numbers", "Keynote", "Preview"} then

set miDuplicate to 9

else if theApp is "TextEdit" then

set miDuplicate to 8

else

error number -128 (* Exit silently if the app isn’t one of the five treated ones *)

end if


tell applicationtheApp to activate

tell application "System Events" to tell process theApp

if triggerSave then

(*

Get name of current document *)

set sourceName to name of first window whose subrole is "AXStandardWindow"

(*

Prepare the loop which would close the sheet "Your document has been changed… " *)

set nbw to count of (every window whose subrole is "AXStandardWindow")

end if


(*

Trigger the menu item Duplicate *)

tell menu bar 1 to tell menu bar itemmtFile to tell menu 1 to clickmenu itemmiDuplicate


(*

Try to click the button Duplicate in a possible sheet "Your document has been changed… " *)

if triggerSave then

repeat 5 times

delay 0.1

try

click first button of first sheet of window sourceName

exit repeat

end try

end repeat

(*

Wait for the availability of the replicate document.

CAUTION : Preview doesn't add the word 'copy' to the replicate's name *)

repeat while nbw = (count of (every window whose subrole is "AXStandardWindow"))

--

end repeat

(*

Trigger the menu item Save… *)


keystroke "s" using {command down}

end if -- triggerSave

end tell

return input-- required for Service.

end run

--{code}


If you continue to fail, send what you done to my mailbox (click my blue name to get my address).

I guess that I would understand what is wrongly done.



message edited because, I don't know why, the original script was clipped on its left edge


Yvan KOENIG (VALLAURIS, France) dimanche 15 avril 2012

iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.3

My Box account is : http://www.box.com/s/00qnssoyeq2xvc22ra4k

May 2, 2012 11:33 AM in response to gizbug

You don't choose Automator in Services, you choose the service you (or I) created that you have placed in the Services folder. To save others the long process of creating the service from scratch, I have successfully created a service named Save_As & placed it on my iDiskfor anyone to download (as long as the iDisk is still functioning). Download the file Save_As.workflow.zip, unzip it & then place it in the Services folder in your home Library. If the folder doesn't already exist you can create it.


User uploaded file


Note: this is a repeat of a post I wrote in this thread on September 26, 2011. iDisk is going away the end of June, 2012, & I have not yet set up another place to house these files, so grab the file while you can.


User uploaded file

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Create keyboard shortcut for duplicated action

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.