Created
January 8, 2025 18:56
-
-
Save gerardo-junior/f98f3b7389281ff926588c299fa42043 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Save this as awakealways.ps1 | |
add-type -AssemblyName microsoft.VisualBasic | |
add-type -AssemblyName System.Windows.Forms | |
Add-Type -AssemblyName System.Windows.Forms | |
Add-Type -AssemblyName System.Drawing | |
Write-Warning "This will Prevent screen from sleep" | |
$form = New-Object System.Windows.Forms.Form | |
$form.Text = 'AwakeScreen' | |
$form.Size = New-Object System.Drawing.Size(200,100) | |
$form.StartPosition = 'Manual' | |
$form.Location = New-Object System.Drawing.Point(1500,670) | |
$textBox = New-Object System.Windows.Forms.TextBox | |
#$textBox.Location = New-Object System.Drawing.Point(10,40) | |
$textBox.Size = New-Object System.Drawing.Size(200,100) | |
$textBox.Multiline = $true | |
$form.Controls.Add($textBox) | |
$form.Topmost = $true | |
$form.Add_Shown({$textBox.Select()}) | |
$form.Show() | |
start-sleep -Milliseconds 1000 | |
try{ | |
Do { | |
$form.Activate() | |
#[Microsoft.VisualBasic.Interaction]::AppActivate($form.fo) | |
[System.Windows.Forms.SendKeys]::SendWait("{BS}") | |
[System.Windows.Forms.SendKeys]::SendWait(".") | |
start-sleep -Milliseconds 180000 | |
} While ($true) | |
} | |
finally | |
{ | |
Write-Warning "Terminating Powershell Script" | |
#Stop-Process $form | |
$form.Close() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
powershell.exe -ExecutionPolicy Bypass -File awakealways.ps1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment