Announcement

Collapse
No announcement yet.

Waking up monitor with SC_MONITORPOWER and windows 8.

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Waking up monitor with SC_MONITORPOWER and windows 8.

    Ever since moving one of my machines to Windows 8 the SC_MONITORPOWER command is not able to wake up the monitor. It works fine when turning it off it will just not wake it up. I searched a bit and found that several people were having the same problem with Windows 8 so I have been looking for a different way of doing it. I found some information on using mouseclicks, but I have found it unreliable. Today I decided to try looking again and I found someone mentioning using mouse movement with MOUSEEVENTF_MOVE, but I'm unable to get it to work. I was hoping that someone with a bit more programing skills would be able to help get this in a format that will with work the script connector.

    The example code they show is:

    [DllImport("user32.dll")]
    static extern void mouse_event(Int32 dwFlags, Int32 dx, Int32 dy, Int32 dwData, UIntPtr dwExtraInfo);

    private const int MOUSEEVENTF_MOVE = 0x0001;

    private void Wake(){
    mouse_event(MOUSEEVENTF_MOVE, 0, 1, 0, UIntPtr.Zero);
    Sleep(40);
    mouse_event(MOUSEEVENTF_MOVE, 0, -1, 0, UIntPtr.Zero);
    }

    And I pulled this from someone talking about it here:

    http://stackoverflow.com/questions/1...ning-windows-8


    Any help would be appreciated.

    Thanks,
    Jeff

    #2
    Not tested, but that should be it.

    wakeup_win8.cs
    #USING System.Runtime.InteropServices

    [DllImport("user32.dll")]
    public static extern void mouse_event(Int32 dwFlags, Int32 dx, Int32 dy, Int32 dwData, UIntPtr dwExtraInfo);

    void Main( object )
    {
    int MOUSEEVENTF_MOVE = 0x0001;

    mouse_event(MOUSEEVENTF_MOVE, 0, 1, 0, UIntPtr.Zero);
    System.Threading.Thread.Sleep( 40 );
    mouse_event(MOUSEEVENTF_MOVE, 0, -1, 0, UIntPtr.Zero);
    }
    Please tell me if it worked.
    Last edited by stipus; January 25, 2013, 04:49 AM.
    --
    stipus

    Comment


      #3
      Thanks Stipus,

      I copied the code from your example into a .cs file and it appears to be working as expected.

      Thanks again,
      Jeff

      Comment

      Working...
      X