I often have the need to illustrate a little section of coding that would be best achieved by showing an animated gif of how the code is typed. I see these kind of things often enough that I feel there must be tools available to make it easier. Here is such an example: https://github.com/pj3677/vscode-protobuf/raw/master/images/protobufdemo.gif
So the way I've done it (not the above image, that's someone else's) is to do a screen capture after every keypress, paste that image as a new layer in a document in GIMP, crop the entire document with all layers to the section I'm interested in and then export as gif.
As you can imagine, taking a screen grab and pasting it into GIMP after every single key press is tedious work. Also, I have to then manually tweak the timing of each frame to simulate that natural appearance of text being typed by a human.
Surely there must be tools or techniques than can speed up this process. I was thinking for instance that if there is a tool that captures video of the text being typed, then breaks it up into images for each frame, then combines those images into a gif but removing duplicate frames and adjusting the duration of the remaining frame accordingly. So each frame will be unique but they will all have different durations.
Any pointers to software (preferably free and preferably for Windows) would be much appreciated.