Click to See Complete Forum and Search --> : How to detect if screensaver is running?
mwdelta
Nov 10th, 1999, 04:28 AM
I am wondering how to detect if the screensaver is running or the system is in standby mode. The program I am developing has a timer that must stop if either of these happens.
Thanks, Mike
mwdelta
Nov 11th, 1999, 07:25 AM
OK, I'll up the ante - whoever can tell me how to do this (and if your solution is implemented) gets a free copy of Workload 2000 when it's released (a $19.95 value!). Workload 2000 helps you keep track of your projects and earnings. Thanks again.
------------------
Mike Wellems
PowerQuery
Compwiz
Nov 11th, 1999, 09:23 AM
This code here works on my Win98 machine and only is a screen saver is running, not Standby. I guess this is not the full answer to your question, but it is a start.
.bas Module Code:
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Function IsSNRunning() As Boolean
If FindWindow("WindowsScreenSaverClass", vbNullString) <> 0 Then
IsSNRunning = True ' Screen Saver Is Running
Else
IsSNRunning = False ' Screen Saver Is Not Running
End If
End Function
Form Code:
Private Sub Timer1_Timer() ' Interval = 1
If IsSNRunning Then
'Screen Saver Is Running
'Do Something Here
End If
End Sub
Hope this helps at least a little bit!
------------------
Tom Young, 14 Year Old
tyoung@stny.rr.com
ICQ: 15743470
AIM: TomY10
PERL, JavaScript and VB Programmer
[This message has been edited by Compwiz (edited 11-11-1999).]
Compwiz
Nov 12th, 1999, 02:46 AM
P.S. Lemme know if this works on a NT machine if you can also.
Yonatan
Nov 12th, 1999, 02:53 AM
This code:
If FindWindow("WindowsScreenSaverClass", vbNullString) <> 0 Then
IsSNRunning = True
Else
IsSNRunning = False
End If
Could be summed up in one line:
IsSNRunning = (FindWindow("WindowsScreenSaverClass", vbNullString) <> 0)
And yes, it works in Windows NT - "WindowsScreenSaverClass" is valid there too.
Other thing: You shouldn't set the Timer's Interval to 1. Use 100 at minimum. VB bug causes the Timer to explode.
------------------
Yonatan
Teenage Programmer
E-Mail: RZvika@netvision.net.il
ICQ: 19552879 (http://www.icq.com/19552879)
mwdelta
Nov 13th, 1999, 12:03 AM
This works great, you guys... Thanks a lot! I will let you know when the program is released and if you want a copy, it's yours. By the way, Compwiz, I am also a young programmer (I'm 17) and I think it's awesome that kids are getting into it earlier. Actually, I have been doing HTML and ColdFusionsince I was about your age, but I just got into Visual Basic recently. I'm curious whether you've developed any complete programs?
Anyway, thanks again!
------------------
Mike Wellems
PowerQuery
Yonatan
Nov 13th, 1999, 12:10 AM
You call that young? (Just kidding)
Tell me if you need any tips for your Workload 2000 program.
------------------
Yonatan
Teenage Programmer
E-Mail: RZvika@netvision.net.il
ICQ: 19552879 (http://www.icq.com/19552879)
Compwiz
Nov 13th, 1999, 12:41 AM
I started programming when I was 8 with batch programmin, then moved to HTML, then to PERL, then to JavaScript, then started my business: http://www.e-bizinternet.com, then started VB. The only program that I've really made that people other than me use is: http://download.cnet.com/downloads/0-10059-100-917104.html?tag=st.dl.10001_103_1.lst.titledetail
Not much of a program, but people seem to like it.
------------------
Tom Young, 14 Year Old
tyoung@stny.rr.com
ICQ: 15743470
AIM: TomY10
PERL, JavaScript and VB Programmer
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.