Results 1 to 2 of 2

Thread: [RESOLVED] Trying to recognise computer 'Wake-up'.

  1. #1

    Thread Starter
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,492

    Resolved [RESOLVED] Trying to recognise computer 'Wake-up'.

    Hi, I can't find out why this doesn't work in Windows 11.
    Code:
    '   Trial to try to get a response to waking my laptop from sleep.
    
    Imports Microsoft.Win32
    
    Public Class Form1
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            AddHandler Microsoft.Win32.SystemEvents.PowerModeChanged, AddressOf PMC
        End Sub
    
        Public Sub PMC(ByVal sender As Object, ByVal e As PowerModeChangedEventArgs)
            If e.Mode = PowerModes.Resume Then Label1.BackColor = Color.Lime
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Me.Close()
        End Sub
    
    End Class
    I run this app and close the lid (Sleep mode), leave it for 30 seconds, open the lid (Wake-up) no change of colour.
    I've put a break point at: If e.Mode = (etc.) and tried again, the method hasn't been called.

    A separate question. I've installed Visual Studio 2019 in this new Win.11 laptop, what's happened to the option to print the code in Highlight mode with line numbers ?


    Poppa
    Along with the sunshine there has to be a little rain sometime.

  2. #2

    Thread Starter
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,492

    Re: Trying to recognise computer 'Wake-up'.

    I've finally fixed this problem, I've used a couple of variables to record the time updated every ten seconds, if the time difference of these two is greater than a minute, the computer must've been asleep.

    Poppa
    Along with the sunshine there has to be a little rain sometime.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width