This may be a question that is difficult to answer. I wrote a Script that checks the responding property of a process. to visualize that the script is running, i created a windows form where you can see which process is watched. The script runs perfectly, but I can't do anything with my winform. Can't minimize or close it, my mouse cursor switches to the hourglass symbol as soon as I move the cursor to the windowsform. any ideas why?
The winform is also not responding when I comment out the while loop
here's my code:
if ($ShowWindowsForm){
$window = New-Object System.Windows.Forms.Form
$window.text = "Process Watcher"
$window.size = New-Object System.Drawing.Size(350,100)
$window.location = New-Object System.Drawing.Size(100,100)
$icon = [system.drawing.icon]::ExtractAssociatedIcon($PSHOME + "\powershell.exe")
$window.Icon = $Icon
$text = New-Object System.Windows.Forms.Label
$text.Text = "Folgender Prozess wird überwacht:`n$target.exe"
$text.location = New-Object System.Drawing.Size(10,10)
$text.AutoSize = $true
$window.Controls.Add($text)
$window.Show()
}
while (1) {
sleep -Milliseconds 100
if(!((get-process $target).Responding -eq $true)) {
#do stuff
}