public
class
MonitorOnOff
const
int
HWND_BROADCAST = 65535;
const
int
SC_MONITORPOWER = 61808;
const
short
WM_SYSCOMMAND = 274;
public
void
Main()
string
instr = Interaction.Command();
switch
(Interaction.Command().ToLower)
case
"off"
:
TurnOff();
break
;
case
"on"
:
TurnOn();
break
;
case
"test"
:
TurnOff();
//turn off monitor
System.Threading.Thread.Sleep(10000);
//10 saniye bekle
TurnOn();
break
;
//turn on monitor
default
:
Interaction.MsgBox(
"Kullanım, [on]/[off]/[test] "
, MsgBoxStyle.Information,
"Komut Gerekiyor"
);
break
;
private
Int32 SendMessage(Int32 Handle, Int32 wMsg, Int32 wParam, Int32 lParam)
public
void
StandBy()
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 1);
public
void
TurnOff()
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
public
void
TurnOn()
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, -1);
C# ile monitörü açıp kapatmak
Hiç yorum yok:
Yorum Gönder