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

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

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

TOPICS
Scripting

Views

382

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

Community Expert , Sep 10, 2020 Sep 10, 2020

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
}

 

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 10, 2020 Sep 10, 2020

Copy link to clipboard

Copied

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

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
Explorer ,
Sep 10, 2020 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?

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 Expert ,
Sep 10, 2020 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

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 Expert ,
Sep 10, 2020 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
}

 

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
Explorer ,
Sep 11, 2020 Sep 11, 2020

Copy link to clipboard

Copied

LATEST

Thank you Carlos.

Works exactly the way I wanted 🙂

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