Below Snippets are for
StrokePlus.net
StrokePlus.net
is the new version of StrokePlus
StrokePlus.net is using C# for scripts.
Google 'C# How to do xxx' to find the help.
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
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:
sp.SendVKeyDown(vk.LCONTROL);
sp.SendVKeyDown(vk.LWIN);
sp.SendVKeyDown(vk.RIGHT);
sp.SendVKeyUp(vk.LCONTROL);
sp.SendVKeyUp(vk.LWIN);
sp.SendVKeyUp(vk.RIGHT);
Mind the double backslash
sp.RunProgram('C:\\Path\\FolderA\\FolderB\\VoiceInput.exe', '', 'open', 'normal', true, false, false);
/*
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));
This snippet will generate a script and save to clipboard. You can create ANOTHER hotkey with the copied scripts.
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 will be treated as plain string, so use eval()
to trigger them:
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);
}
}
For any hotkey/gesture:
// Usage (Double Press F1 to send Alt+F4):
eval(sp.GetMacroScript("Functions", "activeDoublePress"));
activeDoublePress(`sp.SendKeys("{F1}")`,`sp.SendModifiedVKeys([vk.LMENU], [vk.F4]); `);