At work I use two PCs in different offices, so I reach one of them over Remote Desktop. While I work on the local PC, the remote one sits idle, and after five minutes the screen saver kicks in and locks it. Then I type my password again, and again, many times a day. I can’t change the five-minute setting myself.
Short answer: I wrote a small PowerShell tool for the remote PC. While it’s switched on, it presses the Down arrow, then the Up arrow, every 10 seconds, so the PC never looks idle. It has a Start/Stop button, an interval box and a progress bar. The full code is below, feel free to use it.
Check your company’s policy first
A screen lock timeout is usually a security rule, not a mistake. If your company set it, a tool like this works against that rule, and using it could break your IT policy even though it changes no settings. Before you use it at work:
- Check your IT or security policy. If it isn’t clear, ask your IT team
- If the lock gets in your way, the cleanest fix is to ask IT for a longer timeout on that machine
- Use it only on PCs where you’re allowed to, for example your own PC at home
- Never leave an unlocked PC where other people can use it. Lock it yourself (Windows key + L) when you walk away
I can’t take responsibility for any trouble that comes from using this tool.
What the tool does
- While it’s on (Running), it presses Down, waits one second, presses Up, then waits for the interval, over and over
- The default interval is 10 seconds. You can type another number of seconds in the box
- A Start/Stop toggle button switches it on and off, so you don’t have to start and close the script each time
- A progress bar counts down to the next key press

The code
Save it as downup.ps1 on the PC that keeps locking, then right-click it and choose Run with PowerShell. There’s surely room to improve it, but this is what I use.
What to change for your setup:
| What | Where | Default |
|---|---|---|
| Default interval in seconds | $moveInterval = 10 |
10 |
| Keys it presses | SendWait("{DOWN}") and SendWait("{UP}") |
Down, then Up |
| Pause between the two keys | Start-Sleep -Seconds 1 after the Down key |
1 second |
# Load assemblies
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
### Settings ###
# Logger
function logger($msg) {
Write-Host ((Get-Date -Format "yyyy-MM-dd HH:mm:ss") + " " + $msg)
}
# Interval (seconds)
$moveInterval = 10 # Default: every 10 seconds
# Counter
$counter = 0
### Form controls ###
# Form
$OnOffForm = New-Object System.Windows.Forms.Form
$OnOffForm.Size = New-Object System.Drawing.Size(550,250)
$OnOffForm.StartPosition = "CenterScreen"
$OnOffForm.Text = "DownUP"
$OnOffForm.TopLevel = $True
$OnOffForm.MaximizeBox = $False
# Label 1
$label1OnOff = New-Object System.Windows.Forms.Label
$label1OnOff.Location = New-Object System.Drawing.Point(10,10)
$label1OnOff.AutoSize = $true
$label1OnOff.Font = New-Object System.Drawing.Font("Arial", 10)
$label1OnOff.Text = "Start DownUP?"
# Label 2
$label2OnOff = New-Object System.Windows.Forms.Label
$label2OnOff.Location = New-Object System.Drawing.Point(270,50)
$label2OnOff.AutoSize = $true
$label2OnOff.Font = New-Object System.Drawing.Font("Arial", 12)
$label2OnOff.Text = "Stopped"
$label2OnOff.TextAlign = "BottomCenter"
# Start/Stop button
$StartButtonOnOff = New-Object -TypeName System.Windows.Forms.CheckBox
$StartButtonOnOff.location = New-Object System.Drawing.Point(200,50)
$StartButtonOnOff.Autosize = $true
$StartButtonOnOff.Font = New-Object System.Drawing.Font("Arial", 12)
$StartButtonOnOff.Text = "Start"
$StartButtonOnOff.TextAlign = "MiddleCenter"
$StartButtonOnOff.Appearance = "Button"
$StartButtonOnOff.FlatStyle = "System"
# Close button
$CloseButtonOnOff = New-Object System.Windows.Forms.Button
$CloseButtonOnOff.Location = New-Object System.Drawing.Point(215,170)
$CloseButtonOnOff.AutoSize = $true
$CloseButtonOnOff.Font = New-Object System.Drawing.Font("Arial", 10)
$CloseButtonOnOff.Text = "Close tool"
$CloseButtonOnOff.DialogResult = [System.Windows.Forms.DialogResult]::cancel
# Progress bar
$ProgressBar = New-Object System.Windows.Forms.ProgressBar
$ProgressBar.Location = New-Object System.Drawing.Point(10, 130)
$ProgressBar.Size = New-Object System.Drawing.Size(500, 20)
$ProgressBar.Minimum = 0
# Interval text box
$IntervalTextBox = New-Object System.Windows.Forms.TextBox
$IntervalTextBox.Location = New-Object System.Drawing.Point(270, 95)
$IntervalTextBox.Size = New-Object System.Drawing.Size(40, 20)
$IntervalTextBox.Font = New-Object System.Drawing.Font("Arial", 12)
$IntervalTextBox.Text = $moveInterval
# Interval label
$IntervalLabel = New-Object System.Windows.Forms.Label
$IntervalLabel.Location = New-Object System.Drawing.Point(10,100)
$IntervalLabel.AutoSize = $true
$IntervalLabel.Font = New-Object System.Drawing.Font("Arial", 10)
$IntervalLabel.Text = "Interval in seconds:"
# Add the controls to the form
$OnOffForm.Controls.AddRange(@($label1OnOff,$label2OnOff,$StartButtonOnOff,$CloseButtonOnOff,$ProgressBar,$IntervalTextBox,$IntervalLabel))
# Event handler
$StartButtonOnOff.add_CheckedChanged({
if ($StartButtonOnOff.Checked) {
# Check that the interval is a whole number
if ($IntervalTextBox.Text -match '^[0-9]+$') {
$moveInterval = [int]$IntervalTextBox.Text
# Flag to leave the for/while loops
$stopFlag = $false
# Progress bar maximum = interval
$ProgressBar.Maximum = $moveInterval
$StartButtonOnOff.Text = 'Stop'
$label2OnOff.Text = "Running"
$label2OnOff.BackColor = "yellow"
$label2OnOff.Font = New-Object System.Drawing.Font("Arial", 12, [System.Drawing.FontStyle]::Bold)
$label1OnOff.Text = "Stop DownUP?"
# Main loop
while ($StartButtonOnOff.Checked -and !$stopFlag) {
# Let the GUI process its events
[System.Windows.Forms.Application]::DoEvents()
# Was the tool closed?
if (-not $OnOffForm.Visible) {
$stopFlag = $true
break
}
# Was Stop pressed?
if (-not $StartButtonOnOff.Checked) {
$stopFlag = $true
break
}
# Loop counter
$counter++
logger "Count: $counter"
# Press the Down arrow key
[System.Windows.Forms.SendKeys]::SendWait("{DOWN}")
# Short pause between Down and Up so the cursor ends where it started
Start-Sleep -Seconds 1
# Press the Up arrow key
[System.Windows.Forms.SendKeys]::SendWait("{UP}")
for ($i = 0; $i -lt $moveInterval; $i++) {
# Let the GUI process its events
[System.Windows.Forms.Application]::DoEvents()
# Was the tool closed?
if (-not $OnOffForm.Visible) {
$stopFlag = $true
break
}
# Was Stop pressed?
if (-not $StartButtonOnOff.Checked) {
$stopFlag = $true
break
}
if($i -eq 0){
$ProgressBar.Value = $ProgressBar.Maximum
}
Start-Sleep -Seconds 1
# Update the progress bar (interval minus elapsed seconds)
$ProgressBar.Value = $moveInterval - $i - 1
}
}
} else {
# Show an error when the interval is not a whole number
[System.Windows.Forms.MessageBox]::Show("Enter the interval as a whole number of seconds.", "Error", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error)
# Turn the Start button back off
$StartButtonOnOff.Checked = $false
}
} else {
$StartButtonOnOff.Text = 'Start'
$label2OnOff.Text = "Stopped"
$label2OnOff.ResetBackColor()
$label2OnOff.Font = New-Object System.Drawing.Font("Arial", 12)
$label1OnOff.Text = "Start DownUP?"
}
})
# Event handler
$CloseButtonOnOff.add_Click({
$OnOffForm.Close()
$OnOffForm.Dispose()
})
# Show the form
[Windows.Forms.Application]::Run($OnOffForm)
I ran this English version on Windows 11 with Windows PowerShell 5.1: Start, Stop, a bad interval and Close tool all worked.
How it works
The interval and the counter
$moveInterval = 10 is the default interval in seconds. $counter counts the loops and prints Count: 1, Count: 2 and so on to the console. The tool doesn’t need it, but it’s handy if you reuse the loop for something else, like a regular connection check.
The Start/Stop button
The Start button is really a check box drawn as a button (Appearance = "Button"). When it’s checked, the label turns to Running on a yellow background and the loop starts. When you press it again, the label goes back to Stopped.

The key presses
[System.Windows.Forms.SendKeys]::SendWait("{DOWN}") sends the Down arrow key, the same as pressing it yourself. One second later {UP} sends the Up arrow, so the cursor ends up where it started.
One thing to know: SendKeys sends the key to whichever window is in front. If a spreadsheet is in front, the selected cell moves down and back up. If something reacts badly to arrow keys, click the DownUP window first so the keys land there.
Stopping in the middle of an interval
The loop calls [System.Windows.Forms.Application]::DoEvents() every second. Without it, the window ignores clicks until the whole interval has passed, so Stop and Close tool feel frozen. The loop also checks whether you pressed Stop or closed the window, and leaves right away.
Checking the interval box
if ($IntervalTextBox.Text -match '^[0-9]+$') accepts whole numbers only. If you type something else and press Start, an error box asks for a whole number of seconds, and the button goes back to Start.
Notes
- You need an environment where PowerShell scripts are allowed to run. If your company blocks scripts, that’s another sign to ask IT first
- Run the tool on the remote PC itself, not on the PC you connect from
- The PowerShell console stays open behind the window and prints the count. Closing that console also closes the tool
Summary
This tool presses Down and Up on a timer so an idle Remote Desktop PC doesn’t hit the screen lock. It’s about 190 lines of PowerShell with a simple on/off window. But a lock timeout is usually there on purpose, so check your policy first, and when in doubt ask IT for a longer timeout.
Revision history
2024/02/22 First version
2026/11/23 English version


Comments