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

动作里面是手势

快捷键里面是快捷键触发开和关,按回车输入框会关闭

弹图标栏 v0.2

类似Mac OS上的PopClip以及Windows上的SnipDo(原Pantherbar),弹出图标栏,通过图标替代右键菜单文字显示,鼠标移动到图标显示提示,点击图标执行动作,比如启动指定软件、复制、粘贴、剪切文字、打开链接等等

在2代码中的 imgData 对象中添加和设置需要显示图标的路径、提示、点击功能信息
image 图标路径,默认显示图标大小为22x22,需要在S+目录下新建icons文件夹,路径为 “\icons\name”,比如:path+“\icons\Rename.png”(双反斜杠)
tt 图标提示信息
popup 点击触发功能

需要按照模板,依次将各个Label绑定Click事件,与图标数相同

点击图标、点击空白之处、滚动后关闭图标栏
分别添加3代码、4代码,到 全局动作-鼠标事件-左键单击全局动作-鼠标事件-鼠标滚轮

更新:
20220807 移除透明背景,修复大图片显示,设置sz变量显示图标大小(默认22,显示为22x22)

不足之处
a 暂时无法识别划词之后,自动弹文字编辑相关功能的图标栏
b 显示图标栏闪的问题暂时无法解决

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

if(!NativeModules.User32)
{
    var IntPtrT = host.typeOf(clr.System.IntPtr);
    var Int32T = host.typeOf(clr.System.Int32);
    var BooleanT = host.typeOf(clr.System.Boolean);
	
    var user32TB = sp.NativeModule().DefineType("User32", "Class,Public,SequentialLayout,Serializable");

	user32TB.DefinePInvokeMethod("ShowWindow",
								 "user32.dll",
								 [IntPtrT,Int32T], 
								 BooleanT, 
								 "PreserveSig");

    user32TB.DefinePInvokeMethod("SetWindowPos",
								 "user32.dll",
								 [IntPtrT,Int32T,Int32T,Int32T,Int32T,Int32T,Int32T], 
								 BooleanT, 
								 "PreserveSig");

	user32TB.Create();
}

2

var currentMouseLocation = sp.GetCurrentMousePoint();
var mouseWnd = sp.WindowFromPoint(currentMouseLocation, true);
var wndHandle = mouseWnd.HWnd;
var desktopHandle = sp.DesktopWindowListView().HWnd;
var isDesktop = false;

var sz = 22; // The size of the icons to show, default 22x22

if(wndHandle.ToInt32() == desktopHandle.ToInt32() || sp.LastFocusControl().HWnd.ToInt32() == desktopHandle.ToInt32() ||
mouseWnd.ClassName == 'WorkerW' || mouseWnd.ClassName == 'Progman') {
    //Desktop
    isDesktop = true;
}

if (sp.WindowFromHandle(sp.GetStoredHandle('formHWDS1'))) {
    try {
        sp.WindowFromHandle(sp.GetStoredHandle('formHWDS1')).SendClose();
    } catch {}
}

var varLabel = ["label1", "label2", "label3", "label4", "label5", "label6",];
var labelClick = ["label1_Click", "label2_Click", "label3_Click", "label4_Click", "label5_Click", "label6_Click",];
var labelMouseEnter = ["label1_MouseEnter", "label2_MouseEnter", "label3_MouseEnter", "label4_MouseEnter", "label5_MouseEnter", "label6_MouseEnter",];
var labelMouseLeave = ["label1_MouseLeave", "label2_MouseLeave", "label3_MouseLeave", "label4_MouseLeave", "label5_MouseLeave", "label6_MouseLeave",];

var imgData = {
    lb1: {
        image: clr.System.IO.Path.GetDirectoryName(clr.System.Reflection.Assembly.GetEntryAssembly().Location) + "\\icons\\ag99y-oigie-001.ico",
        tt: "Hello",
        popup: function () {
            //sp.ConsoleLog('1');
            sp.SendVKey(vk.F2);
        },
    },
    lb2: {
        image: clr.System.IO.Path.GetDirectoryName(clr.System.Reflection.Assembly.GetEntryAssembly().Location) + "\\icons\\image-2022-07-29 203832.png",
        tt: "Yes",
        popup: function () {
            sp.ConsoleLog('2');
        },
    },
    lb3: {
        image: clr.System.IO.Path.GetDirectoryName(clr.System.Reflection.Assembly.GetEntryAssembly().Location) + "\\icons\\ag99y-oigie-001.ico",
        tt: "OK",        
        popup: function () {
            sp.ConsoleLog('3');
        },
    },
    lb4: {
        image: clr.System.IO.Path.GetDirectoryName(clr.System.Reflection.Assembly.GetEntryAssembly().Location) + "\\icons\\ag99y-oigie-001.ico",
        tt: "AHA",
        popup: function () {
            sp.ConsoleLog('4');
        },
    },
    lb5: {
        image: clr.System.IO.Path.GetDirectoryName(clr.System.Reflection.Assembly.GetEntryAssembly().Location) + "\\icons\\ag99y-oigie-001.ico",
        tt: "Opss",
        popup: function () {
            sp.ConsoleLog('5');
        },
    },
    lb6: {
        image: clr.System.IO.Path.GetDirectoryName(clr.System.Reflection.Assembly.GetEntryAssembly().Location) + "\\icons\\ag99y-oigie-001.ico",
        tt: "Hmmm",
        popup: function () {
            sp.ConsoleLog('6');
        },
    },
}

var Forms = forms.System.Windows.Forms;
var form = new Forms.Form;

form.StartPosition = Forms.FormStartPosition.Manual;
form.FormBorderStyle = Forms.FormBorderStyle.None;
form.TopMost = true;
form.ControlBox = false;
form.ShowInTaskbar = false;
form.Margin = new Forms.Padding(0);
//form.Padding = new Forms.Padding(1); 
form.MinimumSize = new Size(1, 1);
form.Size = new Size(150, sz);
form.Location = new Point(currentMouseLocation.X + 5, currentMouseLocation.Y + 25);
form.AutoSize = true;
form.GetType().GetProperty("DoubleBuffered",
        host.flags(clr.System.Reflection.BindingFlags.NonPublic,
        clr.System.Reflection.BindingFlags.Instance))
        .SetValue(form, true);
form.BackColor = Color.WhiteSmoke;
//form.TransparencyKey = Color.WhiteSmoke;
form.Opacity = 0.9;

var toolTip = new Forms.ToolTip;

var orign = 0;
for(var i = 0; i < varLabel.length; i++) {
    orign = i*sz;
    varLabel[i] = new Forms.Label;
    varLabel[i].Text = "";
    //varLabel[i].Image = new clr.System.Drawing.Bitmap(System.Drawing.Image.FromFile(imgData[Object.keys(imgData)[i]].image));
    varLabel[i].BackgroundImage =  new clr.System.Drawing.Bitmap(System.Drawing.Image.FromFile(imgData[Object.keys(imgData)[i]].image));
    varLabel[i].BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
    varLabel[i].Location = new Point(orign, 0);
    varLabel[i].Height = sz;
    varLabel[i].Width = sz;
    form.Controls.Add(varLabel[i]);

    toolTip.SetToolTip(varLabel[i], imgData[Object.keys(imgData)[i]].tt);

    labelMouseEnter[i] = 
    varLabel[i].MouseEnter.connect(
    function (sender, e) {
        toolTip.ShowAlways = true;
    });

    labelMouseLeave[i] = 
    varLabel[i].MouseLeave.connect(
    function (sender, e) {
        toolTip.ShowAlways = false;
    });
}

// 添加绑定图标数相等的点击事件
labelClick[0] =
varLabel[0].Click.connect(
function (sender, e) {

    sp.StoreBool('shownS1', false);
    sp.DeleteStoredHandle('formHWDS1');
    form.Close();
    if(isDesktop) {
        isDesktop = false;
        sp.WindowFromHandle(sp.DesktopWindowListView().HWnd).Activate();
    }
    var pp = new imgData[Object.keys(imgData)[0]].popup;

});

labelClick[1] =
varLabel[1].Click.connect(
function (sender, e) {
    sp.StoreBool('shownS1', false);
    sp.DeleteStoredHandle('formHWDS1');
    form.Close();
    if(isDesktop) {
        isDesktop = false;
        sp.WindowFromHandle(sp.DesktopWindowListView().HWnd).Activate();
    }
    var pp = new imgData[Object.keys(imgData)[1]].popup;
});

var form_shown = 
form.Shown.connect(
function (sender, args) {

    var HWND_TOPMOST = -1;
    var SWP_NOACTIVATE = 0x0010;
    var SW_SHOWNOACTIVATE = 4;
    NativeModules.User32.ShowWindow(form.Handle, SW_SHOWNOACTIVATE);
    NativeModules.User32.SetWindowPos(form.Handle, HWND_TOPMOST,form.Left, form.Top, form.Width, form.Height,SWP_NOACTIVATE);
    form.TopMost = false;

    sp.StoreBool('shownS1', true);
    sp.StoreHandle('formHWDS1', form.Handle);
});

Forms.Application.Run(form);

3

    if(sp.GetStoredBool('shownS1')) {
        try {
            if (sp.WindowFromPoint(sp.GetCurrentMousePoint(), true).ClassName != "WindowsForms10.Window.8.app.0.13965fa_r6_ad1" &&
                sp.WindowFromClassOrTitle("WindowsForms10.Window.8.app.0.13965fa_r6_ad1", "").Process.MainModule.ModuleName == "StrokesPlus.net.exe") {
                sp.StoreBool('shownS1', false);
                sp.WindowFromHandle(sp.GetStoredHandle('formHWDS1')).SendClose();
                sp.DeleteStoredHandle('formHWDS1');
            }
        } catch {}
    }

4

        sp.StoreBool('shownS1', false);
        sp.WindowFromHandle(sp.GetStoredHandle('formHWDS1')).SendClose();
        sp.DeleteStoredHandle('formHWDS1');

我搜索了PopClip,才知道这个脚本是干嘛的。换成"选择文字后自动弹出按钮"就容易理解了。

楼主我下载了你分享的配置文件并成功导入了,但是手势似乎没有那么多,特别是仿照MAX大佬分区域手势并没有效果。是我用错了方法吗。

分区域暂时只有屏幕四周滚动啦

哪些功能需要通过分区域设置呢

抱歉暂时没有精力维护打包文件,如果有需要我可以花时间弄弄

请问下,为什么用几次手势任务栏就会闪烁一下?

而且每次用手势任务栏最右侧都会出现一个"月牙"图标
图片
这个可以去掉么?


选这两个中的一个选项就可以了,但是这个"最顶层"的选项会把专注助手打开(那个月牙就是专注助手开启的标识),很奇怪,不过不闪就行了

1 个赞

emmmm,之前我碰到过切换专注助手,忘记怎么弄好了

update:要是个别手势显示成专注助手,看看快捷键是不是vk,要是不是改成vk试试,直接点脚本输入框上方插入快捷键然后录制了,确认

您好,想实现一个功能,期待得到您的帮助。
手势功能描述:打开右键菜单-寻找指定文字(比如“属性”)-左键点击指定文字(比如“属性”)。
不知spn能否实现?

具体是什么功能呢

按下右键后,按键盘上下键切换,然后回车

执行cmd命令行可以显示当前窗口属性

我想要实现在打开的右键菜单中找到指定的文字选项,然后左键点击,只是拿“属性”举个例子。比如要点击右键菜单中的b项,但b项在不同情况下的位置不固定,可能是a、b、c,也可能是a、d、b、c,想要实现点击b的功能。

可否告知具体是哪个软件的那个菜单选项

不固定非常难办

vk 是什么啊?

vk快捷键,比如sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_C]);

直接在脚本输入框上方插入那点击

这个功能具体该怎么设置啊,

1 放到 全局动作-启动/退出-启动(启用)
3 放到 全局动作-鼠标事件-左键单击(启用)
4 放到 全局动作-鼠标事件-鼠标滚轮(启用 吞掉) 这里用到[33#]所以有吞掉

2 放到 全局动作-启动/退出-启动 会报错
放到 全局动作-鼠标事件-左键单击 会无效

2是设置到手势,3是出现图标栏了点空白会关闭

请问一下,单个应用跟全局占用同一个手势,能不能做到先划出手势,然后等个几秒直到本应用的手势的提示没了,就会执行全局的手势。比如我在浏览器的上划是home键,全局是复制,那我立马上划就是home键,上划等几秒就是复制

为啥要等几秒

分不同的手势,或者1/8区域手势(一个上划短点,一个上划长点),或者起始点不同应用,不好嘛

理论上也不是不可以实现,推荐上面的

请问,如何实现:复制文本后,通过预设的正则表达或者弹窗替换复制文本,并且替换剪切板为修改后的文本呢

sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_C]);

var a = clip.GetText();

var b // 对a进行处理
clip.SetText(b);

/*
var inputBoxInfo = new InputBoxInfo();
inputBoxInfo.Title = 'Title text';
inputBoxInfo.Message = '';
inputBoxInfo.Items.Add(a);
inputBoxInfo.AllowDirectInput = true;
inputBoxInfo.Sort = true;
inputBoxInfo.ShowAtMouseCursor = true;
var res = sp.InputBox(inputBoxInfo);
if(res != null) {
	clip.SetText(res);
}
*/