but the thing i am asking is about locked user session not for user who is logged off..
That's the same thing as the 3rd scenario that I listed. In that scenario, all running programs (including GUI-based applications) will continue to run. However, Windows does away with the GUI environment until the user logs back in. With no GUI environment, there is no way (as far as I can tell) to automate interactions with a GUI-based application.
This is something that drove me crazy when I ran into it a few years ago. I ran out of time with what I was working on, so I just accepted that this was a limitation that I had to live with.
marto does have a good point. I had not thought of the situation from that perspective, but it does make sense when I look at it from that view point.