Return result of last brush stroke?

I was wondering if it’s possible in scripts to specifically get the result(pixels) of only your last brush stroke, and perform further actions on it. I want to extend functionality for the contour tool (or make a similar tool) where it automatically applies a stroke outline when you draw something (and it would be even better if it could also anti-alias the result with a color of your choice, but I don’t know how to code that).

Pictures because images make this a lot easier to explain:

So the whole idea is that all of this would be the result of a single mouse click and drag.