1

I have a scheduled task that wakes up the computer to run a batch file. However the computer turns back off after some time. I have my computer set to (never sleep) so after waking up from the task it should stay on.

However after doing some reading I found out this was because the computer did not wake up from user input.

What I am looking for is a simple script (batch or vb file maybe) I can run via task scheduler that will simulate user input. Maybe hitting the space bar once or moving the mouse.

Running windows 8.1

I tried the following .vbs script without success

Set WshShell = Wscript.CreateObject("Wscript.Shell") 
WshShell.SendKeys("+{F10}")
hollopost
  • 569
  • 9
  • 28
  • 1
    Windows as a API call that programs like Media Player use to mark a thread as requiring the system on or system and display on. SetThreadExecutionState would be the correct way to do this. You have C# and VB compilers on all windows versions. See https://msdn.microsoft.com/en-us/library/windows/desktop/aa373208%28v=vs.85%29.aspx. The idle timer, according to that page detects, focus changes so `wshshell.appactivate` between two windows may help. –  Jun 15 '16 at 23:31

2 Answers2

1

You can try this application: http://mousejiggler.codeplex.com/

It'll simulate mouse movement to keep your computer awake.

If you really want a script try this: https://gallery.technet.microsoft.com/scriptcenter/Keep-Alive-Simulates-a-key-9b05f980

LeoLiu
  • 87
  • 5
  • Would like to do it without third party software if possible. – user3093979 Feb 25 '15 at 19:22
  • The script you provided is a little to complex for what Im looking for. I do not need the script to press a key every set amount of minutes. I just need the script to press a key once or twice or more the mouse. Just to simulate user input. – user3093979 Feb 25 '15 at 19:34
0

You can simulate the [F5] key to refresh windows every 2 minutes like this :

Option Explicit
Dim Ws
set Ws = createobject("Wscript.Shell")
Do
    Ws.Sendkeys "{F5}"
    Call Pause(2)'To sleep for 2 minutes
Loop
'***************************************
Sub Pause(min)
    Wscript.Sleep(min*1000*60)
End sub
'***************************************
Hackoo
  • 18,337
  • 3
  • 40
  • 70