Skip to content

Instantly share code, notes, and snippets.

@yamgarcia
Last active June 24, 2026 08:05
Show Gist options
  • Select an option

  • Save yamgarcia/f5caec679db539e843af1d6901236527 to your computer and use it in GitHub Desktop.

Select an option

Save yamgarcia/f5caec679db539e843af1d6901236527 to your computer and use it in GitHub Desktop.
Auto Mouse Mover - AntiscreenSaver
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class Mouse {
[DllImport("user32.dll")]
public static extern bool SetCursorPos(int x, int y);
}
"@
function Start-AntiscreenSaver {
# Save the current execution policy
$currentPolicy = Get-ExecutionPolicy
# Set the execution policy to RemoteSigned
Set-ExecutionPolicy RemoteSigned -Scope Process
$screenHeight = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height
$screenWidth = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width
$targetX = $screenWidth / 2
$targetY = $screenHeight
$timeout = New-TimeSpan -Minutes 5
while ($true) {
$currentTime = Get-Date -Format "HH:mm:ss"
$randomMinute = Get-Random -Minimum 49 -Maximum 59
$currentMousePosition = [System.Windows.Forms.Cursor]::Position.X
Start-Sleep -Milliseconds 10000
if (($currentTime -gt ("07:"+$30+":30")) -and
($currentTime -le ("16:"+$randomMinute+":00"))
){
Start-MoveIfSamePosition($currentMousePosition)
# Reset lastInputTime
$lastInputTime = [Environment]::TickCount
}
# Check input interval
Start-Sleep -Milliseconds 1000
}
# Set the execution policy back to the original value
Set-ExecutionPolicy $currentPolicy -Scope Process
}
Function Start-MoveIfSamePosition {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$currentMousePosition
)
$newMousePosition = [System.Windows.Forms.Cursor]::Position.X
if($newMousePosition -eq $currentMousePosition){
Write-Host $newMousePosition
Write-Host $currentMousePosition
# move the mouse cursor
[Mouse]::SetCursorPos($targetX+10, $targetY+10)
Start-Sleep -Seconds 1
[Mouse]::SetCursorPos($targetX+50, $targetY+50)
}
}
Start-AntiscreenSaver
# Add the new type definition with the click method
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class MouseActions {
[DllImport("user32.dll")]
public static extern bool SetCursorPos(int x, int y);
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);
public const int MOUSEEVENTF_LEFTDOWN = 0x02;
public const int MOUSEEVENTF_LEFTUP = 0x04;
public static void ClickLeftMouseButton(int x, int y) {
SetCursorPos(x, y);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, (uint)x, (uint)y, 0, 0);
}
}
"@
function Start-AntiscreenSaver {
# Save the current execution policy
$currentPolicy = Get-ExecutionPolicy
# Set the execution policy to RemoteSigned
Set-ExecutionPolicy RemoteSigned -Scope Process
$screenHeight = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height
$screenWidth = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width
$targetX = $screenWidth / 2
$targetY = $screenHeight
while ($true) {
$currentTime = Get-Date -Format "HH:mm:ss"
$randomMinute = Get-Random -Minimum 49 -Maximum 59
$currentMousePosition = [System.Windows.Forms.Cursor]::Position
Start-Sleep -Seconds 60
if (($currentTime -gt ("07:30:30")) -and ($currentTime -le ("17:" + $randomMinute + ":00"))) {
Start-MoveIfSamePosition -currentMousePosition $currentMousePosition -targetY $targetY -targetX $targetX
}
}
# Set the execution policy back to the original value
Set-ExecutionPolicy $currentPolicy -Scope Process
}
function Start-MoveIfSamePosition {
param (
[Parameter(Mandatory = $true)]
[System.Drawing.Point]$currentMousePosition,
[string]$targetY,
[string]$targetX
)
$newMousePosition = [System.Windows.Forms.Cursor]::Position
if ($newMousePosition -eq $currentMousePosition) {
# Move the mouse cursor
[MouseActions]::SetCursorPos($targetX + 5, $targetY)
Start-Sleep -Seconds 1
[MouseActions]::SetCursorPos($targetX, $targetY)
[MouseActions]::ClickLeftMouseButton($targetX, $targetY)
}
}
Start-AntiscreenSaver
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class Mouse {
[DllImport("user32.dll")]
public static extern bool SetCursorPos(int x, int y);
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);
public const int MOUSEEVENTF_LEFTDOWN = 0x02;
public const int MOUSEEVENTF_LEFTUP = 0x04;
public static void ClickLeftMouseButton(int x, int y) {
SetCursorPos(x, y);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, (uint)x, (uint)y, 0, 0);
}
}
"@
$screenHeight = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Bottom
$screenWidth = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width
$targetY = $screenHeight -10
$targetX = $screenWidth / 2
function Start-AntiscreenSaver {
# Save the current execution policy
$currentPolicy = Get-ExecutionPolicy
# Set the execution policy to RemoteSigned
Set-ExecutionPolicy RemoteSigned -Scope Process
while ($true) {
$currentTime = Get-Date -Format "HH:mm:ss"
$randomMinute = Get-Random -Minimum 49 -Maximum 59
$currentMousePosition = [System.Windows.Forms.Cursor]::Position
# Check input interval
Start-Sleep -Seconds 120
if (($currentTime -gt ("07:30:30")) -and ($currentTime -le ("17:" + $randomMinute + ":00"))) {
Start-MoveIfSamePosition $currentMousePosition
}
}
# Set the execution policy back to the original value
Set-ExecutionPolicy $currentPolicy -Scope Process
}
function Start-MoveIfSamePosition {
param (
[Parameter(Mandatory = $true)]
[System.Drawing.Point]$currentMousePosition
)
$newMousePosition = [System.Windows.Forms.Cursor]::Position
if ($newMousePosition -eq $currentMousePosition) {
# Move the mouse cursor
[Mouse]::SetCursorPos($currentMousePosition.X + 5, $currentMousePosition.Y)
Start-Sleep -Seconds 1
[Mouse]::SetCursorPos($currentMousePosition.X, $currentMousePosition.Y)
# Simulate a mouse click
[Mouse]::ClickLeftMouseButton($targetX, $targetY)
}
}
Start-AntiscreenSaver
@boraluke

Copy link
Copy Markdown

Choosing the best moving company involves checking experience, customer reviews, and the clarity of their pricing before making a decision. Many people also compare online resources such as habibmovers.ae to understand available services and relocation options. A professional mover will offer transparent estimates, proper insurance coverage, and dependable communication to make the entire moving process easier and less stressful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment