An old problem, maybe (?) resolved for older Windows version, but not for Windows 10!
The solutions proposed in old discussions (... SetSuspendState with parameters 0,1,0 (or Sleep), with or without prior hibernate off ...) dont work on Windows 10 systems; at least not on all: the initiated mode is mostly hibernate, not sleep.
What I found out: In older Windows versions there was something like this in the Registry: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\sleep\command] @="rundll32.exe powrprof.dll,SetSuspendState Sleep" This obviously was the sleep command. At least on my Windows 10 PCs there is no such entry!
Somebody here with new answers?
================== EDITED: After this my OP I discovered that this is not a Windows 10 issue, it is a Surface 3 issue, related to the power option used on Surface 3 as Sleep mode:
The Sleep mode used by Surface 3 seems to be "Modern Standby" = "S0 Low Power Idle" = "Connected Network Standby". (Not the usual S3 Sleep mode!!!)
The commands using SetSuspendState seems to be unable at all to initiate the Sleep mode on a Surface 3.
A new wording for my question: All what I would like to have is a command which does the same as the Power button on a Surface 3 which is set to "power-button action = Sleep", or as the Sleep button on an external (USB) keyboard when Surface 3 is set to "sleep-button action = Sleep".
I haven't found a satisfactory answer to this question on the internet, my current solution is simulating key pressing.
In Python, I use the
pyautogui
module. Here's my codes: