试出来了,把按钮里的代码改成黄色的这样就可以了。
Dim dic As Dictionary(Of String, Integer) = vars("abc")
If dic.ContainsKey("记事本") Then
'msgbox("已打开") '已打开的,不再开新的
'SetForegroundWindow(dic("记事本")) '已打开的,不再开新的
'Return '已打开的,不再开新的
'SendMessage(dic("记事本"), &H0010, 0, 0) '用这一句,关掉原窗口时会提示修改是否保存
Dim ps As System.Diagnostics.Process() = System.Diagnostics.Process.GetProcesses() '不提示修改保存,直接用关进程的方式关掉
For Each p As System.Diagnostics.Process In ps
output.show(p.processName)
If p.ProcessName Like "*记事本*" Then
p.kill
End If
Next
vars("abc").Remove("记事本")
End If
basemainform.Topmost = True
Dim Proc As New Process
Proc.file = "notepad.exe"
Proc.Start()
System.Threading.Thread.Sleep(1000)
'上面是模拟一个打开的程序
vars("标题") = "记事本"
Dim CallBack As New EnumWindowsProc(AddressOf EnumWindowsProcCallBack)
EnumWindows(CallBack, 0)