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 : Friday, June 14, 2019 2:08:15 PM(UTC)
thepromises

Rank: Member

Reputation:

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

Thanks: 8 times
Can you share the mouse and double click to close the Chrome tab? Thank you!
Rob  
#2 Posted : Saturday, June 15, 2019 11:54:52 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 need a little more specific details about exactly what/where/how this should react.
thepromises  
#3 Posted : Sunday, June 16, 2019 4:45:28 AM(UTC)
thepromises

Rank: Member

Reputation:

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

Thanks: 8 times
Double-click anywhere on the current tab bar at the top of Chrome to close the current tab!
Rob  
#4 Posted : Sunday, June 16, 2019 1:54:05 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)
Ack! This does not look for the mouse location, it would close the tab on any double-click within Chrome.

Hold on, let me fix.
Rob  
#5 Posted : Sunday, June 16, 2019 2:07:26 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)
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 25px 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 + 25) {
            //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 {}
}


IMPORTANT: There's no way to determine if the mouse is over a tab, only that it is within 25 pixels from the top of the Chrome window.
So you may have some issues, but try it out and see if it is okay for you.

Edited by user Sunday, June 16, 2019 2:10:01 PM(UTC)  | Reason: Added try/catch to ignore script execution on failure for certain circumstances

thanks 1 user thanked Rob for this useful post.
thepromises on 6/17/2019(UTC)
Yuichi  
#6 Posted : Sunday, June 16, 2019 2:47:41 PM(UTC)
Yuichi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 9/13/2018(UTC)
Posts: 54
Poland

Thanks: 18 times
Was thanked: 18 time(s) in 13 post(s)
Hi
Some time ago I wrote a very similar code and had a problem with the changing state of the window (maximize / restore) when I double-clicked on the menu bar where there was no tab icon,
so this fix this problem.
Of course, the cursor will move slightly but the application will not go crazy.

I have put that before main script

Code:
// DO NOT LET THE WINDOW STATE CHANGE BY DOUBLE CLICKING ON THE MENU BAR (MAXIMIZE / RESTORE)
if (click.Down) {
    var wnd = sp.WindowFromPoint(sp.GetCurrentMousePoint(), true);
    if (wnd.Process.ProcessName == "chrome" &&
        ( // rectangle for tabs:
            (sp.GetCurrentMousePoint().Y) > (wnd.Rectangle.Top + 10)
            &&
            (sp.GetCurrentMousePoint().Y) < (wnd.Rectangle.Top + 45)
        )
        &&
        (
            (sp.GetCurrentMousePoint().X) > (wnd.Rectangle.Left + 15)
            &&
            (sp.GetCurrentMousePoint().X) < (wnd.Rectangle.Right - 180)
        )) {
                sp.MouseMove(new Point(sp.GetCurrentMousePoint().X+3,sp.GetCurrentMousePoint().Y)); // state change works only when the mouse is no more than 2 pixels away from the previous click
    }
}
thanks 1 user thanked Yuichi for this useful post.
thepromises on 6/17/2019(UTC)
2014218866  
#7 Posted : Sunday, June 30, 2019 7:11:12 AM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

Thanks: 19 times
Was thanked: 1 time(s) in 1 post(s)
Hello, friends!
I wonder if this script can be implemented.

When you click X1 once (release the X1 after clicking it once ), S + executes "sp. SendControlDown ()",
and when you click X1 the second time, it executes "sp. SendControlUp ()".

Looking forward to your reply
Rob  
#8 Posted : Sunday, June 30, 2019 12:55: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)
I haven't tested this out a lot, but this should get you started.

Code:
//Only process for mouse up/release events, so it doesn't run twice each click
if(!click.Down) {
    //If Control is down from previous click
    if(sp.GetStoredBool("ControlDown")) {
        sp.SendControlUp();
        sp.DeleteStoredBool("ControlDown");
    } else {
        //First click, send control down
        sp.StoreBool("ControlDown", true); 
        sp.SendControlDown();
    }
}
thanks 1 user thanked Rob for this useful post.
2014218866 on 6/30/2019(UTC)
2014218866  
#9 Posted : Sunday, June 30, 2019 1:26:13 PM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

Thanks: 19 times
Was thanked: 1 time(s) in 1 post(s)
Thank you for solving my problem again, Rob
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.