powershell mouse move does not prevent idle mode

后端 未结 8 1770
猫巷女王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:22

    I had a similar situation where a download needed to stay active overnight and required a key press that refreshed my connection. I also found that the mouse move does not work. However, using notepad and a send key function appears to have done the trick. I send a space instead of a "." because if there is a [yes/no] popup, it will automatically click the default response using the spacebar. Here is the code used.

    param($minutes = 120)
    
    $myShell = New-Object -com "Wscript.Shell"
    
    for ($i = 0; $i -lt $minutes; $i++) {
      Start-Sleep -Seconds 30
      $myShell.sendkeys(" ")
    }
    

    This function will work for the designated 120 minutes (2 Hours), but can be modified for the timing desired by increasing or decreasing the seconds of the input, or increasing or decreasing the assigned value of the minutes parameter.

    Just run the script in powershell ISE, or powershell, and open notepad. A space will be input at the specified interval for the desired length of time ($minutes).

    Good Luck!

    0 讨论(0)
  • 2021-01-30 10:23

    There is an analog solution to this also. There's an android app called "Timeout Blocker" that vibrates at a set interval and you put your mouse on it. https://play.google.com/store/apps/details?id=com.isomerprogramming.application.timeoutblocker&hl=en

    0 讨论(0)
提交回复
热议问题