When you want to execute say a “N” with the command key you would say "Keystroke “N” using command down but how would you do the same if you wanted to press the command key first and while holding press the “N” key.
Example when you want to paste the clipboard to a new Preview window you press Command + “N”. I can’t get the applescript to do this for me, could someone please show me how.
I think you have to have something on the clipboard(obviously!) and i think it has to be an image.
This made the menu item active for me once an image was on the clipboard not text.
I also have Preview 3.0.9, and the option is dimmed unless there is something on the clipboard, so I tried scripting it. It has to be
tell application "System Events" to tell process "Preview" to keystroke "n" using command down--note the "n" is not capitalized
I first made a mistake I often make - I capitalized the “N” because the dropdown menu shows a capital letter “N” next to the command sign, but if you type a capital “N” in your script, what you really do is keystroke using shift and command down.
EDIT:
Huh, didn’t even occur to me that PolishPrince might have been copying text.
Thanks Guys
Thanks to the guys that helped me solve my problem. It was the use of the Capital “N” that caused it not to work and yes i did want to use it for screencapture so it would have to be an image. I’m putting the code that works so you can see and maybe it might help other as well.
PolishPrince
tell application "Preview"
activate
end tell
do shell script "screencapture -i -c $FILE"
tell application "Preview"
activate
tell application "System Events" to tell process "Preview" to keystroke "n" using command down --note the "n" is not capitalized
end tell