I have looked on Wowwiki, this site and UI/Macro forum and can't find a solution that works. Wowwiki shows on the "Patch 4.0.1/API changes" page that "Global variables this, event, arg1, ..., are no longer available." The following is the code I was using before the patch:

if not ad_frame then
ad_frame = CreateFrame("Frame", "ad_frame")
end
ad_frame:RegisterEvent("UI_ERROR_MESSAGE")
ad_frame:SetScript("OnEvent", function()
if arg1 == "You are mounted." then
Dismount()
print("|cff24CDB1Auto Dismount dismounted you.")
end
end)