Rank: Member
Groups: Approved
Joined: 6/14/2019(UTC) Posts: 14 Thanks: 8 times
|
Code://Only do this on mouse up (release)
if(!click.Down) {
//Get the window below the mouse
var mouseWindow = sp.WindowFromPoint(sp.GetCurrentMousePoint(), true);
//Check if the window below the mouse cursor is Chrome and that the mouse is
//within 28px of the top of the window
try {
if(mouseWindow.Process.MainModule.ModuleName == "chrome.exe"
&& click.Point.Y >= mouseWindow.Rectangle.Top
&& click.Point.Y <= mouseWindow.Rectangle.Top + 28) {
//If this is the second click, based on the previously stored value from the first click
if(sp.GetStoredBool("ChromeClick")) {
//Send CTRL+W to close the tab
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_W]);
} else {
//This is the first click, so store a value which can be used on next click
sp.StoreBool("ChromeClick", true);
//Create a timer that waits 200 milliseconds, then clears the click value and removes
//the timer (itself)
//NOTE: You may increase the 200 value below if you want to allow more time
//between first and second click
sp.CreateTimer("ChromeClickTimer", 200, 0, `sp.DeleteStoredBool("ChromeClick");
sp.DeleteTimer("ChromeClickTimer");`
);
}
}
} catch {}
}
Right click on double-click the mouse. It seems that it is invalid.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,349 Location: Tampa, FL Thanks: 28 times Was thanked: 416 time(s) in 354 post(s)
|
When you right-click, Windows shows the context menu and the next time the click script runs, the menu is the window below the mouse, which does not belong to Chrome - so it fails when checking for chrome.exe. This works for me, I changed the if to allow if Chrome OR if ChromeClick is true (from the first right-click): Code://Only do this on mouse up (release)
if(!click.Down) {
//Get the window below the mouse
var mouseWindow = sp.WindowFromPoint(sp.GetCurrentMousePoint(), true);
//Check if the window below the mouse cursor is Chrome and that the mouse is
//within 28px of the top of the window
try {
if(sp.GetStoredBool("ChromeClick")
|| (mouseWindow.Process.MainModule.ModuleName == "chrome.exe"
&& click.Point.Y >= mouseWindow.Rectangle.Top
&& click.Point.Y <= mouseWindow.Rectangle.Top + 28)) {
//If this is the second click, based on the previously stored value from the first click
if(sp.GetStoredBool("ChromeClick")) {
//Send CTRL+W to close the tab
sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_W]);
} else {
//This is the first click, so store a value which can be used on next click
sp.StoreBool("ChromeClick", true);
//Create a timer that waits 200 milliseconds, then clears the click value and removes
//the timer (itself)
//NOTE: You may increase the 200 value below if you want to allow more time
//between first and second click
sp.CreateTimer("ChromeClickTimer", 200, 0, `sp.DeleteStoredBool("ChromeClick");
sp.DeleteTimer("ChromeClickTimer");`
);
}
}
} catch {}
}
Edited by user Tuesday, March 30, 2021 1:57:50 PM(UTC)
| Reason: Not specified
|
1 user thanked Rob for this useful post.
|
|
|
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