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

Selecting specific menu items via javascript

Community Beginner ,
Mar 27, 2017 Mar 27, 2017

Copy link to clipboard

Copied

Is there any way of selecting tools (such as selection tool, direct selection tool, curvature tool, line segment tool etc) programmatically via javascript? I've written a custom tool panel extension with html/css and javascript and would like to include a few specific tools on it.

I've been using the executeMenuCommand for actions such as grouping, ungrouping, zooming etc but couldn't seem to invoke any of the above. I've looked everywhere.

Any help appreciated, thanks in advance.

TOPICS
Scripting

Views

2.3K

Translate

Translate

Report

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

correct answers 1 Correct answer

Guide , Mar 28, 2017 Mar 28, 2017

first thought would be to send via BT to JSX to VBA.. then you could get creative and use the VBA result to trigger a JSX callback to the JS in the HTML panel confirming the outcome...

this is basic and has no call back,

I'm not setup on this pc to play with panels so can't test the BT side of things.

function SendKeysViaVB() {

    var VBA = File("~/send_keys_script_file.vbs");

    VBA.execute();

}

SendKeysViaVB();

Votes

Translate

Translate
Adobe
Guide ,
Mar 27, 2017 Mar 27, 2017

Copy link to clipboard

Copied

Dont think Javascript can do that for you.

if your on mac, then apple script can do a sendkeys type function.

you would need to find a macman to help with that.

if its for pc, then we could use vba to do the send keys.

how effective this is will be dependent on the rest of the script also the when and why of the tool selection could cause an issue.

The javascript will not wait for the vba to run, it just keeps on chugging.

Votes

Translate

Translate

Report

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 Beginner ,
Mar 27, 2017 Mar 27, 2017

Copy link to clipboard

Copied

Thanks, I'll look into it, before I do is there a way of checking which shortcut key a tool is before sending? I see shortcuts can be changed

Votes

Translate

Translate

Report

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
Guide ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

ill have a think on it.

it can be exported as a text file manualy.

not sure if you can get to the info with javascript or not.

ill post back soon

Votes

Translate

Translate

Report

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 Beginner ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

Qwertyfly...​ I've created a vb script that sends they keys, tested and working through the file > scripts interface. Do you happen to know how I can link it to my HTML/CSS panel? Ideally I want to click a button on my panel and it runs the vb function. Thanks

Votes

Translate

Translate

Report

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
Guide ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

first thought would be to send via BT to JSX to VBA.. then you could get creative and use the VBA result to trigger a JSX callback to the JS in the HTML panel confirming the outcome...

this is basic and has no call back,

I'm not setup on this pc to play with panels so can't test the BT side of things.

function SendKeysViaVB() {

    var VBA = File("~/send_keys_script_file.vbs");

    VBA.execute();

}

SendKeysViaVB();

Votes

Translate

Translate

Report

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
Valorous Hero ,
Mar 28, 2017 Mar 28, 2017

Copy link to clipboard

Copied

The good news is that with custom CSX PlugPlug Events, you can run the .jsx script which can in turn run a VBA script, and then use the VBA script to run another .jsx script which can then send the custom event up to the panel.

https://www.davidebarranca.com/2014/07/html-panels-tips-11-externalobject-cep-events/

Votes

Translate

Translate

Report

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 Beginner ,
Mar 29, 2017 Mar 29, 2017

Copy link to clipboard

Copied

Any chance you could elaborate more on BT part of things? (had to google what BT was). I have my html, which calls functions from my main js file, then the js file uses csInterface and evalScript to calls functions in my jsx file. I've tried looking for examples but none of them fitted my scenario so couldn't make sense of any.

Votes

Translate

Translate

Report

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
Guide ,
Mar 30, 2017 Mar 30, 2017

Copy link to clipboard

Copied

bridge talk.

its the method used to pass info etc between adobe apps.

its more a text messege to the scripting engine.

eval () is doing kinda the same thing.

it sounds like your working with html panels.

i may be wrong but panels are still a bit limited in the events side of things.

to get true intergration you need to go into the sdk.

as for the question of getting the vb to run. the js may be able to do it with out first passing to jsx via csinterface. ive not tried.

do to shifting jobs and a few bobs, i don't have a setup to try anything out on right now. but the simple sendkeys function above should pass across to the jsx engine without issue. do it the same way you pass your other scripts across.

let us know how you go.

Votes

Translate

Translate

Report

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 Beginner ,
Mar 30, 2017 Mar 30, 2017

Copy link to clipboard

Copied

I've tried putting the function directly in the JS file and call it from html. it enters the function but sadly doesn't work, nor does it reach the end of the function. My function is:

function test(){

    alert("start");

    var VBA = File("C:\Users\212568899\AppData\Roaming\Adobe\CEP\extensions\adobe-scripts-A661\vb\keyscript.vbs");

  //p1 = "Set objShell = CreateObject(\"WScript.Shell\")\r";

  //p2 = "objShell.SendKeys \"V\"";

  //var VBA = p1 + p2;

  VBA.execute();

  alert("end");

}

I tried both the File method and string method. I also tried the same function in the JSX file and calling it via evalScript() but again same issue.

Silly-V​ CarlosCanto​ any ideas?

Votes

Translate

Translate

Report

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
Valorous Hero ,
Mar 30, 2017 Mar 30, 2017

Copy link to clipboard

Copied

Your code you put into your panel's JS should actually be instead in the host script JSX. Once you are able to execute the VBA, you will immediately get your 'end' alert because to my knowledge, this is non-synchronous. Therefore you may end up executing another .jsx file function at the very end of your VBA script to send a CSX event to inform your html panel that your VBA work is complete.

Votes

Translate

Translate

Report

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
Guide ,
Mar 30, 2017 Mar 30, 2017

Copy link to clipboard

Copied

Is it due to the odd space in the file name of the vb.  "keysc ript.vbs".

so it enters the function and sends the "start" alert.

then nothing.

so its probably not finding the .vbs file.

debugging scripts that execute across so many engines or whatever are a pain.

try a simple .vbs that just has a msgbox() in it so you can confirm when you get that to run.

you could also start with a simpler path, I'm not sure if there is any permission issues when trying to get into a users appdata folder.

depending on how the extension is installed it may or may not end up in the appdata folder.

it would make sense to use a relative path.

Votes

Translate

Translate

Report

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
Valorous Hero ,
Mar 30, 2017 Mar 30, 2017

Copy link to clipboard

Copied

It may be probably because file path needs double escaped slash (\\)

But the function above needs to be definitely in the jsx file.

Votes

Translate

Translate

Report

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 Beginner ,
Mar 30, 2017 Mar 30, 2017

Copy link to clipboard

Copied

Right, some progress. I have the script executing with a messagebox, the issue was Silly-V​ the double escape slash. However when I try to run my sendkey script it doesn't work. Know the script code is correct because it works via File > scripts. I put two messageboxes, one at the start and one the end and it executes both but the actual send key doesn't select the right shortcut. Any ideas?

UPDATE: Finally works! Not sure why it didn't earlier, I think something was taking focus but now it does. Much appreciated guys!

Votes

Translate

Translate

Report

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
Valorous Hero ,
Mar 31, 2017 Mar 31, 2017

Copy link to clipboard

Copied

Ok, now go for the gold and try the custom CSX event to deliver a 'done' message back up to your panel! I want to see if this really works

Votes

Translate

Translate

Report

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
Guide ,
Mar 31, 2017 Mar 31, 2017

Copy link to clipboard

Copied

as a poor mans fail safe. you could prob run the sendkeys script a few times. or add a real small pause in the vbs and send the key again. selecting the tool twice will not hurt. just do it fast enough that it does not get in the way.

but your focus issue could really be worth looking into. if your in a text field or something it will just type in the field.

you might want to test for that before running the vbs. not sure how to tell if in a text field. ill think on it. unless your situation would be ok with an {ESC} being sent before the tool shortcut.

Votes

Translate

Translate

Report

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 Beginner ,
Mar 31, 2017 Mar 31, 2017

Copy link to clipboard

Copied

LATEST

Yea I stumbled on the textbox issue when testing it. I solved it with app.executeMenuCommand("deselectall") before sending they key, it works well, for what I need. Thanks again.

If you fancy a stab at another issue then could use your help with Changing the colour picker to another colour via script

Votes

Translate

Translate

Report

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