You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
933 B

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System;
  9. using System.Net;
  10. using System.Net.Sockets;
  11. using System.Threading;
  12. namespace HKHelper
  13. {
  14. public class TelevisionStart
  15. {
  16. public static bool TurnOn()
  17. {
  18. return SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, -1) != 0;
  19. }
  20. public static bool TurnOff()
  21. {
  22. return SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2) != 0;
  23. }
  24. [DllImport("user32.dll")]
  25. public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
  26. private static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
  27. private const uint WM_SYSCOMMAND = 0x0112;
  28. private const int SC_MONITORPOWER = 0xf170;
  29. }
  30. }