Add-Type -TypeDefinition @' using System; using System.Runtime.InteropServices; public class Win32 { [DllImport("user32.dll")] public static extern bool PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam); } '@ function Send-KeyPress { $VK_F15 = 0x7E # Virtual-Key Code for the F15 key $WM_KEYDOWN = 0x100 # Message for a non-system key being pressed $WM_KEYUP = 0x101 # Message for a non-system key being released # Send a key down and then key up message to simulate a complete key press [Win32]::PostMessage([IntPtr]::Zero, $WM_KEYDOWN, $VK_F15, 0) [Win32]::PostMessage([IntPtr]::Zero, $WM_KEYUP, $VK_F15, 0) } while ($true) { Send-KeyPress Start-Sleep -Seconds 600 # Wait for 10 minutes before sending the next key press }