Results 1 to 8 of 8

Thread: How to detect if screensaver is running?

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 1999
    Location
    Kansas, USA
    Posts
    58

    Post

    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

  2. #2

    Thread Starter
    Member
    Join Date
    Nov 1999
    Location
    Kansas, USA
    Posts
    58

    Post

    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

  3. #3
    Hyperactive Member
    Join Date
    Jul 1999
    Location
    NY, USA
    Posts
    270

    Post

    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:
    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:
    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).]

  4. #4
    Hyperactive Member
    Join Date
    Jul 1999
    Location
    NY, USA
    Posts
    270

    Post

    P.S. Lemme know if this works on a NT machine if you can also.

  5. #5
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Post

    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



  6. #6

    Thread Starter
    Member
    Join Date
    Nov 1999
    Location
    Kansas, USA
    Posts
    58

    Post

    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

  7. #7
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Post

    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



  8. #8
    Hyperactive Member
    Join Date
    Jul 1999
    Location
    NY, USA
    Posts
    270

    Post

    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...st.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

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