Last active
June 2, 2023 16:52
-
-
Save ryrun/6b1266bf7614ca682a0e17ee649a2b3f to your computer and use it in GitHub Desktop.
Windows 10 and Windows 11: "Windows Key+Print" Play a sound for Screenshots, when new file is created
This file contains 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
# Set-ExecutionPolicy -ExecutionPolicy Undefined -Scope CurrentUser <- default | |
# Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser <- all scripts | |
# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser <- only local scripts | |
# Task Sheduler, on Systemstart: PowerShell.exe -ExecutionPolicy Bypass -File "C:\Users\Shadow\Documents\screenshotWatcher.ps1" <- best option | |
$wav = New-Object System.Media.SoundPlayer | |
$wav.SoundLocation='C:\Program Files (x86)\Steam\resource\camera1.wav' | |
$watcher = New-Object System.IO.FileSystemWatcher | |
$watcher.Path = "C:\Users\Shadow\Pictures\Screenshots" | |
$watcher.Filter = "*.*" | |
$watcher.IncludeSubdirectories = $true | |
$watcher.EnableRaisingEvents = $true | |
$action = { | |
$wav.playsync() | |
} | |
Register-ObjectEvent $watcher "Created" -Action $action | |
while (1) { | |
Start-Sleep -seconds 3 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment