tmetcalfe89 icon

Chrome Bookmark expansion script (rv3)

tmetcalfe89 | PRO | 02/12/16 11:48:05 PM UTC | 0 ⭐ | 12754 👁️ | Never ⏰ | []
AutoIt |

2.28 KB

|

None

|

0 👍

/

0 👎

;On a 1 second poll
; If Chrome window is active
;  Get mouse position
;  Get Chrome header area bounds
;  If mouse position is in the Chrome header area bounds and bookmarks are expanded or mouse position is not in the Chrome header area bounds and bookmarks aren't expanded
;   Send Chrome bookmark toggle combo
;  End If
; End If
;Loop
 
#include <MsgBoxConstants.au3>
#include "AssocArrays.au3"
 
Global $avTopBarHeight
AssocArrayCreate($avTopBarHeight, 5)
While 1
    $hWnd = WinActive("[CLASS:Chrome_WidgetWin_1]")
    $aControlPos = ControlGetPos($hWnd, "", "Chrome_RenderWidgetHostHWND1")
    If $hWnd And Not @error Then
        Local $aMousePos = MouseGetPos()
 
        Local $aBoundPos[4]
        $aBoundPos[0] = WinGetPos($hWnd)[1]
        $aBoundPos[1] = $aBoundPos[0] + (WinGetPos($hWnd)[3] - ControlGetPos($hWnd, "", "Chrome_RenderWidgetHostHWND1")[3])
        $aBoundPos[2] = WinGetPos($hWnd)[0]
        $aBoundPos[3] = $aBoundPos[2] + WinGetPos($hWnd)[2]
 
        If (Not AssocArrayExists($avTopBarHeight, "" & $hWnd & "." & BitAND(WinGetState($hWnd), 32))) Then
            AssocArrayAssign($avTopBarHeight, "" & $hWnd & "." & BitAND(WinGetState($hWnd), 32), $aBoundPos[1] - $aBoundPos[0]) ;Assumes bookmarks are currently not expanded
        EndIf
 
        If (IsInside($aMousePos, $aBoundPos) And Not IsOpen($aBoundPos, $hWnd)) Then
            Sleep(100)
            Send("^+b")
            Sleep(50)
        EndIf
 
        If (Not IsInside($aMousePos, $aBoundPos) And IsOpen($aBoundPos, $hWnd)) Then
            Sleep(100)
            Send("^+b")
            Sleep(50)
        EndIf
    EndIf
 
    sleep(100)
 WEnd
 
Func IsOpen(ByRef $vBoundPos, ByRef $hWnd)
    Local $iMinTopBarHeight = AssocArrayGet($avTopBarHeight, "" & $hWnd & "." & BitAND(WinGetState($hWnd), 32))
    Local $iCurrentTopBarHeight = $vBoundPos[1] - $vBoundPos[0]
 
    If ($iMinTopBarHeight > $iCurrentTopBarHeight And $iCurrentTopBarHeight > 0) Then
        AssocArrayAssign($avTopBarHeight, "" & $hWnd & "." & BitAND(WinGetState($hWnd), 32), $iCurrentTopBarHeight)
        Return 0
    EndIf
 
    If ($iMinTopBarHeight = $iCurrentTopBarHeight) Then
        Return 0
    EndIf
 
    If ($iMinTopBarHeight < $iCurrentTopBarHeight) Then
        Return 1
    EndIf
EndFunc
 
Func IsInside(ByRef $vMousePos, ByRef $vBoundPos)
    Return ($vMousePos[0] < $vBoundPos[3] And $vMousePos[0] > $vBoundPos[2] And $vMousePos[1] < $vBoundPos[1] And $vMousePos[1] > $vBoundPos[0])
EndFunc

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎