Autohide folder tree by mouse

Edit - Fixed size issues & added delay to the folder tree itself.
Edit - Updated to block being triggered if outside the unmaximized window
This AutoHotkey script I'm working on works for the folder tree + viewer, it will work on all Windows versions that AutoHotkey will run on. :slight_smile:
To use it, just download AutoHotkey at autohotkey.com/
Make a new text file.
Paste the code and save and close it.
Change the extension from .txt to .ahk

  1. Auto show the tree then close once you move outside of it.
  2. Show the viewer if your mouse is in the area for 500MS but it will not close until you move your mouse out of the area and back another 500ms.
#SingleInstance, Force
#Persistent
DetectHiddenWindows, On
#NoTrayIcon
CoordMode, Mouse, Relative
SetTimer, MGP, 50
Return

/*
$ESC:: ;For testing ignore. :P
ToolTip, Closing
Sleep, 1000
ExitApp
*/

MGP: 
DPL = dopus.lister
IfWinActive, ahk_class dopus.lister 
{
        WinGetClass, mC, ahk_id %fID%
        MouseGetPos, fX, fY, fID, fWin
        If(mC < > DPL) {
        Return
    }
    WinGetPos, dX, dY, dW, dH, ahk_classdopus.lister
    Gosub, VT
    ControlGet, CG, Enabled, , SysTreeView321, ahk_classdopus.lister
		If(CG = 1)
{
		ControlGetPos, tX, tY, tW, tH, SysTreeView321, ahk_class dopus.lister
    If(CG = 1 && fX > tW+50) {
        SetTimer, MGP, Off
        Sleep, 100
        SendInput, {F8}
        Sleep, 100
        SetTimer, MGP, On
        Return
    }
}
    If(fX < 8 && fY > 90 && fY < dH - 40) {
        SetTimer, MGP, Off
        Sleep, 375
        MouseGetPos, fX, fY, fID, fWin
        WinGetClass, mCC, ahk_id %fID%
        If(mCC <> DPL) {
        SetTimer, MGP, On
        Return
    }
        MouseGetPos, fX, fY
        Sleep, 125
        If(fX < 8 && fY > 90 && fY < dH - 40) {
        SendInput, {F8}
        }
        MouseGetPos, fX, fY
        Loop, {
            MouseGetPos, fX, fY
            If(fX > 475 && fY > 90) {
                CG = 0
                SetTimer, MGP, On
                Break
            }
            If(fX > 475 && fY < dH - 40) {
                Break
            }
        }
    }
}
Return

VT: 
REV:= dW - 200
IfWinActive, ahk_classdopus.lister 
{
    MouseGetPos, fX, fY, fID, fWin
    ControlGet, CGR, Enabled, , dopus.listerviewpane1, ahk_classdopus.lister
    If(CGR = 1 && fX < REV) {
        SetTimer, MGP, Off
        Sleep, 200
        SetTimer, MGP, On
        Return
    }
    If(fX > dW - 8 && fY > 90 && fY < dH - 40 && fY) {
        SetTimer, MGP, Off
        Sleep, 500
                MouseGetPos, fX, fY, fID, fWin
        WinGetClass, mCC, ahk_id %fID%
        If(mCC <> DPL) {
        SetTimer, MGP, On
        Return
    }
        If(fX > dW - 8 && fY > 90 && fY < dH - 40 && fY) {
            SendInput, {F7}
        }
        MouseGetPos, fX, fY
        Loop, {
            MouseGetPos, fX, fY
            If(fX < REV && fY > 90) {
                SetTimer, MGP, On
                Break
            }

        }
    }
}
Return