Script's screenshot only captures half the screen when it is locked. What could be the cause?

Hello there! I am encountering a peculiar issue when attempting to capture a screenshot of a locked Windows 11 machine using a script. While the script operates as intended when the machine is unlocked, capturing the entire screen, it only captures half the screen when it is locked. I am seeking assistance in identifying the potential cause of this behavior.

Don’t create duplicate topics, please.