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

Notification

Icon
Error

Options
Go to last post Go to first unread
thepromises  
#1 Posted : Thursday, March 25, 2021 5:30:04 AM(UTC)
thepromises

Rank: Member

Reputation:

Groups: Approved
Joined: 6/14/2019(UTC)
Posts: 11
China

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.
Rob  
#2 Posted : Tuesday, March 30, 2021 1:57:11 PM(UTC)
Rob

Rank: Administration

Reputation:

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

Thanks: 21 times
Was thanked: 255 time(s) in 222 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

thanks 1 user thanked Rob for this useful post.
thepromises on 3/31/2021(UTC)
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.