Releases: virtualox/StayActive.ps1
Releases · virtualox/StayActive.ps1
Release list
StayActive v4.0.0
Changelog
[4.0.0] - 2026-05-23
Added
- KeepAwake Mode: New
-KeepAwake/-KeepDisplayparameters callSetThreadExecutionStateso 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
-OnlyWhenIdleand-IdleSecondsparameters useGetLastInputInfoto 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 -Onlineworks.
Changed
- Modern Win32 Input API: Mouse input migrated from the superseded
mouse_eventtoSendInput. Signeddx/dyremoves theuinttwo's-complement workaround that the old code needed to express negative motion. - Output Streams: Status output now uses
Write-Information(the Information stream) andWrite-Progressinstead ofWrite-Host, so output can be redirected, suppressed, or captured like any other PowerShell stream. - Help System: Replaced the custom
-Helpswitch with comment-based help; useGet-Help .\StayActive.ps1 -Fullinstead. - Synopsis: Tightened to a single sentence in the conventional third-person present tense, matching built-in cmdlet style.
Improved
- Idempotent Interop:
Add-Typeis now guarded so re-running the script in the same PowerShell session no longer fails on duplicate CLR types. Native types live in their ownStayActivenamespace to avoid global collisions. - Native Error Surfacing:
GetCursorPosandGetLastInputInforeturn values are checked and any Win32 error is surfaced viaGetLastWin32Errorinstead of silently returning a zeroedPOINT. - Cleaner Verbose Detection:
-Verboseis now detected via$PSBoundParameters.ContainsKey('Verbose'), so a globally set$VerbosePreferenceno longer triggers the script's per-cycle countdown unintentionally. - Verbose Countdown: Now uses
Write-Progresswith-SecondsRemaininginstead 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
ConstrainedLanguagemode, instead of failing partway through with a confusingAdd-Typeerror. - Platform Guard: On PowerShell 7, the script checks
$IsWindowsand exits with a pointer tocaffeinate(macOS) orsystemd-inhibit(Linux) instead of crashing onuser32.dll.
Breaking Changes
-HelpRemoved: UseGet-Help .\StayActive.ps1 -Fullor-Onlineinstead. Anyone scripting.\StayActive.ps1 -Helpneeds to update.- Output Streams: Status no longer goes to the host directly via
Write-Host. Scripts that captured stdout will need to use-InformationAction Continueor the6>redirection operator. - Parameter Sets:
-MoveInterval,-SmallMove,-OnlyWhenIdle,-IdleSecondsbelong to theNudgeset;-KeepAwake,-KeepDisplaybelong to theKeepAwakeset. Mixing them produces a parameter-set error.
Migration Guide
From v3.1.0 to v4.0.0:
- Replace
.\StayActive.ps1 -HelpwithGet-Help .\StayActive.ps1 -Full - If you piped or redirected the script's output, switch from stdout capture to
6>(Information stream) or pass-InformationAction SilentlyContinueto mute it - For "keep the machine awake" use cases (presentations, downloads), prefer the new
-KeepAwakeover the default Nudge mode - For "stay marked active in Teams" use cases, keep using the default (Nudge), and consider adding
-OnlyWhenIdleso 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
FullLanguagemode; the script exits with a clear message under Constrained Language Mode - Tested on Windows PowerShell 5.1 and PowerShell 7+
StayActive v3.1.0
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.1directive for clear error messaging on unsupported PowerShell versions
Security
- Code Signing: Script is digitally signed with Extended Validation (EV) Code Signing Certificate
StayActive
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
-Helpparameter 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-Verbosefunctionality - 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 -HelpBreaking 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
-Helpparameter
StayActive
[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.