Last active
September 4, 2019 20:00
-
-
Save benabrahamson/2c6fb4d54907658bf99b137214527434 to your computer and use it in GitHub Desktop.
Adapted from a script by Peter Hinchley (https://hinchley.net/)
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
$newtitle = "PRIVATE" | |
$interval = 10 #milliseconds | |
Add-Type -TypeDefinition @" | |
using System; | |
using System.Runtime.InteropServices; | |
public static class Win32 { | |
[DllImport("User32.dll", EntryPoint="SetWindowText")] | |
public static extern int SetWindowText(IntPtr hWnd, string strTitle); | |
} | |
"@ | |
$timer = New-Object System.Timers.Timer | |
$timer.Enabled = $true | |
$timer.Interval = $interval | |
$timer.AutoReset = $true | |
function Change-Window-Titles($newtitle) { | |
Get-Process | ? {$_.mainWindowTitle -and $_.mainWindowTitle -notlike "$($newtitle)*"} | %{ | |
[Win32]::SetWindowText($_.mainWindowHandle, "$newtitle") | |
} | |
} | |
Register-ObjectEvent -InputObject $timer -EventName Elapsed -Action { | |
Change-Window-Titles $newtitle | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment