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

Notification

Icon
Error

Options
Go to last post Go to first unread
Sherif Aliti  
#1 Posted : Thursday, February 24, 2022 7:11:07 PM(UTC)
Sherif Aliti

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 2/16/2021(UTC)
Posts: 39
Albania
Location: Fier

Thanks: 25 times
Was thanked: 1 time(s) in 1 post(s)
Is there a script to count mouse click time ?
Need to use the same button for different functions - Example Mouse X1 button - copy then if Mouse X! button long-press "ex:3 sec" then Cut
Is this possible? Thanks

thanks 1 user thanked Sherif Aliti for this useful post.
randomConstant on 2/26/2022(UTC)
Rob  
#2 Posted : Friday, February 25, 2022 3:07:15 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)
Is X1 a stroke button?
thanks 1 user thanked Rob for this useful post.
Sherif Aliti on 2/25/2022(UTC)
Sherif Aliti  
#3 Posted : Friday, February 25, 2022 9:05:21 PM(UTC)
Sherif Aliti

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 2/16/2021(UTC)
Posts: 39
Albania
Location: Fier

Thanks: 25 times
Was thanked: 1 time(s) in 1 post(s)
Originally Posted by: Rob Go to Quoted Post
Is X1 a stroke button?


No, my Mouse stroke button is the Middle one.

X1 I use for Copy
X2 I use for Past.
Is possible if I press the long X1 button ex:3 SEC to make a Cut instead of a Copy? Thanks in Advance

Copy Command

Paste Command

Edited by user Friday, February 25, 2022 9:06:14 PM(UTC)  | Reason: Not specified

Rob  
#4 Posted : Friday, February 25, 2022 9:37:21 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)
Sure, this should work:
Code:
if(click.Down)
{
    // Button press

    // Clear cut variable
    sp.StoreBool("X1Cut", false);

    // Start a timer, set to 2000 milliseconds (2 seconds)
    // If the timer executes, it sets the Cut variable
    sp.CreateTimer("X1LongPressTimer", 2000, -1, `sp.StoreBool("X1Cut", true);`); 

} else {

    // Button release

    // Remove the Cut timer, prevent it from executing if less than 2 seconds
    // Won't do anything if timer already executed
    sp.DeleteTimer("X1LongPressTimer");

    // Check the Cut variable, if it is true (X1 held until timer executed)
    // Send Ctrl+X
    // Otherwise, send Ctrl+C
    if(sp.GetStoredBool("X1Cut")) {
        sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_X]);
    } else {
        sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_C]);
    }
}
thanks 1 user thanked Rob for this useful post.
Sherif Aliti on 2/26/2022(UTC)
Rob  
#5 Posted : Friday, February 25, 2022 9:46:17 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)
You can also use timers and variables to store click counts, so if you double-click X1 (timer set to like 250 ms), it sees it as a double-click and does Cut.

That's a little more complicated, but with the example above, it should give you the pieces you'd need to figure it out :)
Rob  
#6 Posted : Friday, February 25, 2022 9:57:11 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)
Eh, seems like it wasn't very complicated, lol.
Code:
if(click.Down)
{
    // Get current click count, add 1
    var x1Clicks = sp.GetStoredNumber("X1Clicks") + 1;

    // Store click count
    sp.StoreNumber("X1Clicks", x1Clicks);

    // Only start timer on the first click
    if(x1Clicks == 1) {
        sp.CreateTimer("X1ClickCountResetTimer", 
                       250, //250ms
                       -1,  // -1 means the timer doesn't repeat, otherwise this is the interval (ms) it should execute repeatedly
                       `// If more than one X1 click within 250ms, send Ctrl+X
                        // Otherwise, Ctrl+C
                        if(sp.GetStoredNumber("X1Clicks") > 1) {
                            sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_X]);
                        } else {
                            sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_C]);
                        }
                        // Reset click count
                        sp.StoreNumber("X1Clicks", 0);`
                      ); 
    }
} 

Edited by user Friday, February 25, 2022 9:59:58 PM(UTC)  | Reason: Not specified

thanks 2 users thanked Rob for this useful post.
randomConstant on 2/26/2022(UTC), Sherif Aliti on 2/26/2022(UTC)
Sherif Aliti  
#7 Posted : Saturday, February 26, 2022 9:54:26 AM(UTC)
Sherif Aliti

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 2/16/2021(UTC)
Posts: 39
Albania
Location: Fier

Thanks: 25 times
Was thanked: 1 time(s) in 1 post(s)
Originally Posted by: Rob Go to Quoted Post
Sure, this should work:
Code:
if(click.Down)
{
    // Button press

    // Clear cut variable
    sp.StoreBool("X1Cut", false);

    // Start a timer, set to 2000 milliseconds (2 seconds)
    // If the timer executes, it sets the Cut variable
    sp.CreateTimer("X1LongPressTimer", 2000, -1, `sp.StoreBool("X1Cut", true);`); 

} else {

    // Button release

    // Remove the Cut timer, prevent it from executing if less than 2 seconds
    // Won't do anything if timer already executed
    sp.DeleteTimer("X1LongPressTimer");

    // Check the Cut variable, if it is true (X1 held until timer executed)
    // Send Ctrl+X
    // Otherwise, send Ctrl+C
    if(sp.GetStoredBool("X1Cut")) {
        sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_X]);
    } else {
        sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_C]);
    }
}



Gr8 Works really good. Thanks - If possible this ption should be added as option. Mouse click time interval - Just an opinion

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.