From: Mayank Singh 2023 - Professional Profile[^]
FYI: This I get from ChatGPT if I ask it:
'How to make an exe file in C# that locks the screen and starts screensaver immediately?'
Quote:This code imports the LockWorkStation and SendMessage functions from the Windows API, which are used to lock the workstation and start the screensaver, respectively. The LockWorkStation function locks the workstation immediately, while the SendMessage function sends a message to Windows to start the screensaver.
To create an executable file from this code, follow these steps:
Open Visual Studio and create a new C# console application.
Copy the above code and paste it into the Program.cs file in your project.
Build the project by selecting Build > Build Solution from the menu.
Navigate to the bin/Debug folder in your project directory.
Find the .exe file with the same name as your project, and copy it to a convenient location.
Now, when you run the executable file, it will lock the screen and start the screensaver immediately. Note that this code is specific to Windows and may not work on other operating systems.
modified 6-Apr-23 7:36am.