Skip to content

Instantly share code, notes, and snippets.

@yallie
Forked from EugeneLoy/Turn off Screen.bat
Last active July 18, 2024 13:58
Show Gist options
  • Select an option

  • Save yallie/019c5d9e527251e96d8ffff167f2523b to your computer and use it in GitHub Desktop.

Select an option

Save yallie/019c5d9e527251e96d8ffff167f2523b to your computer and use it in GitHub Desktop.

Revisions

  1. yallie revised this gist Apr 1, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Turn off Screen.bat
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    @echo off

    :: see https://www.makeuseof.com/tag/3-quickest-ways-turn-computer-screen-windows/
    :: see https://gist.github.com/EugeneLoy/150044d04b08e35d09e164c864e78da7
    powershell (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)

  2. yallie revised this gist Apr 1, 2023. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion Turn off Screen.bat
    Original file line number Diff line number Diff line change
    @@ -1 +1,7 @@
    powershell (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)
    @echo off

    :: see https://gist.github.com/EugeneLoy/150044d04b08e35d09e164c864e78da7
    powershell (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)

    :: see https://www.pcreview.co.uk/threads/create-a-batch-file-to-lock-computer.3747748/post-12994020
    Rundll32.exe User32.dll,LockWorkStation
  3. @EugeneLoy EugeneLoy revised this gist Oct 20, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Turn off Screen.bat
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    powershell (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)
    powershell (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)
  4. @EugeneLoy EugeneLoy created this gist Apr 1, 2019.
    1 change: 1 addition & 0 deletions Turn off Screen.bat
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    powershell (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)