mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-17 18:27:42 -06:00
Main window handle (#1941)
Condition is comparing $proc.Id with [System.IntPtr]::Zero. The Id property is an integer, representing the process ID, and it's not directly related to window handles. Instead, you should compare the MainWindowHandle property against [System.IntPtr]::Zero
This commit is contained in:
parent
15eb12af11
commit
f130fc6c49
@ -272,9 +272,13 @@ Add-Type @"
|
||||
}
|
||||
|
||||
foreach ($proc in (Get-Process | Where-Object { $_.MainWindowTitle -and $_.MainWindowTitle -like "*titus*" })) {
|
||||
if ($proc.Id -ne [System.IntPtr]::Zero) {
|
||||
# Check if the process's MainWindowHandle is valid
|
||||
if ($proc.MainWindowHandle -ne [System.IntPtr]::Zero) {
|
||||
Write-Debug "MainWindowHandle: $($proc.Id) $($proc.MainWindowTitle) $($proc.MainWindowHandle)"
|
||||
$windowHandle = $proc.MainWindowHandle
|
||||
} else {
|
||||
Write-Warning "Process found, but no MainWindowHandle: $($proc.Id) $($proc.MainWindowTitle)"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user