close tab with RCtrl

Get help with using AutoHotkey and its commands and hotkeys
usser
Posts: 99
Joined: 22 Oct 2014, 13:03

close tab with RCtrl

25 May 2015, 13:12

hello!

can you tell me please a script that will close the current tab in Firefox, with RCtrl?

thanks!
Randy31416
Posts: 46
Joined: 15 Jan 2014, 19:09

Re: close tab with RCtrl

25 May 2015, 19:44

This closes the active tab on my Firefox (ver 33.0.2) by sending the standard close-tab shorkcut (Control+w).

Code: Select all

#IfWinActive, ahk_class MozillaWindowClass ahk_exe firefox.exe
RControl::SendInput, ^w
Possibly Mozilla uses MozillaWindowClass windows elsewhere, and that is why I added the ahk_exe condition to the #IfWinActive. A word of caution, though: lots of shortcut keys involve the control key, and my hands want to type the RControl automatically for many of them, so I am putting tabs in peril every time I hit RControl unless I continue and hit some other key while the control key is still held.
usser
Posts: 99
Joined: 22 Oct 2014, 13:03

Re: close tab with RCtrl

01 Jun 2015, 14:18

thanks it works very well, I tested it for few days

by the way, can you add to it please the functionality of keyboard arrows left/right to focus the left/right to the active, tab?
but it shouldn't work when the cursor is inside a text box and I want to navigate through the text there!
User avatar
Nextron
Posts: 1378
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: close tab with RCtrl

01 Jun 2015, 16:12

Making the tabs switch using the arrow keys wouldn't be hard, by just sending a ^{tab} or ^+{tab}. But making it conditional by determining if a textbox has focus would be more of a challenge as Firefox doesn't behave as most other applications and its window is basically a black box.
usser
Posts: 99
Joined: 22 Oct 2014, 13:03

Re: close tab with RCtrl

01 Jun 2015, 16:16

maybe make it work only when there is a blinking vertical line? or the focus is on text box?
or if nothing can be done, then eventually when the cursor is IBeam maybe?
Randy31416
Posts: 46
Joined: 15 Jan 2014, 19:09

Re: close tab with RCtrl

02 Jun 2015, 20:18

Nextron is correct in that what goes on in the Firefox screen is essentially opaque and unpararsable, except to Firefox. I might suggest (although again I thing RControl by itself is a dangerous thing as I said in the second post) that you use RControl plus a left or right arrow to do the switching of the tabs. After all, RControl is right next to the arrrows on the standard keyboard layout, so it is an easy pair to type. And if you are using RControl by itself to manipulate tabs, your fingers are already there. If you like this, then the following should work (it does on my machine), sending the standard Firefox shortcuts Ctrl+PgUp and Ctrl+PgDn to move the focus tab left and right.

Code: Select all

#IfWinActive, ahk_class MozillaWindowClass ahk_exe firefox.exe
>^Left::SendInput, ^+{PgUp}
>^Right::SendInput, ^+{PgDn}
usser
Posts: 99
Joined: 22 Oct 2014, 13:03

Re: close tab with RCtrl

03 Jun 2015, 10:13

thanks, but I don't want to hit RCtrl and arrows

can you tell me a script that would go to next/previous tab with arrows only? and that would work only if the cursor is IBeam (if not possible to make it work only if a blinking vertical line for text exists)
usser
Posts: 99
Joined: 22 Oct 2014, 13:03

Re: close tab with RCtrl

04 Jun 2015, 15:46

why? what is the problem?
User avatar
Nextron
Posts: 1378
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: close tab with RCtrl

04 Jun 2015, 17:28

usser wrote:can you tell me a script that would go to next/previous tab with arrows only? and that would work only if the cursor is IBeam
You mean, not an Ibeam?
Remember that the cursor is the thing that moves with your mouse. The blinky thingy that moves in front of the letters you type is called a caret (and isn't always visible) Because of the obscured way Firefox works, it doesn't tell Windows if it exists or not, so it's difficult to check for. The cursor however is a Windows thing and is easy to check for, but it's only an Ibeam when it hovers over text. So also static selectable text you can't type in, but it's not an Ibeam when you're actually typing but the cursor is hovering someplace else. Regardless of it's usefulness, this is what you'd have to use:

Code: Select all

#If (A_Cursor!="IBeam")
Left::Send ^+{Tab}
Right::Send ^{Tab}
(if not possible to make it work only if a blinking vertical line for text exists)
I can't think of a way that not incredibly difficult and possibly unreliable.
usser
Posts: 99
Joined: 22 Oct 2014, 13:03

Re: close tab with RCtrl

06 Jun 2015, 12:56

thanks
but how do I combine the two if's?

Code: Select all

#IfWinActive, ahk_class MozillaWindowClass ahk_exe firefox.exe
#If (A_Cursor!="IBeam")
Left::Send ^+{Tab}
Right::Send ^{Tab}
like that?
User avatar
Nextron
Posts: 1378
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: close tab with RCtrl

07 Jun 2015, 04:57

#If (A_Cursor!="IBeam") && WinActive("ahk_class MozillaWindowClass ahk_exe firefox.exe")

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], boiler, c7aesa7r, mikeyww, NexusP, zKade and 34 guests