Batch Script to Refresh screen?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
burnleylad_84
Posts: 4
Joined: 22 Oct 2009 06:51

Batch Script to Refresh screen?

#1 Post by burnleylad_84 » 06 May 2010 08:58

Is it possible to make a Batch Script that remains open but minimised that will either automate F5 to refresh my screen or will move my mouse or something every 2.5 minutes using the ping command, this is to avoid my work computer locking after 5 minutes of idle time.

Thanks,

jeb
Expert
Posts: 1055
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: Batch Script to Refresh screen?

#2 Post by jeb » 06 May 2010 10:23

Hi burnleylad_84,

I assume that it is not possible with pure dos.

But I know how to solve it with C#, it's a simple api call.
Perhaps you can call it from vbscript also ( I don't use vbs at all ).

Code: Select all

    public static class SleepPreventer
    {
        [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        static extern EXECUTION_STATE SetThreadExecutionState(
            EXECUTION_STATE flags);

        [Flags]
        public enum EXECUTION_STATE : uint
        {
            ES_SYSTEM_REQUIRED = 0x00000001,
            ES_DISPLAY_REQUIRED = 0x00000002,
            // ES_USER_PRESENT = 0x00000004,
            ES_CONTINUOUS = 0x80000000
        }

        static public void ResetIdleTimer()
        {
            SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED);
        }
    }


jeb

burnleylad_84
Posts: 4
Joined: 22 Oct 2009 06:51

Re: Batch Script to Refresh screen?

#3 Post by burnleylad_84 » 06 May 2010 11:28

I think you can invoke F5 (Refresh Key) in Batch and then use ping to set up on an interval and just use echo to loop so its continual and does not close.

I know c++ but thought of something more simple as its for work.

jeb
Expert
Posts: 1055
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: Batch Script to Refresh screen?

#4 Post by jeb » 06 May 2010 11:44

You are right, you can invoke the key, but (I suppose) it doesn't help,
because it will not reset the windows idle timer.

But perhaps you can use the shutdown to reset the timer

Something like
shutdown /...
and then cancel it with
shutdown /a

burnleylad_84
Posts: 4
Joined: 22 Oct 2009 06:51

Re: Batch Script to Refresh screen?

#5 Post by burnleylad_84 » 06 May 2010 12:03

I'll do a small app then in c++ and hook the mouse onto an area of the screen and move the cursor every 2.5 minutes or something, should be pretty straight forward.

thx

jeb
Expert
Posts: 1055
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: Batch Script to Refresh screen?

#6 Post by jeb » 06 May 2010 13:01

Hmm I doesn't understand why you will solve it that way?

If you write a c++ programm which only calls the api

Code: Select all

#define ES_SYSTEM_REQUIRED 1UL
void main()
{
SetThreadExecutionState(ES_SYSTEM_REQUIRED);
}


you can start that program with your ping method

Post Reply