I have done this! Once in a while I would take a half Ambien to sleep. A friend of mine emailed me and asked if a given email had come from me. I had no recollection of it, the typing was atrocious, the content was not like me at all, but I looked at my sent emails and it was from me! I was mortified, but glad it was them. lol
Ambien is notorious for this type of side effect.
I once had a 90 yr. old patient who took it every night for 3 months. This lady couldn't walk without her walker...but she would get up in the middle of the night... raid the refrigerator, turn on all the lights and scatter stuff all over the house. She was convinced someone was breaking in until the daughter caught her in the act. Needless to say.... we switched her meds and she was fine after that. :)