Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Keeping certain columns/rows visible | Excel Discussion (Misc queries) | |||
keeping an auto shape or text box visible in an excel chart | Charts and Charting in Excel | |||
Keeping first line visible | Excel Discussion (Misc queries) | |||
Worksheet has to set to visible as it is not visible after saving and closing Excel by VB. | Excel Programming | |||
keeping worksheet title visible during scrolling | Excel Worksheet Functions |