I've written a program that is intended to run in the background, but occasionally has to send keystrokes to itself, thus stealing the focus from whatever window happens to be open.
once my program is finished sending keystrokes to itself, how can I make it return the focus to the program that was previously active

returning the focus to the most recent active window.
tovarish