//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 {} }