Custom keyboard shortcut to launch a script?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
lehtiniemi
Posts: 107
Joined: Mon Jan 14, 2013 3:18 pm

Custom keyboard shortcut to launch a script?

Post by lehtiniemi »

Is it possible to set a custom keyboard shortcut to a script? Custom tool scripts show up in the keyboard shortcut setup, but not scripts.

Any ideas how to accomplish this?
User avatar
synthsin75
Posts: 9935
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Custom keyboard shortcut to launch a script?

Post by synthsin75 »

Menu scripts are the same as button scripts, so if you add them to the toolbar, you can give them a shortcut.
lehtiniemi
Posts: 107
Joined: Mon Jan 14, 2013 3:18 pm

Re: Custom keyboard shortcut to launch a script?

Post by lehtiniemi »

Ah, button scripts. I started scripting today... makes sense! Thanks again!!! :) I'll give my script a button.
User avatar
synthsin75
Posts: 9935
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Custom keyboard shortcut to launch a script?

Post by synthsin75 »

You're welcome, and welcome to AS scripting.
lehtiniemi
Posts: 107
Joined: Mon Jan 14, 2013 3:18 pm

Re: Custom keyboard shortcut to launch a script?

Post by lehtiniemi »

Thank you :)

I quickly wanted to clarify two things, I'm not quite sure about these concepts yet?

-by making it a button, do you mean creating a tool that has a button bar at the top? It's not possible to create a tool-looking button that would activate a script directly but it has to be via "Select tool -> press button at the appearing toolbar"?

-which function separates a script menu script and a tool? I could find a mention which function AS looks for in the script to determine whether it's a tool or a script menu script? What is the very basic code that tells AS to make a script a tool?
User avatar
synthsin75
Posts: 9935
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Custom keyboard shortcut to launch a script?

Post by synthsin75 »

No, not a tool option button. In the toolbar are two types of scripts, tools and buttons. Buttons do not remain active when pressed, like the Insert Text button. Buttons use the exact same syntax as menu scripts, e.g. function someScript:Run(moho). To get the button behavior, you'll need to edit the _tool_list.txt in the tools folder (preferably in your custom content folder). You'll see that the tool_list already has some buttons setup, so just follow that example with your own.
lehtiniemi
Posts: 107
Joined: Mon Jan 14, 2013 3:18 pm

Re: Custom keyboard shortcut to launch a script?

Post by lehtiniemi »

synthsin75 wrote:No, not a tool option button. In the toolbar are two types of scripts, tools and buttons. Buttons do not remain active when pressed, like the Insert Text button. Buttons use the exact same syntax as menu scripts, e.g. function someScript:Run(moho). To get the button behavior, you'll need to edit the _tool_list.txt in the tools folder (preferably in your custom content folder). You'll see that the tool_list already has some buttons setup, so just follow that example with your own.
Ah, thank you so much!!! :)
Post Reply