tmplinshi wrote:That explains everything. This script only works on a solid background theme. The last code tested on firefox v62.0.2 (theme: Default/Light/Dark).
Here it is working with the
Firefox Quantum Nightly theme. It uses a different color along the top of the tab.
Code: Select all
F1::FF_PinUnpin()
; Tested on FireFox v62.0.2 (Theme: Default/Light/Dark), Windows 10
FF_PinUnpin() {
FF_PinUnpin.DoIt()
}
class FF_PinUnpin
{
DoIt() {
TabList := this.FindTabList()
TabPos := this.FindActiveTabPos(TabList)
ControlClick, % "x" TabPos.x+TabPos.w//2 " y" TabPos.y+4, % "ahk_class MozillaWindowClass",, RIGHT,, NA
WinWait, % "ahk_class MozillaDropShadowWindowClass"
ControlSend,, % (TabPos.w < 50) ? "b" : "p"
; Fix tab redraw problem.
PostMessage, WM_MOUSEMOVE := 0x200, 0, 0,, % "ahk_class MozillaWindowClass"
}
FindTabList(WinTitle := "ahk_class MozillaWindowClass") {
if !WinExist(WinTitle)
throw WinTitle " does not exist."
acc := Acc_ObjectFromWindow( WinExist() )
for i, child in Acc_Children(acc)
{
if ( child.accRole(0) = 0x00000016 ) ; ROLE_SYSTEM_TOOLBAR
{
o := Acc_Children(child)
if ( o.1.accRole(0) = 0x0000003C ) ; ROLE_SYSTEM_PAGETABLIST
return o.1
}
}
throw "Couldn't find TabList object"
}
FindActiveTabPos(oTabList) {
if (oTabList.accChildCount = 2)
pos := success := Acc_Location( Acc_Children(oTabList).1 )
else
{
PreMode := A_CoordModePixel
CoordMode, Pixel, Screen
for i, child in Acc_Children(oTabList)
{
pos := Acc_Location(child)
PixelGetColor, color, pos.x+pos.w//2, pos.y+1
if (color = 0xFFFE00)
{
success := true
Break
}
}
CoordMode, Pixel, %PreMode%
}
if success {
WinGetPos, winX, winY,,, % "ahk_class MozillaWindowClass"
return pos, pos.x -= winX, pos.y -= winY
}
throw "Unable to find active tab."
}
}