Results 1 to 4 of 4

Thread: [RESOLVED] Stop screen saver

  1. #1

    Thread Starter
    Hyperactive Member BrianPaul's Avatar
    Join Date
    Aug 2007
    Posts
    294

    Resolved [RESOLVED] Stop screen saver

    I have a program that won't run if the screen saver is active. Is there a way to cause the screen saver to stop? I was thinking of sending a keystroke that would cause the screen saver to stop, but I wasn't sure if there was a better way.

  2. #2

    Thread Starter
    Hyperactive Member BrianPaul's Avatar
    Join Date
    Aug 2007
    Posts
    294

    Re: Stop screen saver

    I found this...

    Code:
    Private Const SPI_SETSCREENSAVEACTIVE = 17
    Private Const SPI_GETSCREENSAVEACTIVE = 16
    Private Const SPIF_SENDWININICHANGE = &H2
    Private Const SPIF_UPDATEINIFILE = &H1
    
    Private Declare Function SystemParametersInfo Lib "user32" Alias _
        "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, _
        ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
    
    Function SetScreenSaverState(ByVal enabled As Boolean) As Boolean
    ' Enable or disable the screen saver
        Dim fuWinIni As Long
        SetScreenSaverState = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, enabled, _
            ByVal 0&, fuWinIni) <> 0
    End Function
    
    Private Sub StopScreenSaver()
       Call SetScreenSaverState(False)
    End Sub

  3. #3
    New Member
    Join Date
    Sep 2005
    Posts
    2

    Re: [RESOLVED] Stop screen saver

    Hi

    I am also looking for a piece of code which deacitivates Screen Saver through VB.

    I tried the given code but it is still not deactivated. Please can anyone help on this ??

  4. #4
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    Re: [RESOLVED] Stop screen saver

    VB.NET MVP 2008 - Present

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