Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;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 $avToggled
- AssocArrayCreate($avToggled, 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($avToggled, $hWnd)) Then
- AssocArrayAssign($avToggled, "" & $hWnd, 0) ;Assumes bookmarks are currently not expanded
- EndIf
- If ((IsInside($aMousePos, $aBoundPos) And AssocArrayGet($avToggled, $hWnd) = 0)) Then
- Send("^+b")
- AssocArrayAssign($avToggled, "" & $hWnd, 1)
- EndIf
- If (Not IsInside($aMousePos, $aBoundPos) And AssocArrayGet($avToggled, $hWnd) = 1) Then
- Send("^+b")
- AssocArrayAssign($avToggled, "" & $hWnd, 0)
- EndIf
- EndIf
- sleep(100)
- WEnd
- 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
Advertisement
Add Comment
Please, Sign In to add comment