StrokePlus.net - Powerful Hotkey Boot

2022-09-21 10:37:04 浏览数 (1)

  • StrokePlus Vs StrokePlus.net

  • Code Help
  • Usage
    • Snippets
      • Activate when double pressed

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]); `);

0 人点赞