基本上,我正在创建一个管理器,当您单击按钮或列表框项时,该管理器将显示窗口。
这很有用,因为在I.T.在工作场所中,有打开多个程序的窗口或正在运行的一个程序的实例,通过查看特定实例并单击以显示该实例,可以比在任务栏上滚动以查找一个文档更容易,从而在任务之间进行切换您正在寻找。
我有两个问题:
在列表框中选择实例后,如何显示通过按钮选择的窗口
如何使它仅关闭程序的选项卡/实例而不是程序?
我正在使用的kill脚本是
Private Sub btnKill_Click(sender As Object, e As EventArgs) Handles btnKill.Click
Try
Dim whole As String = Search.SelectedItem.ToString
Dim pid = whole.Substring(whole.LastIndexOf(" # "))
pid = pid.Replace(" # ", "")
Dim p As Process = Process.GetProcessById(pid)
Try
p.Kill()
Catch ex As Exception
' MessageBox.Show(ex.Message)
End Try
Catch ex As Exception
' MessageBox.Show(ex.Message)
End Try
Search.Items.Clear()
For Each p As Process In Process.GetProcesses
If p.MainWindowTitle = String.Empty = False Then
Search.Items.Add(p.ProcessName & " # " & p.MainWindowTitle & " # " & p.Id)
End If
Next
'For every process running
For Each P As Process In Process.GetProcesses
'Get a list of ALL of the open windows associated with the process
Dim windows As IDictionary(Of IntPtr, String) = GetOpenWindowsFromPID(P.Id)
For Each kvp As KeyValuePair(Of IntPtr, String) In windows
If kvp.Value.ToLower = "start" = False Then
lstMain.Items.Add(P.ProcessName & " # " & kvp.Value & " # " & P.Id)
Search.Items.Clear()
End If
Next
Next
Try
Dim whole As String = lstMain.SelectedItem.ToString
Dim pid = whole.Substring(whole.LastIndexOf(" # "))
pid = pid.Replace(" # ", "")
Dim p As Process = Process.GetProcessById(pid)
Try
p.Kill()
Catch ex As Exception
' MessageBox.Show(ex.Message)
End Try
Catch ex As Exception
' MessageBox.Show(ex.Message)
End Try
lstMain.Items.Clear()
For Each p As Process In Process.GetProcesses
If p.MainWindowTitle = String.Empty = False Then
lstMain.Items.Add(p.ProcessName & " # " & p.MainWindowTitle & " # " & p.Id)
End If
Next
'For every process running
For Each P As Process In Process.GetProcesses
'Get a list of ALL of the open windows associated with the process
Dim windows As IDictionary(Of IntPtr, String) = GetOpenWindowsFromPID(P.Id)
For Each kvp As KeyValuePair(Of IntPtr, String) In windows
If kvp.Value.ToLower = "start" = False Then
lstMain.Items.Add(P.ProcessName & " # " & kvp.Value & " # " & P.Id)
End If
Next
Next
End Sub
即使我打开了3个不同的单词文件,如果我杀死一个,它也会全部杀死。我认为这与:
Dim pid = whole.Substring(whole.LastIndexOf(" # "))
pid = pid.Replace(" # ", "")
Dim p As Process = Process.GetProcessById(pid)
非常感谢您的帮助!
谢谢!
-Filip
编辑:如何将“ BringtoFront”命令与之配合使用?