powershell mouse move does not prevent idle mode

后端 未结 8 1775
猫巷女王i
猫巷女王i 2021-01-30 09:36

Before I start, here is my very first little code I wrote in PowerShell :)

[System.Windows.Forms.Cursor]::Position = `
    New-Object System.Drawing.Point($pos.X         


        
8条回答
  •  花落未央
    2021-01-30 10:13

    Try this: (source: http://just-another-blog.net/programming/powershell-and-the-net-framework/)

    Add-Type -AssemblyName System.Windows.Forms 
    
    $position = [System.Windows.Forms.Cursor]::Position  
    $position.X++  
    [System.Windows.Forms.Cursor]::Position = $position 
    
        while(1) {  
        $position = [System.Windows.Forms.Cursor]::Position  
        $position.X++  
        [System.Windows.Forms.Cursor]::Position = $position  
    
        $time = Get-Date;  
        $shorterTimeString = $time.ToString("HH:mm:ss");  
    
        Write-Host $shorterTimeString "Mouse pointer has been moved 1 pixel to the right"  
        #Set your duration between each mouse move
        Start-Sleep -Seconds 150  
        }  
    

提交回复
热议问题