nikos wrote:GetFocus().GetWindowText()...
That's only half the story dude, for if one clicks a toolbar button to invoke it, or is doing something else, while the pane "looks" active, and is active in our minds, it actually doesn't have the focus, so we need to get a little more creative...
This is the most reliable function I've crafted (using AutoIt, but AHK is the same thing without the formalities) that works under almost any conditions or, shall we say, at least fails the least...
Code: Select all
Global $hWin = WinActivate("[REGEXPCLASS:ATL:(Explorer)|(Scrap)Frame]")
Global Const $ADDRESSBAR = 1001
Global Const $INVOKE_ADDRESSBAR = 33131
Global Const $WM_COMMAND = 0x0111
Func _GetActivePane()
Local $Focus = ControlGetFocus($hWin)
If StringLeft($Focus, 19) = "ATL:BrowserListView" Then Return $Focus
Local $AddressText = ControlGetText($hWin, "", $ADDRESSBAR)
ControlSetText($hWin, "", $ADDRESSBAR, "") ; Applying a null string resets focus to the active-pane (regardless of where focus was originally)...
_SendMessage($hWin, $WM_COMMAND, $INVOKE_ADDRESSBAR)
ControlSetText($hWin, "", $ADDRESSBAR, $AddressText)
Return ControlGetFocus($hWin) ; ...reading that new focus tells us which pane is the active-pane
EndFunc
It gets even goofier if you start taking the context of tab-enumeration into account, and deriving the (implied or actual) opposite pane, never mind the questions about control visibility and window "on-top-ness".
In a floating haze there's "Left pane settings", "Right pane settings", "Scrap view settings", "Scrap view dual settings"...
And then the real work begins, for after our dog has caught the car, what's he going to do with it...? Jaw clamped firmly on the bumper, his little paws start furiously swiping left and right and before you know it he's got a date for the doggy-prom... but that's another paradigm...