StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
kittinzaa  
#1 Posted : Saturday, December 18, 2021 6:02:00 PM(UTC)
kittinzaa

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/18/2021(UTC)
Posts: 7
Thailand

This software is almost perfect I feel like this is the only missing piece because gesture have it down side it hard to recognize when you have a lot of gesture assigning.
With the ability to split screen region will make a simple call out menu very useful which I never seen anywhere else.
I really hope to see this in the future update.

randomConstant  
#2 Posted : Sunday, December 19, 2021 7:26:59 AM(UTC)
randomConstant

Rank: Advanced Member

Reputation:

Groups: Translators, Approved
Joined: 7/17/2021(UTC)
Posts: 135

Thanks: 35 times
Was thanked: 18 time(s) in 15 post(s)
Hi, a pie/circle menu will be nice to see.

I needed to use some of the gestures/actions from a single place as well and I modified Rob's script from this forum a little bit. That script lists all the actions in a dropdownmenu/popupmenu, all sorted within their own sub menu.

Here's a link to that post:
Create Menu with All Actions

And here's my minified/modified version, it scans an application named someRandomApplication and looks for all the scripts/actions with the gesture name addtomenu. That is just a dummy gesture I made and assigned to all the actions I wanted to put in menu, it shows a conflict(red link color) in S+ but actions run fine from the menu.

Code:
var popupMenuInfoEx = new PopupMenuInfoEx(sp.GetCurrentMousePoint());

popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("Close Menu", ""));
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("-"));

//Get the active actions for the required app, sorted by Category, then Description
var appActions = sp_config.Applications.Where(app => app.Description == 'someRandomApplication').First().Actions.Where(a => a.Active).OrderByMultiple("Category|0,Description|0").ToList();
if(appActions.Count > 0) {
    for (var j = 0; j < appActions.Count; j++) {
        if(appActions[j].GestureName == 'addtomenu'){ //you can also use regex to check for a pattern in gesture names here. more flexible and avoids gesture conflict.
            var desc = appActions[j].Description;
            var script = appActions[j].Script;

            popupMenuInfoEx.MenuItems.Add(new PopupMenuItem(desc, script));
        }
    }
}

sp.ShowPopupMenuEx(popupMenuInfoEx);


Rob's original code will probably help you modify it according to your use case.

Hope it helps.
randomConstant  
#3 Posted : Sunday, December 19, 2021 8:06:27 AM(UTC)
randomConstant

Rank: Advanced Member

Reputation:

Groups: Translators, Approved
Joined: 7/17/2021(UTC)
Posts: 135

Thanks: 35 times
Was thanked: 18 time(s) in 15 post(s)
Here is a better/easier version:

How to use:
  1. Make a dummy gesture and name is addtomenu
  2. Assign that gesture to any script/action which you want to add to menu
  3. Activate the provided script using some gesture or shortcut


The Code:
Code:
//create a popupmenu
var popupMenuInfoEx = new PopupMenuInfoEx(sp.GetCurrentMousePoint());

//Add close menu and spacer option
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("Close Menu", ""));
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("-"));

//get all applications and scripts
var applications = sp_config.Applications.Where(a => a.Active).OrderBy("Description").ToList();
applications.Insert(0, sp_config.GlobalApplication); //Insert Global app at the top of the app list
//applications[0].Description = "Global Actions"; //Rename Global app if naming conflict with defined app having name "Global"

//go through all the applications in a loop
for (var i = 0; i < applications.Count;i++) {
    //Get the active actions for the current app, sorted by Category, then Description
    var appActions = applications.Where(x => x.Description == applications[i].Description).First().Actions.Where(a => a.Active).OrderByMultiple("Category|0,Description|0").ToList();
    if(appActions.Count > 0) {
        for (var j = 0; j < appActions.Count; j++) {
            //check if the script has been assigned a gesture with a certain name
            if(appActions[j].GestureName == 'addtomenu'){
                //get description and code of the scipt
                var desc = appActions[j].Description;
                var script = appActions[j].Script;
                //add the script information to popup menu
                popupMenuInfoEx.MenuItems.Add(new PopupMenuItem(desc, script));
            }
        }
    }
}

//show the popup menu
sp.ShowPopupMenuEx(popupMenuInfoEx);
kittinzaa  
#4 Posted : Sunday, December 19, 2021 8:17:48 AM(UTC)
kittinzaa

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/18/2021(UTC)
Posts: 7
Thailand

The first one look like just a way to collect all existing actions into a menu which is not what I thought.
I was thinking about new menu builder system that I can select which action to assign to, because I still want to use gesture for actions that is easy to remember, And use the menu for one that isn't use often. And if possible can work together with existing screen region function.

The second one concept look cool for a temporary workaround.
But to be honest I'm very new to this software so where to I have to put this code?
randomConstant  
#5 Posted : Sunday, December 19, 2021 8:33:25 AM(UTC)
randomConstant

Rank: Advanced Member

Reputation:

Groups: Translators, Approved
Joined: 7/17/2021(UTC)
Posts: 135

Thanks: 35 times
Was thanked: 18 time(s) in 15 post(s)
Got it. Yes a new menu builder would be cool but it probably requires some backend code gymnastics from Rob Laugh

You can put this code into any action, For example you can make a new action which is executed when you drag the mouse down, and have this popupmenu be displayed that way. Basically this code is just like any other action which we use in S+.

As for being able to execute those actions from both the menu and the custom gestures, you can add those actions to menu by checking for a certain keyword in action's names(descriptions) rather than use a dummy gesture. This way you can execute actions using gesture and menu.

Here's a slightly modified version doing this:
Code:
//create a popupmenu
var popupMenuInfoEx = new PopupMenuInfoEx(sp.GetCurrentMousePoint());

//Add close menu and spacer option
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("Close Menu", ""));
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("-"));

//get all applications and scripts
var applications = sp_config.Applications.Where(a => a.Active).OrderBy("Description").ToList();
applications.Insert(0, sp_config.GlobalApplication); //Insert Global app at the top of the app list
//applications[0].Description = "Global Actions"; //Rename Global app if naming conflict with defined app having name "Global"

//go through all the applications in a loop
for (var i = 0; i < applications.Count;i++) {
    //Get the active actions for the current app, sorted by Category, then Description
    var appActions = applications.Where(x => x.Description == applications[i].Description).First().Actions.Where(a => a.Active).OrderByMultiple("Category|0,Description|0").ToList();
    if(appActions.Count > 0) {
        for (var j = 0; j < appActions.Count; j++) {
            //check if the script has a certain tag/keyword in it, in this case its 'addtomenu'
            if(String(appActions[j].Description).match(/addtomenu/)){
                //get description and code of the scipt
                var desc = appActions[j].Description;
                desc = desc.replace(/addtomenu/g,""); //replace the keyword (addtomenu) from the script name for neatness
                var script = appActions[j].Script;
                //add the script information to popup menu
                popupMenuInfoEx.MenuItems.Add(new PopupMenuItem(desc, script));
            }
        }
    }
}

//show the popup menu
sp.ShowPopupMenuEx(popupMenuInfoEx);


Here, we do not need to make a dummy gesture and assign it to actions.

To use, simple add the keyword addtomenu in the name of the actions you'd like to be included in the menu.

Hope this helps.
kittinzaa  
#6 Posted : Wednesday, December 22, 2021 1:58:48 PM(UTC)
kittinzaa

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/18/2021(UTC)
Posts: 7
Thailand

I'm trying your second version of code managed to got actions displaying on the menu list but after I click on the action nothing happen. I'm not sure what I do wrong.
randomConstant  
#7 Posted : Wednesday, December 22, 2021 3:10:35 PM(UTC)
randomConstant

Rank: Advanced Member

Reputation:

Groups: Translators, Approved
Joined: 7/17/2021(UTC)
Posts: 135

Thanks: 35 times
Was thanked: 18 time(s) in 15 post(s)
Originally Posted by: randomConstant Go to Quoted Post
Got it. Yes a new menu builder would be cool but it probably requires some backend code gymnastics from Rob Laugh

You can put this code into any action, For example you can make a new action which is executed when you drag the mouse down, and have this popupmenu be displayed that way. Basically this code is just like any other action which we use in S+.

As for being able to execute those actions from both the menu and the custom gestures, you can add those actions to menu by checking for a certain keyword in action's names(descriptions) rather than use a dummy gesture. This way you can execute actions using gesture and menu.

Here's a slightly modified version doing this:
Code:
//create a popupmenu
var popupMenuInfoEx = new PopupMenuInfoEx(sp.GetCurrentMousePoint());

//Add close menu and spacer option
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("Close Menu", ""));
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("-"));

//get all applications and scripts
var applications = sp_config.Applications.Where(a => a.Active).OrderBy("Description").ToList();
applications.Insert(0, sp_config.GlobalApplication); //Insert Global app at the top of the app list
//applications[0].Description = "Global Actions"; //Rename Global app if naming conflict with defined app having name "Global"

//go through all the applications in a loop
for (var i = 0; i < applications.Count;i++) {
    //Get the active actions for the current app, sorted by Category, then Description
    var appActions = applications.Where(x => x.Description == applications[i].Description).First().Actions.Where(a => a.Active).OrderByMultiple("Category|0,Description|0").ToList();
    if(appActions.Count > 0) {
        for (var j = 0; j < appActions.Count; j++) {
            //check if the script has a certain tag/keyword in it, in this case its 'addtomenu'
            if(String(appActions[j].Description).match(/addtomenu/)){
                //get description and code of the scipt
                var desc = appActions[j].Description;
                desc = desc.replace(/addtomenu/g,""); //replace the keyword (addtomenu) from the script name for neatness
                var script = appActions[j].Script;
                //add the script information to popup menu
                popupMenuInfoEx.MenuItems.Add(new PopupMenuItem(desc, script));
            }
        }
    }
}

//show the popup menu
sp.ShowPopupMenuEx(popupMenuInfoEx);


Here, we do not need to make a dummy gesture and assign it to actions.

To use, simple add the keyword addtomenu in the name of the actions you'd like to be included in the menu.

Hope this helps.


Hi,

Are you talking about this code? I just tested it by adding addtomenu in my already existing actions and they showed in menu and also executed correctly.

Actions looks like this with added keyword:
UserPostedImage

If the action's descriptions(names) are being shown then their code(scripts) should also be added to and executing from the popupmenu, maybe trying with other actions might help? For example I've tested mute volume script and it is working correctly.
Rob  
#8 Posted : Wednesday, December 22, 2021 3:24:24 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
Quote:
Yes a new menu builder would be cool but it probably requires some backend code gymnastics from
Rob
Gentle reminder that users can create their own plug-ins (and share with others), which can include UIs Laugh
kittinzaa  
#9 Posted : Wednesday, December 22, 2021 3:29:00 PM(UTC)
kittinzaa

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/18/2021(UTC)
Posts: 7
Thailand

Originally Posted by: randomConstant Go to Quoted Post
Originally Posted by: randomConstant Go to Quoted Post
Got it. Yes a new menu builder would be cool but it probably requires some backend code gymnastics from Rob Laugh

You can put this code into any action, For example you can make a new action which is executed when you drag the mouse down, and have this popupmenu be displayed that way. Basically this code is just like any other action which we use in S+.

As for being able to execute those actions from both the menu and the custom gestures, you can add those actions to menu by checking for a certain keyword in action's names(descriptions) rather than use a dummy gesture. This way you can execute actions using gesture and menu.

Here's a slightly modified version doing this:
Code:
//create a popupmenu
var popupMenuInfoEx = new PopupMenuInfoEx(sp.GetCurrentMousePoint());

//Add close menu and spacer option
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("Close Menu", ""));
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("-"));

//get all applications and scripts
var applications = sp_config.Applications.Where(a => a.Active).OrderBy("Description").ToList();
applications.Insert(0, sp_config.GlobalApplication); //Insert Global app at the top of the app list
//applications[0].Description = "Global Actions"; //Rename Global app if naming conflict with defined app having name "Global"

//go through all the applications in a loop
for (var i = 0; i < applications.Count;i++) {
    //Get the active actions for the current app, sorted by Category, then Description
    var appActions = applications.Where(x => x.Description == applications[i].Description).First().Actions.Where(a => a.Active).OrderByMultiple("Category|0,Description|0").ToList();
    if(appActions.Count > 0) {
        for (var j = 0; j < appActions.Count; j++) {
            //check if the script has a certain tag/keyword in it, in this case its 'addtomenu'
            if(String(appActions[j].Description).match(/addtomenu/)){
                //get description and code of the scipt
                var desc = appActions[j].Description;
                desc = desc.replace(/addtomenu/g,""); //replace the keyword (addtomenu) from the script name for neatness
                var script = appActions[j].Script;
                //add the script information to popup menu
                popupMenuInfoEx.MenuItems.Add(new PopupMenuItem(desc, script));
            }
        }
    }
}

//show the popup menu
sp.ShowPopupMenuEx(popupMenuInfoEx);


Here, we do not need to make a dummy gesture and assign it to actions.

To use, simple add the keyword addtomenu in the name of the actions you'd like to be included in the menu.

Hope this helps.


Hi,

Are you talking about this code? I just tested it by adding addtomenu in my already existing actions and they showed in menu and also executed correctly.

Actions looks like this with added keyword:
UserPostedImage

If the action's descriptions(names) are being shown then their code(scripts) should also be added to and executing from the popupmenu, maybe trying with other actions might help? For example I've tested mute volume script and it is working correctly.


Maybe because my action is using Steps in the Script tab is blank??

randomConstant  
#10 Posted : Wednesday, December 22, 2021 3:38:09 PM(UTC)
randomConstant

Rank: Advanced Member

Reputation:

Groups: Translators, Approved
Joined: 7/17/2021(UTC)
Posts: 135

Thanks: 35 times
Was thanked: 18 time(s) in 15 post(s)
Hehe yes Rob, got gently reminded. Laugh

and kittinzaa I think that might be the case, since the code is fetching script of those actions and not the steps. I've never used steps to be honest, what are you doing using steps? maybe we can help you do that thing in script?
kittinzaa  
#11 Posted : Wednesday, December 22, 2021 4:30:08 PM(UTC)
kittinzaa

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/18/2021(UTC)
Posts: 7
Thailand

Originally Posted by: randomConstant Go to Quoted Post
Hehe yes Rob, got gently reminded. Laugh

and kittinzaa I think that might be the case, since the code is fetching script of those actions and not the steps. I've never used steps to be honest, what are you doing using steps? maybe we can help you do that thing in script?



I'm using this software to increase my productivity as a 3D modeler so mostly will just press the shortcut.
And I'm very familiar with the Step system because I've use many mocro software from the gaming device.
Rob  
#12 Posted : Wednesday, December 22, 2021 5:47:43 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
Try this to execute steps instead of script (when that's the action's type).

It's not pretty, but it seemed to work on my quick test. Note that currently this executes steps with no action data passed in, so as long as you steps are getting values from the Event Object in the step, it will work fine.

Replace:
Code:
            var script = appActions[j].Script;
With:
Code:
            var script = "";
            if(appActions[j].Type == StrokesPlus.Enums.Internal.ActionType.ScriptEngine) {
                script = appActions[j].Script;
            } else {
                script = `eval("sp.ExecuteSteps(null, `;
                if(includeGlobalActions && i == 0) {
                    script += `sp_config.GlobalApplication.Actions.Where(a => a.Description == '${appActions[j].Description}').First().Steps`;
                } else {
                    script += `sp_config.Applications.Where(a => a.Description == '${applications[i].Description}').First().Actions.Where(a => a.Description == '${appActions[j].Description}').First().Steps`;
                }
                script += `);");`;
            }
kittinzaa  
#13 Posted : Thursday, December 23, 2021 6:57:01 AM(UTC)
kittinzaa

Rank: Newbie

Reputation:

Groups: Approved
Joined: 12/18/2021(UTC)
Posts: 7
Thailand

Originally Posted by: Rob Go to Quoted Post
Try this to execute steps instead of script (when that's the action's type).

It's not pretty, but it seemed to work on my quick test. Note that currently this executes steps with no action data passed in, so as long as you steps are getting values from the Event Object in the step, it will work fine.

Replace:
Code:
            var script = appActions[j].Script;
With:
Code:
            var script = "";
            if(appActions[j].Type == StrokesPlus.Enums.Internal.ActionType.ScriptEngine) {
                script = appActions[j].Script;
            } else {
                script = `eval("sp.ExecuteSteps(null, `;
                if(includeGlobalActions && i == 0) {
                    script += `sp_config.GlobalApplication.Actions.Where(a => a.Description == '${appActions[j].Description}').First().Steps`;
                } else {
                    script += `sp_config.Applications.Where(a => a.Description == '${applications[i].Description}').First().Actions.Where(a => a.Description == '${appActions[j].Description}').First().Steps`;
                }
                script += `);");`;
            }


To be honest I don't know what is define the action type step.

By the way I found I silly way by using "insert hotkey" button on the Script tab and that seem to work for me since I mostly just to press a shortcut key.

But now the problem is this script scan an action from all applications, Is there a way to make it only scan an action only from activate application?

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.