Hi all,

I am running a lenghthy loop and I want to PREVENT the screen saver from running during the time the loop is being excecuted.

I can detect when the screen saver kicks off but I can't seem to disable it as soon as that happens.

I have tried many things including SendKeys and Mouse move evnts, setcursorPos ....to emulate an action but without any luck !

this is waht I have so far but the "SPI_SETSCREENSAVERRUNNING" doesn't work !

Code:

VB Code:
  1. Declare Function SystemParametersInfo Lib "user32" Alias _
  2. "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, _
  3. ByRef lpvParam As Long, ByVal fuWinIni As Long) As Long
  4.  
  5. Const SPI_SETSCREENSAVERRUNNING As Long = 97
  6. Const SPI_GETSCREENSAVERRUNNING As Long = &H72
  7.  
  8. Public Sub TEST()
  9.  
  10.     Dim lngIsRunning As Long
  11.    
  12.     Do
  13.         SystemParametersInfo SPI_GETSCREENSAVERRUNNING, vbNull, lngIsRunning, vbNull
  14.         If CBool(lngIsRunning) Then
  15.             'THIS DOESN'T DISABLE SCREEN SAVER !
  16.             SystemParametersInfo SPI_SETSCREENSAVERRUNNING, 0, 0, 0
  17.             Exit Do
  18.         End If
  19.     Loop
  20.     MsgBox "FINISH"
  21.  
  22. End Sub

I have even used different SenMessage commands but nothing disables the screen saver !


FYI, I am using WIN XP.

ANY HELP PLEASE ?

THANK YOU.