StrokesPlus.net教程及脚本持续更新

右键执行中键

点右键关闭浏览器标签页,打开书签栏书签,支持Chrome,Edge,Firefox,按Ctrl+右键正常显示菜单(官方论坛帖子

添加到全局动作-启动/退出-启动(开启)

重要设置:选项-高级-启动订阅鼠标钩子事件

// Define globally instead of each click
var browser_classname = ["Chrome_WidgetWin_1", "MozillaWindowClass"];

var mouseButtonEventObj = sp.GetStoredObject("mouseButtonEvent");
//Disconnect any existing binding for this object name
if(mouseButtonEventObj.GetType().FullName.includes('EventConnection'))
{
    mouseButtonEventObj.disconnect();
    sp.DeleteStoredObject("mouseButtonEvent");
} 

//Create the event binding and bind to synchronous event
var mouseButtonEvent = MouseHook.OnMouseHookButtonEvent.connect(
    function (sender, mouseHookEvent) {
        //Wrap all code in try/catch, exceptions will crash S+
        try
        {
            if(mouseHookEvent.Button == MouseButtons.Right)
            {
                var mouseWindow = sp.WindowFromPoint(mouseHookEvent.Location, true);
                if(browser_classname.includes(mouseWindow.ClassName) 
                    && ((mouseHookEvent.Location.Y >= mouseWindow.Rectangle.Top && mouseHookEvent.Location.Y < mouseWindow.Rectangle.Top + 35) || (mouseHookEvent.Location.Y >= mouseWindow.Rectangle.Top + 70 && mouseHookEvent.Location.Y < mouseWindow.Rectangle.Top + 105))
                    && !mouseHookEvent.InjectedByHost) 
                {
                    if(mouseHookEvent.ButtonState == ButtonState.Up)
                    {
                        if (sp.GetKeyState(vk.CONTROL) & 0x8000)
                        {
                            // Invoke right click on new thread so the hook
                            // doesn't get stuck while waiting for this method 
                            // to return
                            sp.CreateTimer("rightClick", 
                                           0, 
                                           -1, 
                                           `sp.MouseClick(sp.GetCurrentMousePoint(), MouseButtons.Right, true, true); 
                                            sp.DeleteTimer("rightClick");`
                                          );
                            
                        }
                        else
                        {
                            // Invoke middle click on new thread so the hook
                            // doesn't get stuck while waiting for this method 
                            // to return
                            sp.CreateTimer("middleClick", 
                                           0, 
                                           -1, 
                                           `sp.MouseClick(sp.GetCurrentMousePoint(), MouseButtons.Middle, true, true); 
                                            sp.DeleteTimer("middleClick");`
                                          );
                        }
                    }
                    mouseHookEvent.Consume = true;
                }
            }
        }
        catch(err) 
        {
            StrokesPlus.Console.Log(err.message);
        }
    });

//Note that on S+ reload, events in Stored Object list have disconnect called on them
sp.StoreObject("mouseButtonEvent", mouseButtonEvent);