This is an open source example that works only with Game Maker 7, 8, 8.1 and Mac versions! It is possible to use it with GM:S, but you cannot select the directory where to save your recording.
All you need to do is import the single object into your project, place it in the room and whenever you want to record just hit "R" (or the key of your choice). Since it is open source, you can modify anything you want! The engine also supports area recording, so you can record a custom area of your game.
The engine supports 9999 recordings of infinite duration (determined by your HDD space) in one folder! More than 9999 and it will start overwriting. It also has the frame modulation option, so you can slow down or speed up the recording real-time.
The output is a directory with ".png" frames of your recording. All you need to do now is merge them into a .gif file or an animation with a program and post previews of your game!