I wanted to write a "flipbook" program, where you could draw a series of frames and create a simple animation. I think this type of program could be fun for kids.
I was about to write the program in Pygame, but found myself re-implementing many of the standard bitmap editing tools. It's easy to make a rectangle and oval tool, but I didn't really feel like making the fill tool or selection tool. So, instead, I used MSPaint as part of the interface to the program. (This is completely a hack, and the resulting program isn't robust, but it was kind of interesting to do). See a video of how to use it - you can move from frame to frame, duplicate the current frame, and play the animation.
I'm trying to make this look like just one program. A lot is going on behind the scenes. The program is a c# app that, first, launches Paint. It has a window style that causes it to be on top of other windows. The program uses many Windows API SendKey calls to send key events to Paint. When you move from one frame to the next, it does the following:
- Tell paint to select all (Ctrl A), and cut (Ctrl X)
- Take that image from the clipboard and save it to a .png file
- Open the next .png file in memory and put it in clipboard
- Tell paint to paste (Ctrl V) and deselect (Esc)
It ended up working. The Win api gives you almost too much to play with. Now I know that c# apps can send simulated keystrokes to other processes, for semi-practical purposes.