The solution is to run your automation with the system unlocked. Pega Robotics is a tool designed to automate user initiated actions. Should the applications behave differently when locked, they cannot be automated in that state.
Possibly, but that would be done using C#. I would suggest looking in CodeProject or other C# specific forums for C# questions though as you will find more options there. Keep in-mind that while Pega Robotics does not care if your system is locked, your applications may. Since Pega Robotics is designed to automate user-actions as a user would, and since you currently don't have users performing these tasks while there systems are locked, you likely do not know if the applications behave differently. Some applications (like Internet Explorer for example) know when the system is locked and behave differently; often leaving off controls they would normally display.