Home key script or action needed

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

midavis

Home key script or action needed

Post by midavis »

Often I would like to have Mac Photoshop CS6 open images showing the top left, as if I had pressed the "Home" key after opening. This would help when cleaning up batches of images, not having to press the Home key each time when opening file after file. I do know how to do this via Applescript, but I need it to be either with Javascript or else a Photoshop action.

Any help would really be appreciated. (a Javascript newbie.) Thanks.

Mike
pfaffenbichler

Home key script or action needed

Post by pfaffenbichler »

What is
the "Home" key
supposed to be?
midavis

Home key script or action needed

Post by midavis »

To clarify: On the Mac extended keyboard, the HOME key is just to the left of the PAGE UP key. Pressing the HOME key in many applications will take you to the beginning of a page or document, or as with Photoshop, to the top left (0x,0y) of an open image. It's a good starting point to make your way through an image for cleanups, etc. Thanks for asking.

-Mike
Mike Hale

Home key script or action needed

Post by Mike Hale »

I don't think it is possible for javascript to send keystrokes to Photoshop. If you want to use one of the Photoshop supported scripting languages you need either AppleScript or VBScript.
larsen67

Home key script or action needed

Post by larsen67 »

It's been some time but I don't think you can use those languages with the events manager? ( I could be wrong though )… Anyhows on a mac…

#target photoshop

app.bringToFront();

app.system( 'osascript -e \'tell application "System Events" to keystroke "1" using command down\'' );

sorry don't have extended keyboard at home to find your home key?
midavis

Home key script or action needed

Post by midavis »

Thanks to all for the help. Here is the final snippet to simulate a press on the HOME key:


// Mac Home key script
#target photoshop
app.bringToFront();
app.system( 'osascript -e \'tell application "System Events" to key code 115\'' );
schroef
Posts: 33
Joined: Sat Apr 11, 2020 6:22 am

Re: Home key script or action needed

Post by schroef »

Man i did not think AppleScript would work from JSX!!! Thanks you very much if been looking to execute a keypress using java for 2 nights in a row. Tried dozens of methods. I want to use this to make a a global timeline scrubber for the video timeline. I got most parts work but i could get it to focus on the playhead. But now it will work when shortcut keys are enabled and using this code.

Does someone know the equivalent to Windows? I did found something but that was very expanded for what i need. Would be nice if its just a single liner just like this one.

Below you see screenshot of it. The blue icon represent the current playhead. The thin line is a seeker which show the famenumber under the cursor position. This way you can work with a full zoomed in timeline but can easily scrub trough with using that scrollbar at the bottom. Its just a little gimic i was thinking off.

:D :o :D
Image