|
-
Oct 27th, 2002, 03:59 PM
#1
Thread Starter
Junior Member
Turn off monitor(s)
Hello
Is there a way to click on a button and have your monitor turn off, like when your power settings are set to do so after a certain amount of time? Also, I want to be able to have the monitor come back on, but only after a specific key is pressed, not just on any key press or mouse movement.
Thanks!
Kosta
-
Oct 27th, 2002, 04:11 PM
#2
PowerPoster
Here's the code in visual basic. Now you just have to port it over to vb.net
Code:
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_SYSCOMMAND = &H112
Const SC_MONITORPOWER = &HF170
Private Sub Command1_Click()
' Turn Monitor Off
SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal -1&
End Sub
Private Sub Command2_Click()
' Turn monitor on
SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal 0&
End Sub
-
Oct 27th, 2002, 05:27 PM
#3
Thread Starter
Junior Member
Thanks for the help!
Unfortunately, I'm new to both vb6 and vb.net. Do you have an example already in vb.net?
Thanks again,
Kosta
-
Jan 2nd, 2003, 07:22 PM
#4
Thread Starter
Junior Member
I know this is an old post, but if anyone was interested:
Code:
Private Const WM_SYSCOMMAND = &H112
Private Const SC_MONITORPOWER = &HF170
Private Declare Ansi Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Enum MonitorState
StateOn = -1
StateSuspend = 1
StateOff = 2
End Enum
Private Sub SwitchMonitorState(ByVal State As MonitorState)
SendMessage(Me.Handle.ToInt32(), WM_SYSCOMMAND, SC_MONITORPOWER, State)
End Sub
I just came across it...
Thanks,
Kosta
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|