Created
May 30, 2020 16:21
-
-
Save emad-elsaid/2c82ab51d793f205c8b57dec75b6f1c4 to your computer and use it in GitHub Desktop.
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
Add-Type @" | |
using System; | |
using System.Runtime.InteropServices; | |
public class Tricks { | |
[DllImport("user32.dll")] | |
public static extern IntPtr GetForegroundWindow(); | |
} | |
"@ | |
while($TRUE) | |
{ | |
$a = [tricks]::GetForegroundWindow() | |
get-process | ? { $_.mainwindowhandle -eq $a } | |
sleep 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment