Applescript is not designed to do this - it's an automation system, not a full-fledged programming language.
You are not going to improve upon Keychain for security; certainly not by recording your own keystrokes and storing them in a hidden text file. If you're smart enough to know about keyloggers, you're smart enough to know that makes no sense. Now, if you want to try to steal people's passwords - as seems likely from this post - that makes more sense, and mostly that's between you and your conscience. However, please don't insult us with such a lame back-story. There aren't many people here who haven't seen (and seen through) a few hundred requests of this nature, so the least you can do is put the effort in to make it entertaining for us.
I mean, seriously...
I wasn't very original, let me just try this againxD I expect there to be a huge disaster in 2012 and since my computer is not going to be very safe with all the harbour waves coming in, i need a script that records my keystrokes and sends them on an email to an email adress. My keychain application was also destroyed in a freak accident back in 1996 so there is no way i am able to do this. I also need the script because my grandmother had this ancient mac that i need to reclaim, and if i sent this script and it sends the keystrokes back to me by email i can also savely safe the data from that pc.
To get back to my question, would that be possible with either perl or a cocoa app or something in objective C?
I am sorry i am asking this obvious question but i find it so unsophisticated to state that i would love to obtain the passwords of certain individuals. I ask this question since i found open source vbscript that manages this and i didn't think applescript and vbscript were very differentxD
So if you don't have any password managers such as Keychain, and are relying on remembering or writing down your passwords anyway, then why not use that? Just use keystrokes to put the passwords into a document, no recording necessary.
Freak accident in 1996? Disaster in 2012?
I agree with twtwtw - you are going to have to do better than that - really.
Actually, Red, part of his problem is fixable. He obviously hasn't done any updates since 1996 (otherwise his Keychain app would have been fixed). Running the OS9 combined updater (OS X didn't come out to 2001) ought to fix that problem and put him back into secure functionality.
Further, after the Mayan apocalypse, it's doubtful that the internet will still be up and running, so security concerns will be far lower. Not to mention that there probably won't be an extant power grid on which to charge his laptop (unless he mocks up a person-powered device with an old bicycle and some coconuts). Your 'writing it down' system will probably be better anyway, since he won't have to rely on having power to his box in order to see his passwords. For extra security, he might invest in a metal box with a lock.
See, we volunteers at the ASC are dedicated to providing quality assistance for all user problems!