For CharcterFrame you can simply do:
Code:
hooksecurefunc(CharcterFrame, "Show", function() print("Showing CharcterFrame") end)
hooksecurefunc(CharcterFrame, "Hide", function() print("Hiding CharcterFrame") end)
But for PlayerTalentFrame (and others like ArchaeologyFrame, InspectFrame, AuctionHouseFrame, ClassTrainerFrame) it is a bit more complicated, because these frames do not exist yet after login. You have to wait with your hook until after they are created, and that is what these events you are mentioning can be helpful for. So for PlayerTalentFrame you could do:
Code:
local playerTalentFrameHooked = false
local addonLoadedFrame = CreateFrame("Frame")
addonLoadedFrame:RegisterEvent("ADDON_LOADED")
addonLoadedFrame:SetScript("OnEvent", function(self, event, arg1, ...)
if not playerTalentFrameHooked and arg1 == "Blizzard_TalentUI" then
hooksecurefunc(PlayerTalentFrame, "Show", function() print("Showing PlayerTalentFrame") end)
hooksecurefunc(PlayerTalentFrame, "Hide", function() print("Hiding PlayerTalentFrame") end)
playerTalentFrameHooked = true
end
end)