Skip to content

Releases: virtualox/StayActive.ps1

StayActive v4.0.0

Choose a tag to compare

@virtualox virtualox released this 23 May 10:52
8c46f16

Changelog

[4.0.0] - 2026-05-23

Added

  • KeepAwake Mode: New -KeepAwake / -KeepDisplay parameters call SetThreadExecutionState so Windows itself keeps the system (and optionally the display) awake. Ideal for presentations, long downloads, and remote sessions. The execution-state flag is cleared on exit.
  • Idle Guard for Nudge Mode: New -OnlyWhenIdle and -IdleSeconds parameters use GetLastInputInfo to skip a cycle if the user has been active recently, so the cursor no longer jumps while you are typing or clicking.
  • INPUTS / OUTPUTS / LINK Help Sections: Comment-based help now documents the lack of pipeline support and links to the GitHub repo, so Get-Help .\StayActive.ps1 -Online works.

Changed

  • Modern Win32 Input API: Mouse input migrated from the superseded mouse_event to SendInput. Signed dx/dy removes the uint two's-complement workaround that the old code needed to express negative motion.
  • Output Streams: Status output now uses Write-Information (the Information stream) and Write-Progress instead of Write-Host, so output can be redirected, suppressed, or captured like any other PowerShell stream.
  • Help System: Replaced the custom -Help switch with comment-based help; use Get-Help .\StayActive.ps1 -Full instead.
  • Synopsis: Tightened to a single sentence in the conventional third-person present tense, matching built-in cmdlet style.

Improved

  • Idempotent Interop: Add-Type is now guarded so re-running the script in the same PowerShell session no longer fails on duplicate CLR types. Native types live in their own StayActive namespace to avoid global collisions.
  • Native Error Surfacing: GetCursorPos and GetLastInputInfo return values are checked and any Win32 error is surfaced via GetLastWin32Error instead of silently returning a zeroed POINT.
  • Cleaner Verbose Detection: -Verbose is now detected via $PSBoundParameters.ContainsKey('Verbose'), so a globally set $VerbosePreference no longer triggers the script's per-cycle countdown unintentionally.
  • Verbose Countdown: Now uses Write-Progress with -SecondsRemaining instead of writing a line per second.

Security

  • Code Signing: Script is digitally signed with Extended Validation (EV) Code Signing Certificate.
  • Constrained Language Mode Detection: Script exits early with an actionable message if PowerShell is running under AppLocker / WDAC ConstrainedLanguage mode, instead of failing partway through with a confusing Add-Type error.
  • Platform Guard: On PowerShell 7, the script checks $IsWindows and exits with a pointer to caffeinate (macOS) or systemd-inhibit (Linux) instead of crashing on user32.dll.

Breaking Changes

  • -Help Removed: Use Get-Help .\StayActive.ps1 -Full or -Online instead. Anyone scripting .\StayActive.ps1 -Help needs to update.
  • Output Streams: Status no longer goes to the host directly via Write-Host. Scripts that captured stdout will need to use -InformationAction Continue or the 6> redirection operator.
  • Parameter Sets: -MoveInterval, -SmallMove, -OnlyWhenIdle, -IdleSeconds belong to the Nudge set; -KeepAwake, -KeepDisplay belong to the KeepAwake set. Mixing them produces a parameter-set error.

Migration Guide

From v3.1.0 to v4.0.0:

  • Replace .\StayActive.ps1 -Help with Get-Help .\StayActive.ps1 -Full
  • If you piped or redirected the script's output, switch from stdout capture to 6> (Information stream) or pass -InformationAction SilentlyContinue to mute it
  • For "keep the machine awake" use cases (presentations, downloads), prefer the new -KeepAwake over the default Nudge mode
  • For "stay marked active in Teams" use cases, keep using the default (Nudge), and consider adding -OnlyWhenIdle so the cursor only moves when you have actually walked away

Notes

  • Nudge mode (the original behaviour) remains the default; passing no parameters works exactly as before
  • KeepAwake is a power-management hint and will not keep Teams or similar presence-aware apps from marking you away — use Nudge for that
  • Requires FullLanguage mode; the script exits with a clear message under Constrained Language Mode
  • Tested on Windows PowerShell 5.1 and PowerShell 7+

StayActive v3.1.0

Choose a tag to compare

@virtualox virtualox released this 23 Mar 09:34

Changelog

[3.1.0] - 2026-03-23

Improved

  • Native Parameter Validation: Replaced manual if-checks with PowerShell's built-in [ValidateRange()] attributes for cleaner, more idiomatic validation
  • Version Enforcement: Added #Requires -Version 5.1 directive for clear error messaging on unsupported PowerShell versions

Security

  • Code Signing: Script is digitally signed with Extended Validation (EV) Code Signing Certificate

StayActive

Choose a tag to compare

@virtualox virtualox released this 28 May 08:11
44ea19c

Changelog

[3.0.0] - 2025-05-28

Added

  • Professional Command-Line Interface: Full parameter support with [CmdletBinding()] for PowerShell best practices
  • Built-in Help System: Comprehensive -Help parameter with detailed usage examples and syntax
  • Progress Indicators: Real-time progress display showing movement count, runtime, and next movement timing
  • Enhanced Verbose Logging: Timestamped detailed logging using PowerShell's native Write-Verbose
  • Parameter Validation: Input validation for all parameters with helpful error messages
  • Mouse Position Tracking: Advanced cursor position monitoring for detailed logging
  • Runtime Statistics: Comprehensive summary showing total runtime, movements, and average intervals
  • Professional Output Formatting: Color-coded startup banners and termination summaries
  • Graceful Error Handling: Proper exception handling with detailed error reporting
  • Configurable Movement Distance: Adjustable pixel movement (1-10 pixels) with validation

Changed

  • Major Architecture Overhaul: Complete rewrite from simple loop to professional PowerShell cmdlet
  • Default Interval: Increased from 1 second to 60 seconds for more realistic usage patterns
  • Logging System: Replaced custom logging with PowerShell's standard Write-Verbose functionality
  • Parameter Structure: Moved from hardcoded values to full command-line parameter support
  • Output Format: Enhanced from minimal output to comprehensive user feedback
  • Error Handling: Upgraded from basic try-catch to comprehensive exception management

Enhanced

  • Code Quality: Implemented PowerShell best practices and proper cmdlet structure
  • User Experience: Added professional startup/shutdown sequences with detailed information
  • Monitoring Capabilities: Extensive logging and progress tracking for production environments
  • Customization Options: Multiple parameters for different use cases and environments
  • Documentation: Comprehensive inline help and parameter descriptions

Security

  • Code Signing: Script is digitally signed with Extended Validation (EV) Code Signing Certificate
  • Parameter Validation: Input sanitization and bounds checking to prevent misuse
  • Execution Policy: Proper PowerShell execution policy handling and guidance

Technical Improvements

  • Windows API Integration: Enhanced API calls with proper error handling
  • Memory Management: Improved resource usage and cleanup procedures
  • Performance Optimization: Efficient timing and movement algorithms
  • Compatibility: Tested with PowerShell 5.1 and PowerShell Core 6.0+

Usage Examples

# Basic usage with default settings
.\StayActive.ps1

# Show progress indicators
.\StayActive.ps1 -ShowProgress

# Custom interval with verbose logging
.\StayActive.ps1 -MoveInterval 30 -Verbose

# Full features for monitoring
.\StayActive.ps1 -MoveInterval 45 -SmallMove 2 -ShowProgress -Verbose

# Display help information
.\StayActive.ps1 -Help

Breaking Changes

  • Parameter Names: All configuration now requires explicit parameters instead of editing script variables
  • Output Format: Completely redesigned output may affect automated parsing
  • Timing: Default interval changed from 1 second to 60 seconds
  • Execution: Requires PowerShell parameter syntax instead of direct execution

Migration Guide

From v1.0.0 to v3.0.0:

  • Replace direct script execution with parameter-based usage
  • Update any automation scripts to use new parameter names
  • Adjust timing expectations due to new default 60-second interval
  • Review verbose output if used for monitoring or logging

Notes

  • The script maintains backward compatibility for basic mouse movement functionality
  • All new features are optional and don't affect core functionality when using defaults
  • Enhanced security through code signing and parameter validation
  • Comprehensive documentation available via -Help parameter

StayActive

Choose a tag to compare

@virtualox virtualox released this 18 Oct 21:16
1fd82f8

[1.0.0] - 2023-10-18

Added

  • Initial release of the StayActive PowerShell script that simulates mouse movements to prevent system sleep or screen locking.

Notes

  • The script was signed with an Extended Validation (EV) Code Signing Certificate to enhance security and trust.