Rank: Member
Groups: Approved
Joined: 2/21/2021(UTC) Posts: 16 Location: nagano Thanks: 16 times Was thanked: 1 time(s) in 1 post(s)
|
Nice to meet you. I've always been comfortable using StrokesPlus.net. Could you please tell me the script for the doubleclick on the left?
if(click.Down) {    if(click.Down) { sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_W]); } else { sp.MouseClick(sp.GetCurrentMousePoint(), MouseButtons.Left, true, true); } }
This is the only thing I can find when I search the forum for double-clicking.
var text_doubleClick = text.DoubleClick.connect( function (sender, args) { form.Close();
I did a web search and found this script.
$("#other").dblclick(function() { $("#target").dblclick(); });
Thank you for your help. I'm sorry my English is not good enough. These sentences are translated by Deepl translation site.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
The only difference between a click and a double-click is timing. In a double-click, a single click is always processed - it is simply a matter of whether a second click was also done soon enough after a previous click which signals a double-click event. In the code below, it uses a timer set to 400 milliseconds which helps to determine if a click should be recognized as a double-click. This is not using the Consume Click Event option selected, as that could interfere with other operations. However, you could use the consume (absorb, prevent) option - but you would then need to send the clicks manually (shown at the top, remove "//" from click line). Code://Use line below if consume option is checked
//sp.MouseClick(click.Point, MouseButtons.Left, click.Down, !click.Down);
//If mouse up and double click timer has not cleared the variable
if(!click.Down && sp.GetStoredBool("DoubleClickCheck")) {
//Send Ctrl+W
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_W]);
}
//If mouse up and double click timer has not been created
if(!click.Down && !sp.GetStoredBool("DoubleClickCheck")) {
//Store variable for above code to look for
sp.StoreBool("DoubleClickCheck", true);
//Create timer that waits 400 milliseconds, then clears the variable
//Adjust 400 to set the desired amount of time between clicks to
//indicate a double click should be detected
sp.CreateTimer("DoubleClickTimer",
400,
0,
`sp.StoreBool("DoubleClickCheck", false);
sp.DeleteTimer("DoubleClickTimer");
`);
}
Edited by user Sunday, March 7, 2021 12:59:32 PM(UTC)
| Reason: Not specified
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Member
Groups: Approved
Joined: 2/21/2021(UTC) Posts: 16 Location: nagano Thanks: 16 times Was thanked: 1 time(s) in 1 post(s)
|
Thank you very much for your quick reply. I have one more question, if you don't mind.
Is it called "long press and click"? It would be great if you could also tell me the script that works if I hold down the left click for one second. Please reply at your convenience.
I did a web search and found this script.
$("a").mouseup(function(){ clearTimeout(pressTimer); // Clear timeout return false; }).mousedown(function(){ // Set timeout pressTimer = window.setTimeout(function() { ... Your Code ...},1000); return false; });
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
It's very similar to the previous code, the example below mirrors the JavaScript code you posted. Code://If mouse up, delete timer
if(!click.Down) {
sp.DeleteTimer("LongPressTimer");
}
//If mouse down
if(click.Down) {
//Create timer that waits 1000 milliseconds, then executes
//the code enclosed in backticks
sp.CreateTimer("LongPressTimer",
1000,
0,
`// your long press code here
sp.MessageBox("Long Press", "Long Press");
sp.DeleteTimer("LongPressTimer");
`);
}
It is important to remember that while the S+ script language is JavaScript, it's not in the context of a web browser, so script you may find on the web which interact with a page or mouse/keyboard input will not directly translate.
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Member
Groups: Approved
Joined: 2/21/2021(UTC) Posts: 16 Location: nagano Thanks: 16 times Was thanked: 1 time(s) in 1 post(s)
|
I added this because I have trouble selecting text. Thank you very much for everything. I'll keep using StrokesPlus.net! Code:
//If mouse up, delete timer
if(!click.Down) {
sp.DeleteTimer("LongPressTimer");
}
//If mouse down
if(click.Down && (sp.GetCurrentMouseCursor() == "Arrow") ) {
//Create timer that waits 1000 milliseconds, then executes
//the code enclosed in backticks
sp.CreateTimer("LongPressTimer",
1000,
0,
`sp.StoreBool("LongPressCheck", false);
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_W]);
sp.DeleteTimer("LongPressTimer");
`);
}
Edited by user Sunday, March 7, 2021 5:55:07 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
Here is a sample that would only perform the long click if the mouse has moved less than 25 pixels from the start location. Code://If mouse up, delete timer
if(!click.Down) {
sp.DeleteTimer("LongPressTimer");
}
//If mouse down
if(click.Down) {
//Store start location for use in timer script
sp.StorePoint("ClickStart", click.Point);
//Create timer that waits 1000 milliseconds, then executes
//the code enclosed in backticks
sp.CreateTimer("LongPressTimer",
1000,
0,
`//Get the start point/location where mouse down occurred
var startPoint = sp.GetStoredPoint("ClickStart");
//Get the current mouse location
var currPoint = sp.GetCurrentMousePoint();
//Calculate distance in pixels from the start of the click
var distance = Math.sqrt(Math.pow((currPoint.X- startPoint.X), 2.0) + Math.pow((currPoint.Y - startPoint.Y), 2.0));
//Only if the mouse has moved less than 25 pixels since click down
if (distance < 25) {
//Send mouse up to prevent issues with keys thinking mouse is still down
sp.MouseClick(currPoint, MouseButtons.Left, false, true);
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_W]);
}
sp.DeleteTimer("LongPressTimer");
`);
}
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Member
Groups: Approved
Joined: 2/21/2021(UTC) Posts: 16 Location: nagano Thanks: 16 times Was thanked: 1 time(s) in 1 post(s)
|
Thanks for the great improvement. I was able to use it while it was set to the stroke button. I have one more request. When I run LongPressTimer with the right click set as the stroke button, the context menu appears at the end. Is it possible to hide it? The image below shows the execution of sp.SendVKey(vk.HOME);.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
I'm having a little challenge understanding the sequence and configuration.
Could you provide some additional details / steps to reproduce your scenario?
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Member
Groups: Approved
Joined: 2/21/2021(UTC) Posts: 16 Location: nagano Thanks: 16 times Was thanked: 1 time(s) in 1 post(s)
|
https://forum.strokesplus.net/po...g-of-X1-and-X2#post11764Take a hint from the link above 1.Right-click down(LongPress) 2.Esc Down (script (sp.SendVKey(vk.HOME);) is runnin) 3.Right-click Up 4.Esc Up If you press in this order, the context menu screen will not appear. This also works well with X1. But Just inserting  sp.SendVKey(vk.ESCAPE);  into the script did not work. X2 and wheel-clicking did not work with the above steps either.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
So you're just trying to use the Escape key being held down to avoid the context menu from showing? Honestly, at this point you might be better off using the mouse button hook, which will give you precise control over all mouse button events, which includes handling the mouse button events before S+ starts to process its internal logic. https://forum.strokesplus.net/posts/t7209-Mouse---Keyboard-Event-SubscriptionsSpecifically, the synchronous OnMouseHookButtonEvent, which lets you set mouseHookEvent.Consume = true; and even S+ ignores the button press (along with all other apps not seeing it). To handle this the way I think it's being done, you'd probably have to create a timer that continuously sent sp.SendVKeyDown(vk.ESCAPE); until the script was done, then send sp.SendVKeyUp(vk.ESCAPE); to release the Escape key. When you physically hold a key, it sends the key down, then pauses, then sends repeated key down events until release.
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Member
Groups: Approved
Joined: 2/21/2021(UTC) Posts: 16 Location: nagano Thanks: 16 times Was thanked: 1 time(s) in 1 post(s)
|
The MouseHook relation is too high level for me to understand. I tried to insert sp.SendVKeyDown(vk.ESCAPE); and sp.SendVKeyUp(vk.ESCAPE); but it didn't work.
I will take the time to challenge myself. Thank you very much for all the hints.
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 161 Thanks: 46 times Was thanked: 23 time(s) in 17 post(s)
|
Originally Posted by: Rob Here is a sample that would only perform the long click if the mouse has moved less than 25 pixels from the start location.
Hi Rob, I need your help. Could it track whether the mouse moves in 6s? I use the following code in Global Actions-Load/Unload, but it does work. Code:
sp.CreateTimer("PointTimer",
250,
250,
`
if(!sp.GetStoredBool("mouseMove")) {
sp.StoreBool("mouseMove", true);
}
`
);
if(sp.GetStoredBool("mouseMove")) {
//Get the current mouse location
var currentMouseLocation = sp.GetCurrentMousePoint();
sp.StorePoint("mouseStart", currentMouseLocation);
sp.CreateTimer('mouseMoveTimer',
6000,
-1,
`
//Get the start point/location
var startPoint = sp.GetStoredPoint("mouseStart");
//Get the current mouse location
var currPoint = sp.GetCurrentMousePoint();
if (currPoint.X - startPoint.X == 0) {
sp.MessageBox('Title', 'Message')
sp.StoreBool("mouseMove", false);
} else {
sp.DeleteTimer('mouseMoveTimer');
}
`
);
}
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
Code:sp.CreateTimer("PointTimer",
250,
250,
`
if(!sp.GetStoredBool("mouseMove")) {
sp.StoreBool("mouseMove", true);
}
`
);
// ^^
// THIS is not true, because the timer above doesn't set the value before this line is processed.
// V ---- V
if(sp.GetStoredBool("mouseMove")) {
//Get the current mouse location
var currentMouseLocation = sp.GetCurrentMousePoint();
sp.StorePoint("mouseStart", currentMouseLocation);
sp.CreateTimer('mouseMoveTimer',
6000,
-1,
`
//Get the start point/location
var startPoint = sp.GetStoredPoint("mouseStart");
//Get the current mouse location
var currPoint = sp.GetCurrentMousePoint();
if (currPoint.X - startPoint.X == 0) {
sp.MessageBox('Title', 'Message')
sp.StoreBool("mouseMove", false);
} else {
sp.DeleteTimer('mouseMoveTimer');
}
`
);
}
|
|
|
|
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 161 Thanks: 46 times Was thanked: 23 time(s) in 17 post(s)
|
Originally Posted by: Rob
Code:sp.CreateTimer("PointTimer",
250,
250,
`
if(!sp.GetStoredBool("mouseMove")) {
sp.StoreBool("mouseMove", true);
}
`
);
// ^^
// THIS is not true, because the timer above doesn't set the value before this line is processed.
// V ---- V
if(sp.GetStoredBool("mouseMove")) {
//Get the current mouse location
var currentMouseLocation = sp.GetCurrentMousePoint();
sp.StorePoint("mouseStart", currentMouseLocation);
sp.CreateTimer('mouseMoveTimer',
6000,
-1,
`
//Get the start point/location
var startPoint = sp.GetStoredPoint("mouseStart");
//Get the current mouse location
var currPoint = sp.GetCurrentMousePoint();
if (currPoint.X - startPoint.X == 0) {
sp.MessageBox('Title', 'Message')
sp.StoreBool("mouseMove", false);
} else {
sp.DeleteTimer('mouseMoveTimer');
}
`
);
}
I change to use the count, tracking whether the mouse moves still don't work, Oops. At the same time, I want it will work continuously after run sp.StoreBool("mouseRestrict", false) as a condition. I find Options-Advanced Max Script Pool Size can be set at more than 20, should I change 1000 to 10000 when I want to track whether the mouse moves in 1min? Code:
var currentMouseLocation = sp.GetCurrentMousePoint();
sp.StorePoint("mouseStart", currentMouseLocation);
sp.CreateTimer("mouseTimer",
1000,
0,
`
if(!sp.GetStoredBool("mouseRestrict")) {
//Get the start point/location
var startPoint = sp.GetStoredPoint("mouseStart");
//Get the current mouse location
var currPoint = sp.GetCurrentMousePoint();
if (currPoint.X - startPoint.X === 0) {
sp.StoreNumber('n', sp.GetStoredNumber('n') + 1);
var num = sp.GetStoredNumber('n');
if(num === 6) {
sp.MessageBox(num, 'Message');
sp.StoreBool("mouseRestrict", true);
}
} else {
sp.StoreNumber('n', 0);
}
} else {
sp.StoreNumber('n', 0);
}
`
);
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
I swapped the start and interval value for sp.CreateTimer and it seems to work for me. Code:var currentMouseLocation = sp.GetCurrentMousePoint();
sp.StorePoint("mouseStart", currentMouseLocation);
sp.CreateTimer("mouseTimer",
0,
1000,
`
if(!sp.GetStoredBool("mouseRestrict")) {
//Get the start point/location
var startPoint = sp.GetStoredPoint("mouseStart");
//Get the current mouse location
var currPoint = sp.GetCurrentMousePoint();
if (currPoint.X - startPoint.X === 0) {
sp.StoreNumber('n', sp.GetStoredNumber('n') + 1);
var num = sp.GetStoredNumber('n');
if(num === 6) {
sp.MessageBox(num, 'Message');
sp.StoreBool("mouseRestrict", true);
}
} else {
sp.StoreNumber('n', 0);
}
} else {
sp.StoreNumber('n', 0);
}
`
);
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 161 Thanks: 46 times Was thanked: 23 time(s) in 17 post(s)
|
Originally Posted by: Rob Thankkkkkkk you, I do a little change, may this time track whether the mouse moves in anytime. This is why I still don't understand the startdelay and interval element in CreatTimer for so long time. Code:
var currentMouseLocation = sp.GetCurrentMousePoint();
sp.StorePoint("mouseStart", currentMouseLocation);
sp.CreateTimer("mouseTimer",
0,
1000,
`
if(!sp.GetStoredBool("mouseRestrict")) {
//Get the start point/location
var startPoint = sp.GetStoredPoint("mouseStart");
//Get the current mouse location
var currPoint = sp.GetCurrentMousePoint();
if (currPoint.X - startPoint.X === 0) {
sp.StoreNumber('n', sp.GetStoredNumber('n') + 1);
var num = sp.GetStoredNumber('n');
if(num === 6) {
//sp.MouseRestrictToRectangle(new Rectangle(currPoint.X, currPoint.Y, 0, 0));
sp.ShowBalloonTip('Title','Message here','Info',1000);
//sp.MessageBox(num, 'Message');
sp.StoreBool("mouseRestrict", true);
sp.StoreNumber('n', 0);
}
} else {
currentMouseLocation = sp.GetCurrentMousePoint();
sp.StorePoint("mouseStart", currentMouseLocation);
sp.StoreNumber('n', 0);
}
} else {
sp.StoreNumber('n', 0);
}
`
);
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
Start delay is how long to wait for the first execution.
Interval is how often to repeat the execution after the start delay.
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 3/30/2019(UTC) Posts: 74 Thanks: 8 times Was thanked: 1 time(s) in 1 post(s)
|
Dear friends, can S+ limit the distance between two points (the point double-clicked twice) not to exceed 10 pixels to execute the script? Originally Posted by: Rob The only difference between a click and a double-click is timing. In a double-click, a single click is always processed - it is simply a matter of whether a second click was also done soon enough after a previous click which signals a double-click event. In the code below, it uses a timer set to 400 milliseconds which helps to determine if a click should be recognized as a double-click. This is not using the Consume Click Event option selected, as that could interfere with other operations. However, you could use the consume (absorb, prevent) option - but you would then need to send the clicks manually (shown at the top, remove "//" from click line). Code://Use line below if consume option is checked
//sp.MouseClick(click.Point, MouseButtons.Left, click.Down, !click.Down);
//If mouse up and double click timer has not cleared the variable
if(!click.Down && sp.GetStoredBool("DoubleClickCheck")) {
//Send Ctrl+W
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_W]);
}
//If mouse up and double click timer has not been created
if(!click.Down && !sp.GetStoredBool("DoubleClickCheck")) {
//Store variable for above code to look for
sp.StoreBool("DoubleClickCheck", true);
//Create timer that waits 400 milliseconds, then clears the variable
//Adjust 400 to set the desired amount of time between clicks to
//indicate a double click should be detected
sp.CreateTimer("DoubleClickTimer",
400,
0,
`sp.StoreBool("DoubleClickCheck", false);
sp.DeleteTimer("DoubleClickTimer");
`);
}
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
Quote:Dear friends, can S+ limit the distance between two points (the point double-clicked twice) not to exceed 10 pixels to execute the script? See post #6 in this thread for an example.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close