try this addon script; it had to be delayed a bit though or it somehow wouldn't work ..
Code:
local f = CreateFrame("Frame")
f:RegisterEvent("VARIABLES_LOADED")
f:SetScript("OnEvent", function() ChatEdit_SetLastActiveWindow(ChatFrame3EditBox) end)
Where 3 is the Chat Window index, you can find it with[HowTo] Make a code snippet into an addon in twelve easy steps
Edit:
That script only works for the editbox .. not for scrolling up/down actually ><
I also have this example which should work for scrolling too, but for some reason it seems to give errors when used from an addon ..
Code:
FCF_Tab_OnClick(ChatFrame3Tab, "LeftButton")