Search notes:

simulate-activity.ps1

The following PowerShell script moves the cursor one position to the left and then one to the right, every minute.
This script might be useful to prevent locking the display or from being logged out on remote sessions after a certain amount of inactivity: the script (hopefully) fools Windows into thinking that something is happening.
$sh = new-object -com "Wscript.Shell"

#
# loop indefinitely, stop with ctrl-c.
#
while ($true) {

 #
 # Sleep for a minute.
 #
   start-sleep -seconds 60

 #
 # Move cursor one to the left and one to
 # the right.
 #
   $sh.sendkeys("{LEFT}" )
   $sh.sendkeys("{RIGHT}")
}
Github repository scripts-and-utilities, path: /simulate-activity.ps1

See also

The VBA statement sendkeys
Other Scripts

Index