Light
Project Green
DVD Screen Waker
Start
Press
Enter
or click to toggle
Screen wake lock: unavailable
Cursor “Animation” 👀
1
Click
Copy
below, open Notepad, paste, then save as
exercise1.ps1
(set file type to
All Files
so it doesn't save as
.txt
).
2
Right-click the file and select
Run with PowerShell
.
3
To stop it, click the PowerShell window and press
Ctrl+C
.
download here, if you dare
exercise1.ps1
Copy
Add-Type
-AssemblyName
System.Windows.Forms
$radius
=
100
# pixels from center
$steps
=
60
# points per full rotation
$delay
=
30
# ms per step (~1.8s per loop)
Write-Host
"Exercise 1: cursor animation running. Press Ctrl+C to stop."
Write-Host
"Moving in a circle (radius:
$radius
px)`n"
$origin
=
[
System.Windows.Forms.Cursor
]::Position
$i
=
0
while
(
$true
) {
$angle
=
2
*
[
Math
]::PI
*
$i
/
$steps
$x
=
[
int
](
$origin
.X
+
$radius
*
[
Math
]::Cos(
$angle
))
$y
=
[
int
](
$origin
.Y
+
$radius
*
[
Math
]::Sin(
$angle
)) [
System.Windows.Forms.Cursor
]::Position
=
[
System.Drawing.Point
]::new(
$x
,
$y
)
Start-Sleep
-Milliseconds
$delay
$i
=
(
$i
+
1
)
%
$steps
if
(
$i
-eq
0
) {
$time
=
Get-Date
-Format
"HH:mm:ss"
Write-Host
"[
$time
] Loop"
} }