'BitBlt | StretchBlt - Access is denied when the user is not logged in to Windows

I have a python program that uses simple Windows GDI functions like BitBlt and StretchBlt which runs at computer startup but it starts before the user has logged in at the logon screen and that results in an [Error 5] Access is denied. Is there a way to see when the user has logged in to Windows and then start the program?



Solution 1:[1]

You are using the wrong Registry key. You can't run a GUI program from the Winlogon key, since WinLogon runs outside of any user session.

Use a Run key instead, eg: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run:

Use Run or RunOnce registry keys to make a program run when a user logs on.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Remy Lebeau