tmetcalfe89

Chrome Bookmark expansion script (fixed)

Feb 9th, 2016
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. ;On a 1 second poll
  2. ; If Chrome window is active
  3. ; Get mouse position
  4. ; Get Chrome header area bounds
  5. ; 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
  6. ; Send Chrome bookmark toggle combo
  7. ; End If
  8. ; End If
  9. ;Loop
  10.  
  11. #include <MsgBoxConstants.au3>
  12. #include "AssocArrays.au3"
  13.  
  14. Global $avToggled
  15. AssocArrayCreate($avToggled, 5)
  16. While 1
  17. $hWnd = WinActive("[CLASS:Chrome_WidgetWin_1]")
  18. $aControlPos = ControlGetPos($hWnd, "", "Chrome_RenderWidgetHostHWND1")
  19. If $hWnd And Not @error Then
  20. Local $aMousePos = MouseGetPos()
  21.  
  22. Local $aBoundPos[4]
  23. $aBoundPos[0] = WinGetPos($hWnd)[1]
  24. $aBoundPos[1] = $aBoundPos[0] + (WinGetPos($hWnd)[3] - ControlGetPos($hWnd, "", "Chrome_RenderWidgetHostHWND1")[3])
  25. $aBoundPos[2] = WinGetPos($hWnd)[0]
  26. $aBoundPos[3] = $aBoundPos[2] + WinGetPos($hWnd)[2]
  27.  
  28. If (Not AssocArrayExists($avToggled, $hWnd)) Then
  29. AssocArrayAssign($avToggled, "" & $hWnd, 0) ;Assumes bookmarks are currently not expanded
  30. EndIf
  31.  
  32. If ((IsInside($aMousePos, $aBoundPos) And AssocArrayGet($avToggled, $hWnd) = 0)) Then
  33. Send("^+b")
  34. AssocArrayAssign($avToggled, "" & $hWnd, 1)
  35. EndIf
  36.  
  37. If (Not IsInside($aMousePos, $aBoundPos) And AssocArrayGet($avToggled, $hWnd) = 1) Then
  38. Send("^+b")
  39. AssocArrayAssign($avToggled, "" & $hWnd, 0)
  40. EndIf
  41. EndIf
  42.  
  43. sleep(100)
  44. WEnd
  45.  
  46. Func IsInside(ByRef $vMousePos, ByRef $vBoundPos)
  47. Return ($vMousePos[0] < $vBoundPos[3] And $vMousePos[0] > $vBoundPos[2] And $vMousePos[1] < $vBoundPos[1] And $vMousePos[1] > $vBoundPos[0])
  48. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment