Rank: Advanced Member
Groups: Approved
Joined: 2/16/2021(UTC) Posts: 39 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
|
1 user thanked Sherif Aliti for this useful post.
|
|
|
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)
|
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 2/16/2021(UTC) Posts: 39 Location: Fier Thanks: 25 times Was thanked: 1 time(s) in 1 post(s)
|
Originally Posted by: Rob 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 Edited by user Friday, February 25, 2022 9:06:14 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)
|
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]);
}
}
|
1 user thanked Rob for this useful post.
|
|
|
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)
|
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 :)
|
|
|
|
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)
|
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
|
2 users thanked Rob for this useful post.
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 2/16/2021(UTC) Posts: 39 Location: Fier Thanks: 25 times Was thanked: 1 time(s) in 1 post(s)
|
Originally Posted by: Rob 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
|
|
|
|
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