How do you turn on and off a monitor from within a Java application?

后端 未结 4 862
长发绾君心
长发绾君心 2020-12-06 03:12

How do you turn on and off a monitor from within a Java application?

In case you\'re wondering why, this is a kiosk style application where it would be great to turn

4条回答
  •  感情败类
    2020-12-06 03:56

    Assuming you deploy your Java Applications on Windows, you can use this WIN32API functions:

    // turn off monitor
    SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 2); 
    
    // turn on monitor
    SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) -1);    
    

    Then you write a little C-JNI wrapper to functions that call the mentioned SendMessage and use the little wrapper to turn off the monitor from Java.

提交回复
热议问题