noboffinme
Registered User.
- Local time
- Tomorrow, 00:15
- Joined
- Nov 28, 2007
- Messages
- 288
Hi
I am using an extra PC & want the PC to stay awake while it runs a query.
I thought I'd get the computer to hit the keyboard letter 'A' after 5 minutes to make sure it doesn't go turning off the monitor using the 'Sendkeys' method.
So I've got a repeating timer procedure but I'm unsure whether this is the right approach.
The result is that I get the timer to add the 'A' letter only once when really I need it to repeat this action every 5 minutes to keep the PC 'awake' so it's similar to me hitting the letter 'A' every 5 mins.
Any suggests?
-------------------------------------------
Option Explicit
Public RunWhen As Double
Public Const cRunIntervalSeconds = 300 ' five minutes
Public Const cRunWhat = "TheSub" ' the name of the procedure to run
-------------------------------
Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
Schedule:=True
End Sub
---------------------------
Sub TheSub()
Application.SendKeys "{A}"
StartTimer ' Reschedule the procedure
End Sub
---------------------------
I am using an extra PC & want the PC to stay awake while it runs a query.
I thought I'd get the computer to hit the keyboard letter 'A' after 5 minutes to make sure it doesn't go turning off the monitor using the 'Sendkeys' method.
So I've got a repeating timer procedure but I'm unsure whether this is the right approach.
The result is that I get the timer to add the 'A' letter only once when really I need it to repeat this action every 5 minutes to keep the PC 'awake' so it's similar to me hitting the letter 'A' every 5 mins.
Any suggests?
-------------------------------------------
Option Explicit
Public RunWhen As Double
Public Const cRunIntervalSeconds = 300 ' five minutes
Public Const cRunWhat = "TheSub" ' the name of the procedure to run
-------------------------------
Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
Schedule:=True
End Sub
---------------------------
Sub TheSub()
Application.SendKeys "{A}"
StartTimer ' Reschedule the procedure
End Sub
---------------------------