I suggest you have a try the code showed in the link you mentioned. I test on Window 10 with Python 3.6, it works perfectly.
Before you run the code you may need to install two modules like this:
pip install pypiwin32
pip install comtypes
After that open the Python code file via Python IDE and select Run module from the menu bar.
You will get the following output:
*** STARTING ***
hwnd: 67998
registering GUID_MONITOR_POWER_ON
result: -0x5438e940
lastError: 0
registering GUID_SYSTEM_AWAYMODE
result: -0x5438e780
lastError: 0
registering GUID_CONSOLE_DISPLAY_STATE
result: -0x5438ea20
lastError: 0
registering GUID_ACDC_POWER_SOURCE
result: -0x5438eb00
lastError: 0
registering GUID_BATTERY_PERCENTAGE_REMAINING
result: -0x5438e6a0
lastError: 0
Entering loop
Power setting changed...
Monitor on
Power setting changed...
Display on
Power setting changed...
AC power