File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -27,23 +27,20 @@ function Show-Window {
2727 [string ] $ProcessName
2828 )
2929 $ProcessName = $ProcessName -replace ' \.exe$'
30- # WARN: This method return the latest windows which have title. many have titles but cant show.
31- # IF you want to switch between them, must use different method like powertoys run.
32- $procId = (Get-Process - ErrorAction Ignore " *$ProcessName *"
33- ).Where ({ $_.MainWindowTitle }, ' First' ).Id
3430
31+ $b = (Get-Process - ErrorAction Ignore " *$ProcessName *" ).Where ({ $_.MainWindowTitle })
32+ $c = $b | % ProcessName | fzf -- select-1 -- exit-0 -- bind one:accept | % {$b | ? Name -eq $_ }
33+ $procId = $c.ID
3534 if (-not $procId ) {
3635 throw " No $ProcessName process with a non-empty window title found."
3736 return 1
3837 }
39- $null = (New-Object - ComObject WScript.Shell).AppActivate($procId )
38+ return (New-Object - ComObject WScript.Shell).AppActivate($procId )
4039}
41- Set-Alias - Name shw - Value Show-Window
40+
4241# Load the necessary assembly
4342Add-Type - AssemblyName System.Windows.Forms
4443
45-
46- # Define the user32.dll functions
4744Add-Type @"
4845using System;
4946using System.Runtime.InteropServices;
You can’t perform that action at this time.
0 commit comments