Chris,
A quick bit of testing on my system (W2K), shows that printing anything to
debug prevents the ScreenSaver kicking in.
If you halt the code or the code finishes, then the screen saver starts up,
but surely by then it's not a problem.
Screen saver set to 1 min:
Also, the DoEvents seems necssary if the Screen Saver does kick in to allow
you to get rid of it. Maybe try that first.
'Option Explicit
Private Sub CommandButton1_Click()
Dim arr(1 To 1000000) As Variant
Dim starttime As Date
starttime = Now
For j = 1 To 20
For i = 1 To 1000000
'Just some longish calculation
arr(i) = Rnd() * Asc(Mid(Split("ahsd kjhh")(0), 2, 1)) ^ 3.3
Next
Debug.Print Format(Now() - starttime, "ss")
Erase arr
' DoEvents
Next
End Sub
NickHK
wrote in message
ps.com...
Thanks for that Bernie, I suspect that the same group policy will
prevent me from installing anything new on the machine, but I'll give
it a try :)
I was looking up the sendinput API call - any view on whether that
would simulate a mouse movement? It looks like it wouldn't be
interpreted as a hardware movement, so wouldn't stop the screensaver
(and associated password protect) kicking in.
Cheers,
Chris
On Jun 5, 7:11 pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Chris,
They won't let me turn the screensaver off.
"They" are idiots. Since their policy is directly interfering with your
work, take your complaint
up the food-chain until a bigger fish tells them to change it.
In the mean time, I have heard that
http://www.rjlsoftware.com/software/utility/stopss/
will prevent your screensaver from kicking in. Not tested....
HTH,
Bernie
MS Excel MVP
wrote in message
ups.com...
Hi,
I have a rather restricitve group policy set on my machine. I look
after a monte carlo simulation model, written in VBA, which annoying
breaks whenever the screensaver kicks in. They won't let me turn the
screensaver off. I have tried.
I have the following programming tools available:
1. VBA
2. Python compiler
and, er, that's it...
Does anyone know any vba hacks (or at a stretch a python hack) which
could stop my screensaver locking every 15 minutes, breaking my model?
I don't care how it does it - simulate a mouse movement, type a key,
turn the screensaver off... anything - it's becoming desperate!
I found the following in this newsgroup, but not sure it would work
with a group policy screensaver (Don Bardner, original author)...
Private Declare Function SystemParametersInfo Lib "user32" Alias _
"SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long,
_
lpvParam As Any, ByVal fuWinIni As Long) As Long
Sub SetScreenSaver(OnOff As Long)
'From Don Bradner
Dim templong As Long
Const SPI_SETSCREENSAVEACTIVE = 17
Const SPIF_UPDATEINIFILE = 1
Const SPIF_SENDWININICHANGE = 2
templong = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, OnOff,
ByVal
0&, _
SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
End Sub
Sub MySub()
SetScreenSaver 0
'your code here
SetScreenSaver 1
End Sub- Hide quoted text -
- Show quoted text -