Skip to content

Instantly share code, notes, and snippets.

@jamessantiago
Last active August 29, 2015 14:05
Show Gist options
  • Save jamessantiago/b6bfcc9d6f4d09f77a23 to your computer and use it in GitHub Desktop.
Save jamessantiago/b6bfcc9d6f4d09f77a23 to your computer and use it in GitHub Desktop.
Timbo Shell
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class Tricks {
[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();
}
"@
1..60 |% {
$p = [tricks]::GetForegroundWindow()
$c = get-process | ? { $_.mainwindowhandle -eq $p }
write-host "$(date): $($c.ProcessName) has focus"
sleep 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment