Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to simulate keyboard (event) press in Photoshop extendscript?

Contributor ,
Apr 29, 2016 Apr 29, 2016

Hey Guys!

Is it possible to simulate a keyboard event trough script (in Photoshop)?!?

Trough .jsx/html extension?!?

I mean i press a button like:

HTML:

<button class="basic_button" onclick="onClickButton('example_push')">Button Text</button>

lickButton('example_push')">Button Text</button>

Javascript:

$._ext_example_push={

    run : function() {

  //something

  //something

      }

  };

and than some keyboard press is simulated. For example "CTRL+0"  (Fit on Screen command) or any else?!?

Any ideas or examples and/or solutions are more than welcome!!

Thank You!

Ben

TOPICS
Actions and scripting
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Apr 30, 2016 Apr 30, 2016
and than some keyboard press is simulated. For example "CTRL+0"  (Fit on Screen command) or any else?!?

Why insert an unnecessary step (simulating the key-press) for something that can be Scripted anyway?

Simulating key-press events is platform dependent, did you do a Forum Search?

https://forums.adobe.com/search.jspa?q=simulate%20press%20key

Send keystroke from Javascript to Photoshop ?!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 30, 2016 Apr 30, 2016

note the "or any else" part....

but here are my answers and goals:

1. it could be usefull to education

2, it could be usefull when script listener fails you

3. it could be easier than write 100line of code (depending on the key simulator code of course)

thats all 🙂
Do You know script for Fit on Screen command (ctrl+0)?!? 

Appreciate any help....
i check out the link You gave me

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 30, 2016 Apr 30, 2016

Do You know script for Fit on Screen command (ctrl+0)?!?

From CS4, you can use the built-in app.runMenuItem method:

runMenuItem (stringIDToTypeID ("fitOnScreen"));

runMenuItem (stringIDToTypeID ("actualPixels"));

runMenuItem (stringIDToTypeID ("printSize"));

And before CS4, you can use Action Manager code to define your own runMenuItem function:

function runMenuItem (menuItem)

{

    var desc = new ActionDescriptor ();

    var ref = new ActionReference ();

    ref.putEnumerated (stringIDToTypeID ("menuItemClass"), stringIDToTypeID ("menuItemType"), menuItem);

    desc.putReference (stringIDToTypeID ("target"), ref);

    executeAction (stringIDToTypeID ("select"), desc, DialogModes.ERROR);

}

HTH,

--Mikaeru

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 01, 2016 May 01, 2016

1. it could be usefull to education

2, it could be usefull when script listener fails you

3. it could be easier than write 100line of code (depending on the key simulator code of course)

Fair enough.

Did any of the threads provide a solution for your platform?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 05, 2016 May 05, 2016
LATEST

thanks, but no luck yet!

Ben

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines