前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >StrokePlus.net - Powerful Hotkey Boot

StrokePlus.net - Powerful Hotkey Boot

作者头像
szhshp
发布2022-09-21 10:37:04
1750
发布2022-09-21 10:37:04
举报

StrokePlus Vs StrokePlus.net

Below Snippets are for StrokePlus.net StrokePlus.net is the new version of StrokePlus

Code Help

StrokePlus.net is using C# for scripts.

Google 'C# How to do xxx' to find the help.

Usage

Snippets

Activate when double pressed

Double press backquote(`) to trigger F2 200ms is the best suitable duration for double press If only pressed for once, original key stroke will be triggered

代码语言:javascript
复制
var duration = 200;
var alreadyPressed = sp.GetStoredBool("pressed");

var originalKeyStroke = "`";
if (alreadyPressed) {
  sp.DeleteAllTimers();
  sp.StoreBool("pressed", false);

  /* The actual events are triggered here */
  sp.SendKeys("{F2}");

} else {
  sp.CreateTimer(
    "test",
    duration,
    -1,
    String.raw`

      /* after time out for 200ms, trigger the event here */
      sp.SendString(originalKeyStroke);
    
      sp.StoreBool("pressed", false);
    `
  );
  sp.StoreBool("pressed", true);
}

If you want to bind virtual key, you need to set the hotkey unregistered and consume:

Switch to next/previous screen
代码语言:javascript
复制
sp.SendVKeyDown(vk.LCONTROL);
sp.SendVKeyDown(vk.LWIN);
sp.SendVKeyDown(vk.RIGHT);

sp.SendVKeyUp(vk.LCONTROL);
sp.SendVKeyUp(vk.LWIN);
sp.SendVKeyUp(vk.RIGHT);
Open Specfic App

Mind the double backslash

代码语言:javascript
复制
sp.RunProgram('C:\\Path\\FolderA\\FolderB\\VoiceInput.exe', '', 'open', 'normal', true, false, false);
Click and back to previous position
代码语言:javascript
复制
/*
var a = sp.GetCurrentMousePoint();
sp.MessageBox(a.X + ',' + a.Y,'getPosition')
*/

var a = sp.GetCurrentMousePoint();
sp.MouseClick(new Point(939, 245), MouseButtons.Left, true, false);
sp.Sleep(86);
sp.MouseClick(new Point(939, 245), MouseButtons.Left, false, true);
sp.MouseMove(new Point(a.X, a.Y));
Generate a script to do quick click

This snippet will generate a script and save to clipboard. You can create ANOTHER hotkey with the copied scripts.

代码语言:javascript
复制
var currentMousePoint = sp.GetCurrentMousePoint();
sp.MessageBox(currentMousePoint.X + "," + currentMousePoint.Y, "getPosition");

var mousePoint = currentMousePoint.X + "," + currentMousePoint.Y;


var code = String.raw`var a = sp.GetCurrentMousePoint();
sp.MouseClick(new Point(${mousePoint}), MouseButtons.Left, true, false);
sp.Sleep(86);
sp.MouseClick(new Point(${mousePoint}), MouseButtons.Left, false, true);
sp.MouseMove(new Point(a.X, a.Y));`;

clip.SetText(code) // Code will be set to clipboard

sp.MessageBox(code, "Code Copied to Clipboard");

Macros

Macros will be treated as plain string, so use eval() to trigger them:

代码语言:javascript
复制
function activeDoublePress(actualKey, functionKey) {
  var duration = 200;
  var alreadyPressed = sp.GetStoredBool("pressed");

  if (alreadyPressed) {
    sp.DeleteAllTimers();
    sp.StoreBool("pressed", false);
    sp.SendKeys(functionKey);
  } else {
    sp.DeleteAllTimers();
    sp.CreateTimer(
      "test",
      duration,
      -1,
      String.raw`sp.SendString('${actualKey}');sp.StoreBool("pressed", false);
    );
    sp.StoreBool("pressed", true);
  }
}
Usage

For any hotkey/gesture:

代码语言:javascript
复制
// Usage (Double Press F1 to send Alt+F4):
eval(sp.GetMacroScript("Functions", "activeDoublePress"));
activeDoublePress(`sp.SendKeys("{F1}")`,`sp.SendModifiedVKeys([vk.LMENU], [vk.F4]); `);
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-01-20,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • StrokePlus Vs StrokePlus.net
  • Code Help
  • Usage
    • Snippets
      • Activate when double pressed
      • Switch to next/previous screen
      • Open Specfic App
      • Click and back to previous position
      • Generate a script to do quick click
    • Macros
      • Usage
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档