LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Keeping excel visible

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/winu...ouse_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...metersinfo.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

--
HTH,

okaizawa


Mike K wrote:
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

"Mike K" wrote:


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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Keeping certain columns/rows visible MichaelPhilips Excel Discussion (Misc queries) 2 January 8th 09 05:40 PM
keeping an auto shape or text box visible in an excel chart bdamin Charts and Charting in Excel 0 September 22nd 08 08:06 PM
Keeping first line visible Ann in Italy Excel Discussion (Misc queries) 4 June 15th 06 11:16 AM
Worksheet has to set to visible as it is not visible after saving and closing Excel by VB. Oscar Excel Programming 6 June 21st 05 10:39 PM
keeping worksheet title visible during scrolling New at excel Excel Worksheet Functions 2 February 16th 05 01:30 AM


All times are GMT +1. The time now is 11:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"