Rank: Member
Groups: Approved
Joined: 6/14/2019(UTC) Posts: 14 Thanks: 8 times
|
Can you share the mouse and double click to close the Chrome tab? Thank you!
|
|
|
|
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)
|
I need a little more specific details about exactly what/where/how this should react.
|
|
|
|
Rank: Member
Groups: Approved
Joined: 6/14/2019(UTC) Posts: 14 Thanks: 8 times
|
Double-click anywhere on the current tab bar at the top of Chrome to close the current tab!
|
|
|
|
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)
|
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.
|
|
|
|
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)
|
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
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 9/13/2018(UTC) Posts: 54 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
}
}
|
1 user thanked Yuichi for this useful post.
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 111 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
|
|
|
|
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)
|
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();
}
}
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 111 Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
Thank you for solving my problem again, Rob
|
|
|
|
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