Results 1 to 2 of 2

Thread: Starting a screensaver

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800

    Post

    I was wondering if I could start the screensaver through code. (better than setting it to one minute!)


    Steve

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    Try this:

    Code:
    Declare Function GetDesktopWindow Lib "user32" () As Long
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    
    Public Const WM_SYSCOMMAND As Long = &H112&
    Public Const SC_SCREENSAVE As Long = &HF140&
    
    Sub Main()
    
    Dim hWnd&
    On Error Resume Next
    hWnd& = GetDesktopWindow()
    Call SendMessage(hWnd&, WM_SYSCOMMAND, SC_SCREENSAVE, 0&)
    End
    
    End Sub
    Paste it to the declarations section of a module. You don't need any forms or any other modules for this to work.

    All the best,

    ------------------
    - Chris
    [email protected]
    If it ain't broke - don't fix it

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