StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
misaki4650  
#1 Posted : Sunday, March 7, 2021 9:54:54 AM(UTC)
misaki4650

Rank: Member

Reputation:

Groups: Approved
Joined: 2/21/2021(UTC)
Posts: 15
Japan
Location: nagano

Thanks: 16 times
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.
Rob  
#2 Posted : Sunday, March 7, 2021 12:58:14 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 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

thanks 1 user thanked Rob for this useful post.
misaki4650 on 3/7/2021(UTC)
misaki4650  
#3 Posted : Sunday, March 7, 2021 2:07:35 PM(UTC)
misaki4650

Rank: Member

Reputation:

Groups: Approved
Joined: 2/21/2021(UTC)
Posts: 15
Japan
Location: nagano

Thanks: 16 times
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;
});
Rob  
#4 Posted : Sunday, March 7, 2021 3:46:33 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 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.
thanks 1 user thanked Rob for this useful post.
misaki4650 on 3/7/2021(UTC)
misaki4650  
#5 Posted : Sunday, March 7, 2021 5:52:38 PM(UTC)
misaki4650

Rank: Member

Reputation:

Groups: Approved
Joined: 2/21/2021(UTC)
Posts: 15
Japan
Location: nagano

Thanks: 16 times
I added this because I have trouble selecting text.
Thank you very much for everything.
I'll keep using StrokesPlus.net!
Smile

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

Rob  
#6 Posted : Monday, March 8, 2021 12:16:19 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 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");
                   `); 
}
thanks 1 user thanked Rob for this useful post.
misaki4650 on 3/8/2021(UTC)
misaki4650  
#7 Posted : Monday, March 8, 2021 8:12:03 PM(UTC)
misaki4650

Rank: Member

Reputation:

Groups: Approved
Joined: 2/21/2021(UTC)
Posts: 15
Japan
Location: nagano

Thanks: 16 times
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);.

UserPostedImage
Rob  
#8 Posted : Tuesday, March 9, 2021 11:11:21 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
I'm having a little challenge understanding the sequence and configuration.

Could you provide some additional details / steps to reproduce your scenario?
thanks 1 user thanked Rob for this useful post.
misaki4650 on 3/9/2021(UTC)
misaki4650  
#9 Posted : Tuesday, March 9, 2021 4:14:05 PM(UTC)
misaki4650

Rank: Member

Reputation:

Groups: Approved
Joined: 2/21/2021(UTC)
Posts: 15
Japan
Location: nagano

Thanks: 16 times
https://forum.strokesplus.net/po...g-of-X1-and-X2#post11764

Take 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.
Rob  
#10 Posted : Wednesday, March 10, 2021 2:05:19 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 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-Subscriptions

Specifically, 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.
thanks 1 user thanked Rob for this useful post.
misaki4650 on 3/10/2021(UTC)
misaki4650  
#11 Posted : Thursday, March 11, 2021 4:04:31 PM(UTC)
misaki4650

Rank: Member

Reputation:

Groups: Approved
Joined: 2/21/2021(UTC)
Posts: 15
Japan
Location: nagano

Thanks: 16 times
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.
soooulp  
#12 Posted : Sunday, April 18, 2021 3:09:17 PM(UTC)
soooulp

Rank: Advanced Member

Reputation:

Groups: Moderators, Approved
Joined: 4/23/2020(UTC)
Posts: 161
China

Thanks: 46 times
Was thanked: 23 time(s) in 17 post(s)
Originally Posted by: Rob Go to Quoted Post
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');
                    }
                    `
    );
}
Rob  
#13 Posted : Monday, April 19, 2021 3:38:29 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 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');
                    }
                    `
    );
}
soooulp  
#14 Posted : Monday, April 19, 2021 11:48:22 AM(UTC)
soooulp

Rank: Advanced Member

Reputation:

Groups: Moderators, Approved
Joined: 4/23/2020(UTC)
Posts: 161
China

Thanks: 46 times
Was thanked: 23 time(s) in 17 post(s)
Originally Posted by: Rob Go to Quoted Post


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

Rob  
#15 Posted : Monday, April 19, 2021 2:46:13 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 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);
                    }
                   `
); 
thanks 1 user thanked Rob for this useful post.
soooulp on 4/19/2021(UTC)
soooulp  
#16 Posted : Monday, April 19, 2021 6:34:25 PM(UTC)
soooulp

Rank: Advanced Member

Reputation:

Groups: Moderators, Approved
Joined: 4/23/2020(UTC)
Posts: 161
China

Thanks: 46 times
Was thanked: 23 time(s) in 17 post(s)
Originally Posted by: Rob Go to Quoted Post
I swapped the start and interval value for sp.CreateTimer and it seems to work for me.


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

Rob  
#17 Posted : Monday, April 19, 2021 6:41:25 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 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.
thanks 1 user thanked Rob for this useful post.
soooulp on 4/19/2021(UTC)
zyxi  
#18 Posted : Sunday, September 12, 2021 2:32:41 AM(UTC)
zyxi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/30/2019(UTC)
Posts: 74
China

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 Go to Quoted Post
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");
                   `); 
}




Rob  
#19 Posted : Tuesday, September 14, 2021 2:35:58 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 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.
Users browsing this topic
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.