Skip to content

Instantly share code, notes, and snippets.

@ryrun
Last active June 2, 2023 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryrun/6b1266bf7614ca682a0e17ee649a2b3f to your computer and use it in GitHub Desktop.
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
# 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