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

Notification

Icon
Error

Options
Go to last post Go to first unread
liuchina  
#1 Posted : Wednesday, October 16, 2019 8:14:59 AM(UTC)
liuchina

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 9/26/2018(UTC)
Posts: 73
China
Location: 北京

Thanks: 18 times
Was thanked: 1 time(s) in 1 post(s)
Hi Rob:
Can you implement the user's startup script through InputBox, and finally use voice to control PC with S + net. If you can implement s + net, it will be very cool.
When I use s + net, I often have the experience of a script gesture of S + net. If I don't use it for a while, I forget the start gesture of the gesture. The more gestures you create in S + net, the more often this happens. If S + net starts the script with voice or control, it may completely change this situation.
Thank you.
Rob  
#2 Posted : Wednesday, October 16, 2019 1:37:30 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
Quote:
If I don't use it for a while, I forget the start gesture of the gesture.


This is exactly the reason gestures are not more common (beyond a few very simple ones). The average user needs to see things, gestures are hidden and must be remembered.

Regarding the rest of your post, I have to admit that I am confused. You mention InputBox, startup script, voice control...I will need some more detailed examples of what you mean.

Voice control would be quite an undertaking, but I'll look into what's out there for examples and determine if it is feasible to consider for the future.
liuchina  
#3 Posted : Thursday, October 17, 2019 12:54:12 AM(UTC)
liuchina

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 9/26/2018(UTC)
Posts: 73
China
Location: 北京

Thanks: 18 times
Was thanked: 1 time(s) in 1 post(s)
I mean, if a user forgets which gesture he should use to start the script he has written when using S + net, he can start the script by typing the name of the gesture in an inputbox. S + net starts the script after recognizing the string of the gesture name in the InputBox. This function should be easy to implement in the shortcut key of S + net. It would be great if gestures in S + net could do this. I think it will save users from having to remember so many different gestures and shortcut key combinations.
For voice operations, if you implement the InputBox string to start the script. So with the current level of voice input technology, it should be easy to realize voice control PC.
Rob  
#4 Posted : Thursday, October 17, 2019 1:07:22 AM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
I mean, you can do that now if you want. Not voice, well maybe you could with Windows Speech enabled.
Code:
var inputBoxInfo = new InputBoxInfo();
inputBoxInfo.Title = 'Execute Global Action';
inputBoxInfo.Message = 'Select an action to execute';
for (var i = 0; i < sp_config.GlobalApplication.Actions.Count; i++) {
    inputBoxInfo.Items.Add(sp_config.GlobalApplication.Actions[i].Description);
}
inputBoxInfo.Sort = true;
inputBoxInfo.ShowAtMouseCursor = true;
var res = sp.InputBox(inputBoxInfo);
if(res != null) {
	eval(sp_config.GlobalApplication.Actions.Where(x => x.Description == res).First().Script);
}

Of course, there are many ways this could be optimized/enhanced, but as a starting point this does what you're asking =)

Edited by user Thursday, October 17, 2019 1:12:40 AM(UTC)  | Reason: Not specified

thanks 1 user thanked Rob for this useful post.
liuchina on 10/17/2019(UTC)
liuchina  
#5 Posted : Thursday, October 17, 2019 1:38:26 AM(UTC)
liuchina

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 9/26/2018(UTC)
Posts: 73
China
Location: 北京

Thanks: 18 times
Was thanked: 1 time(s) in 1 post(s)
Thank you very much for the script that solved my problem.
Rob  
#6 Posted : Thursday, October 17, 2019 1:43:15 AM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
You could also build out a menu with all apps/actions:
Code:
var popupMenuInfoEx = new PopupMenuInfoEx(sp.GetCurrentMousePoint());
var mnuGlobal = new PopupMenuItem("Global Actions");
var globalActions = sp_config.GlobalApplication.Actions.OrderBy("Description").ToList();
for (var i = 0; i < globalActions.Count; i++) {
    mnuGlobal.SubMenuItems.Add(new PopupMenuItem(globalActions[i].Description, globalActions[i].Script));
}
popupMenuInfoEx.MenuItems.Add(mnuGlobal);

//Build Application menus
var applications = sp_config.Applications.OrderBy("Description").ToList();
for (var i = 0; i < applications.Count;i++) {
    var appActions = sp_config.Applications.Where(x => x.Description == applications[i].Description).First().Actions;
    if (appActions.Count > 0) {
        var mnuApp = new PopupMenuItem(applications[i].Description);
        for (var j = 0; j < appActions.Count; j++) {
            mnuApp.SubMenuItems.Add(new PopupMenuItem(appActions[j].Description, appActions[j].Script));
        }    
        popupMenuInfoEx.MenuItems.Add (mnuApp);
    }
}

popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("-"));
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("Close Menu", ""));
sp.ShowPopupMenuEx(popupMenuInfoEx);
thanks 1 user thanked Rob for this useful post.
liuchina on 10/17/2019(UTC)
liuchina  
#7 Posted : Thursday, October 17, 2019 1:48:41 AM(UTC)
liuchina

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 9/26/2018(UTC)
Posts: 73
China
Location: 北京

Thanks: 18 times
Was thanked: 1 time(s) in 1 post(s)
Great job,Rob.Perfect.
Rob  
#8 Posted : Thursday, October 17, 2019 2:24:08 AM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
Here, this one is better. It breaks out the categories into sub-menus, unless an application has only one category, then there's no sub-menu.

There's a lot of sloppy code going on here due to a) time and b) lack of access to some IList methods which would greatly reduce the code.

There are probably numerous ways to simplify this via JavaScript; but this works and again, I don't want to spend a lot of time on it right now =)

Code:
//Build Global Actions
var popupMenuInfoEx = new PopupMenuInfoEx(sp.GetCurrentMousePoint());
var mnuGlobal = new PopupMenuItem("Global Actions");
var globalActions = sp_config.GlobalApplication.Actions.OrderBy("Category").ToList();
var catCount = 0;
var currentCategory = "";
for (var j = 0; j < globalActions.Count; j++) {
    if(currentCategory != globalActions[j].Category) {
        catCount++;
        currentCategory = globalActions[j].Category;
    }
}
for (var i = 0; i < globalActions.Count; i++) {
    if(currentCategory != globalActions[i].Category) {
        currentCategory = globalActions[i].Category;
        if(catCount > 1) {
            categoryMenu = new PopupMenuItem(currentCategory);
        }
        var catActions = sp_config.GlobalApplication.Actions.Where(x => x.Category == currentCategory).OrderBy("Description").ToList();
        for (var j = 0; j < catActions.Count; j++) {
            if(catCount ==1) {
                mnuGlobal.SubMenuItems.Add(new PopupMenuItem(catActions[j].Description, catActions[j].Script));
            } else {
                categoryMenu.SubMenuItems.Add(new PopupMenuItem(catActions[j].Description, catActions[j].Script));
            }
        }
        if(catCount > 1) {
            mnuGlobal.SubMenuItems.Add(categoryMenu);
        }
    }
}
popupMenuInfoEx.MenuItems.Add(mnuGlobal);

//Build Application menus
var applications = sp_config.Applications.OrderBy("Description").ToList();
for (var i = 0; i < applications.Count;i++) {
    var appActions = sp_config.Applications.Where(x => x.Description == applications[i].Description).First().Actions.OrderBy("Category").ToList();
    if(appActions.Count > 0) {
        var catCount = 0;
        var currentCategory = "";
        for (var j = 0; j < appActions.Count; j++) {
            if(currentCategory != appActions[j].Category) {
                catCount++;
                currentCategory = appActions[j].Category;
            }
        }
        var mnuApp = new PopupMenuItem(applications[i].Description);
        currentCategory = "";
        for (var j = 0; j < appActions.Count; j++) {
            if(currentCategory != appActions[j].Category) {
                currentCategory = appActions[j].Category;
                if(catCount > 1) {
                    categoryMenu = new PopupMenuItem(currentCategory);
                }
                var catActions = sp_config.Applications.Where(x => x.Description == applications[i].Description).First().Actions.Where(x => x.Category == currentCategory).OrderBy("Description").ToList();
                for (var k = 0; k < catActions.Count; k++) {
                    if(catCount == 1) {
                        mnuApp.SubMenuItems.Add(new PopupMenuItem(catActions[k].Description, catActions[k].Script));
                    } else {               
                        categoryMenu.SubMenuItems.Add(new PopupMenuItem(catActions[k].Description, catActions[k].Script));
                    }
                }
                if(catCount > 1) {
                    mnuApp.SubMenuItems.Add(categoryMenu);
                }
            }
        }
        popupMenuInfoEx.MenuItems.Add(mnuApp);
    }
}

popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("-"));
popupMenuInfoEx.MenuItems.Add(new PopupMenuItem("Close Menu", ""));
sp.ShowPopupMenuEx(popupMenuInfoEx);
Rob  
#9 Posted : Thursday, October 17, 2019 2:30:53 AM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
You could also append to the action description things like the gesture name, modifiers, and whether it uses the primary or secondary stroke button if you wanted...as a reminder.

Again, there are a lot of things you can do if you want! :)

These are the action properties for those items:

GestureName (string - name of the gesture)

UseSecondaryStrokeButton - (boolean - true means secondary, false means primary stroke button)

Modifiers: (booleans)

Control
Alt
Shift
Left
Middle
Right
X1
X2
WheelUp
WheelDown


For example, this would add "- {gesture name}" to the action name in the menu:
Code:
new PopupMenuItem(catActions[j].Description + ' - ' + catActions[j].GestureName, catActions[j].Script)

Edited by user Thursday, October 17, 2019 2:38:48 AM(UTC)  | Reason: Not specified

liuchina  
#10 Posted : Thursday, October 17, 2019 3:06:04 AM(UTC)
liuchina

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 9/26/2018(UTC)
Posts: 73
China
Location: 北京

Thanks: 18 times
Was thanked: 1 time(s) in 1 post(s)
Thank you very much Rob, S + net is more powerful and easy for users to use. I hope you can open the help files that can be searched comprehensively as soon as possible, so that new users can more easily understand your coding method and S + built-in functions, and more people can use s + net. I think s + net will really have a huge market prospect in the future.
Rob  
#11 Posted : Thursday, October 17, 2019 3:49:39 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
Okay, this new script is much cleaner, but requires minimum S+.net version 0.3.4.9 which I just released. It also adds the gesture name and any modifiers to the name of the action.

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

var applications = sp_config.Applications.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 the name "Global"
for (var i = 0; i < applications.Count;i++) {
    var appActions = applications.Where(x => x.Description == applications[i].Description).First().Actions.OrderByMultiple("Category|0,Description|0").ToList();
    if(appActions.Count > 0) {
        var catCount = appActions.Distinct("Category").Count();
        var mnuApp = new PopupMenuItem(applications[i].Description);
        currentCategory = "";
        for (var j = 0; j < appActions.Count; j++) {
            var desc = appActions[j].Description;
            desc += ' - ' + appActions[j].GestureName 
                    + (appActions[j].Left ? ' [L]' : '')  + (appActions[j].Middle ? ' [M]' : '') + (appActions[j].Right ? ' [R]' : '')
                    + (appActions[j].Control ? ' [C]' : '') + (appActions[j].Alt ? ' [A]' : '') + (appActions[j].Shift ? ' [S]' : '')
                    + (appActions[j].WheelDown ? ' [WD]' : '') + (appActions[j].WheelUp ? ' [WU]' : '');
            var script = appActions[j].Script;
            if(catCount > 1) {
                if(currentCategory != appActions[j].Category) {
                    if(currentCategory != "") {
                        mnuApp.SubMenuItems.Add(categoryMenu);
                    }
                    currentCategory = appActions[j].Category; 
                    categoryMenu = new PopupMenuItem(currentCategory);
                }
                categoryMenu.SubMenuItems.Add(new PopupMenuItem(desc, script));
                if(j == appActions.Count - 1) {
                    mnuApp.SubMenuItems.Add(categoryMenu);
                }
            } else {
                mnuApp.SubMenuItems.Add(new PopupMenuItem(desc, script));
            }
        }
        popupMenuInfoEx.MenuItems.Add(mnuApp);
    }
}

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

Edited by user Thursday, October 17, 2019 5:29:17 PM(UTC)  | Reason: Not specified

Rob  
#12 Posted : Thursday, October 17, 2019 5:49:56 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
I made a separate post for this menu script, as I think it's a really handy script!

I've also made a few other tweaks to it, so check there for an updated version:

https://forum.strokesplus.net/posts/m9766-Create-Menu-with-All-Actions
liuchina  
#13 Posted : Friday, October 18, 2019 12:27:25 AM(UTC)
liuchina

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 9/26/2018(UTC)
Posts: 73
China
Location: 北京

Thanks: 18 times
Was thanked: 1 time(s) in 1 post(s)
I have updated S + net to the latest version. The new script runs perfectly. Thank you very much.
Users browsing this topic
Guest
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.