Monitor off
1 Attachment(s)
I needed something fast to turn off laptop screen.
I come across this one line command, can use it as a shortcut or a batch file. Tested on a windows 10 laptop work fine so far. Attached contain the shortcut file and also the batch file. Credit to whoever posted online(I forgot where I find it).:p |
For those who are curious about the batch file or the command, here it is:
Code:
cmd /c "powershell.exe -Command "(Add-Type '[DllImport(\"user32.dll\")]public static extern int SendMessage(int hWnd,int hMsg,int wParam,int lParam);' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)"" Here is a short explanation of the code: The SendMessage function is imported from the User32.dll library. The function is called with the following parameter codes 0x0112 and 0xF170,2. They are: WM_SYSCOMMAND (0x0112) which is sending messages to the Windows System Command to the windows application and 0xF170 is the type of System command SC_MONITORPOWER in this case. Code:
SC_MONITORPOWER Code:
hxxps://learn.microsoft.com/en-us/windows/win32/menurc/wm-syscommand |
How to turn it back on?
|
Quote:
|
I suggest to use the asynchronous PostMessage(...) instead of the synchronous SendMessage(...) to avoid waiting forever.....
Code:
cmd /c "powershell.exe -Command "(Add-Type '[DllImport(\"user32.dll\")]public static extern int PostMessage(int hWnd,int hMsg,int wParam,int lParam);' -Name a -Pas)::PostMessage(-1,0x0112,0xF170,2)"" |
All times are GMT +8. The time now is 18:45. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX