Highlighted

Is it possible to activate menu command with Option click from a script?

Explorer ,
Sep 10, 2020

Copy link to clipboard

Copied

Hi, I wonder if the following is possible in the script:
if ("file-scripts-myscript"click + f.ex. Option key){ do this} else {do that}
Can't find any hints.

Adobe Community Professional
Correct answer by CarlosCanto | Adobe Community Professional

I see, yes it's possible. You can use ScriptUI keyboard state even if there's no actual UI.

 

place this at the beginning of your script to test for Shift or Alt keys

 

 

if(ScriptUI.environment.keyboardState.shiftKey) { 
    alert ('Shift Key pressed...')
    // do your thing
}

if(ScriptUI.environment.keyboardState.altKey) { 
    alert ('Alt Key pressed...')
    // do your thing
}

 

Topics

Scripting

Views

83

Likes

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

Is it possible to activate menu command with Option click from a script?

Explorer ,
Sep 10, 2020

Copy link to clipboard

Copied

Hi, I wonder if the following is possible in the script:
if ("file-scripts-myscript"click + f.ex. Option key){ do this} else {do that}
Can't find any hints.

Adobe Community Professional
Correct answer by CarlosCanto | Adobe Community Professional

I see, yes it's possible. You can use ScriptUI keyboard state even if there's no actual UI.

 

place this at the beginning of your script to test for Shift or Alt keys

 

 

if(ScriptUI.environment.keyboardState.shiftKey) { 
    alert ('Shift Key pressed...')
    // do your thing
}

if(ScriptUI.environment.keyboardState.altKey) { 
    alert ('Alt Key pressed...')
    // do your thing
}

 

Topics

Scripting

Views

84

Likes

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
Adobe Community Professional ,
Sep 10, 2020

Copy link to clipboard

Copied

can you please elaborate? I'm not sure what you're trying to do

Likes

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
Reply
Loading...
Explorer ,
Sep 10, 2020

Copy link to clipboard

Copied

Hi Carlos

It's probably not possible, but the dream scenario is:
if you navigate to a script from the Illustrator file menu and press Option (or Shift or Command) while clicking on it, it will open one pop -up window, but if you just click, it opens another window.

Does it make sense?

Likes

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
Reply
Loading...
Contributor ,
Sep 10, 2020

Copy link to clipboard

Copied

I don't know how to do that. If your script first opens a ScriptUI window you might have a better chance. See https://creativepro.com/files/kahrel/indesign/scriptui.html section on "Listening to the keyboard". Maybe? Sounds like it isn't quite what you want. I wondered if you could check for option (.altKey) during a scriptUI window.onShow event?

 

Screen Shot 2020-09-11 at 7.28.22 am.png

Likes

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
Reply
Loading...
Adobe Community Professional ,
Sep 10, 2020

Copy link to clipboard

Copied

I see, yes it's possible. You can use ScriptUI keyboard state even if there's no actual UI.

 

place this at the beginning of your script to test for Shift or Alt keys

 

 

if(ScriptUI.environment.keyboardState.shiftKey) { 
    alert ('Shift Key pressed...')
    // do your thing
}

if(ScriptUI.environment.keyboardState.altKey) { 
    alert ('Alt Key pressed...')
    // do your thing
}

 

Likes

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
Reply
Loading...
kb3 LATEST
Explorer ,
Sep 11, 2020

Copy link to clipboard

Copied

Thank you Carlos.

Works exactly the way I wanted 🙂

Likes

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
Reply
Loading...