-
Feb 2nd, 2025, 07:44 PM
#1
Thread Starter
PowerPoster
[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.
-
Feb 21st, 2025, 03:36 AM
#2
Thread Starter
PowerPoster
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|