Keeping excel visible

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Oh Wise Ones,
Due to circumstances beyond my control I can no
longer view my excel constantly running macro for longer than 5 mins before
my screen saver kicks in. Is there an excel solution to simulate mouse
movement or keystroke events to satisfy windows screensaver so as to not
innitiate? If not, is there a non-excel solution? As I said, I cannot modify
the screensaver settings, all I can do is make it look like I'm doing
something within a 5 min span. Any help would be appriciated.

Thanks,
Mike
 
Have you tried moving your mouse in a corner part of the screen while
the macros are running just to keep the screensaver from kicking in.

Those bloody IT dudes. :rolleyes:
JoJo
 
To clarify, everything is fine if I'm at the computer mousing or keyboarding.
I need something to do these things for me when I'm accross the room or away
from the computer for more than 5 mins. Similar to "keep alive" programs for
dialup connections. A task schedular may work if it can do something every
4m55s, or it may not. I'm not sure what satisfies windows definition of
inactivity to kick in a screensaver.

Mike
 
Hi,

you can use the SystemParametersInfo api to enable or disable the screen
saver, and the mouse_event api to move the mouse pointer.
(but some security settings might prevent your code running)

for example,

mouse_event
http://msdn.microsoft.com/en-us/win...reference/mouseinputfunctions/mouse_event.asp

Public Const MOUSEEVENTF_MOVE = &H1
Declare Sub mouse_event Lib "user32" ( _
ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, _
ByVal cButtons As Long, ByVal dwExtraInfo As Long)


Sub Test_mouse_event()

'your code

mouse_event MOUSEEVENTF_MOVE, 0, 0, 0, 0

'your code

mouse_event MOUSEEVENTF_MOVE, 0, 0, 0, 0

'your code ...

End Sub



SystemParametersInfo
http://msdn.microsoft.com/library/en-us/sysinfo/base/systemparametersinfo.asp

Private Const SPI_GETSCREENSAVEACTIVE = 16
Private Const SPI_SETSCREENSAVEACTIVE = 17
Private Const SPIF_UPDATEINIFILE = &H1
Private Const SPIF_SENDWININICHANGE = &H2

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 IsScreenSaverActive() As Boolean
Dim pvParam As Long
SystemParametersInfo SPI_GETSCREENSAVEACTIVE, 0, pvParam, 0
IsScreenSaverActive = (pvParam <> 0)
End Function

Function EnableScreenSaver(Enable As Boolean) As Boolean
EnableScreenSaver = SystemParametersInfo( _
SPI_SETSCREENSAVEACTIVE, CInt(Enable), ByVal 0&, 0)
End Function


Sub Test_EnableScreenSaver()
Dim isactive As Boolean
isactive = IsScreenSaverActive()
If isactive Then EnableScreenSaver False

'your code

If isactive Then EnableScreenSaver True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top