Jump to content

Recommended Posts

Posted

This script is designed to be used with a hotkey on a keyboard, or better yet, a mouse. For example, I have a logitech mouse that has a couple of extra buttons on it, one of which is assigned a hotkey that runs this script.

What does the script do? Well, it basically closes something... if you are in a tabbed application, it tries to close the specific tab, otherwise it fires off a "Alt+F4" and closes the application.

I personally find it very useful, thought you might too. It currently is customized to detect Firefox & SciTE tabs only. I borrowed the basic format from an example in the help menu

The default hotkey to run the script is "Ctrl+\"

The default hotkey to pause the script is "Pause"

The default hotkey to close the script is "Win+Esc"

Let me know what you think!

#NoTrayIcon
Opt("WinTitleMatchMode", 4)

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("#{ESC}", "Terminate")
HotKeySet("^\", "Closer")

While 1
    Sleep(100)
WEnd

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Closer is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func Closer()
    Select
        Case WinActive("classname=SciTEWindow")
            $oTitle = WinGetTitle("active")
            Send("^w")
            if WinGetTitle("active") = $oTitle Then
                Send("!{F4}")
            EndIf
        Case WinActive("view-source:") ; case for firefox source viewer
            Send("!{F4}")
        Case WinActive("active")
            $oTitle = WinGetTitle("active")
            If StringInStr($oTitle, "Firefox") Then
                Send("^w")
            Else ; add your own elseif's here!
                Send("!{F4}")
            EndIf
        Case Else
            Send("!{F4}")
    EndSelect
EndFunc
Posted

if it only detects firefox and scite tabs its pretty pointless at the moment...but if you integrate a few other progs/apps, you might have something! : )

it only detects *tabs* in firefox and SciTE, it will close any other application without further configuration... have you tried it?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...