[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 787
  • Last Modified:

Wakeup monitor from sleep

Hello

How can I wake up my monitor/screen from sleep mode?

Thanks

Sven
0
Ruttensoft
Asked:
Ruttensoft
1 Solution
 
LordWabbitCommented:
You could try using sendkeys to send a couple key strokes to your application.
0
 
RuttensoftAuthor Commented:
Hm tried that before, doesn't work :-(
0
 
zubin_kharasCommented:
Hi,  Use a timer object to tick every 60000 ms. On each tick, just go me.hide & me.show.
That will cause the WIndows OS to wake up sice a refresh activity will be detected by the OS
Cheers, Zubin
0
 
RuttensoftAuthor Commented:
Thanks, but my application is a DLL, so unfortunately can't use me.hide...
0
 
gregoryyoungCommented:
something like this? I have it in C# here

    class Program
    {
        const int HWND_BRROADCAST = 0xFFFF;
        const uint WM_SYSCOMMAND = 0x0112;
        const int SC_MONITORPOWER = 0xF170;
        [DllImport("user32.dll")]
        public static extern int SendMessage(
            int hWnd, // handle to destination window
            uint Msg, // message
            int wParam, // first message parameter
            int lParam // second message parameter
        );

        static void StandBy()
        {
            SendMessage(HWND_BRROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 1);
        }

        static void TurnOff()
        {
            SendMessage(HWND_BRROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
        }

        static void TurnOn()
        {
            SendMessage(HWND_BRROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, -1);
        }
        static void Main(string[] args)
        {
            TurnOff();
            System.Threading.Thread.Sleep(30000);
            TurnOn();
        }

I have done the effort to convert this to VB.NET for you ..

Imports System.Runtime.InteropServices
Module Module1

    <DllImport("User32.dll")> _
    Private Function SendMessage( _
        ByVal Handle As Int32, _
        ByVal wMsg As Int32, _
        ByVal wParam As Int32, _
        ByVal lParam As Int32) As Int32
    End Function
    Const HWND_BROADCAST As Integer = &HFFFF
    Const SC_MONITORPOWER As Integer = &HF170
    Const WM_SYSCOMMAND As Short = &H112S

    Sub StandBy()
        SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 1)
    End Sub

    Sub TurnOff()
        SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2)
    End Sub
    Sub TurnOn()
        SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, -1)
    End Sub

    Sub Main()
        TurnOff() 'turn off monitor
        System.Threading.Thread.Sleep(10000) 'wait 10 seconds
        TurnOn() 'turn on monitor
    End Sub

End Module

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now