- Offizieller Beitrag
Hi,
im Hilfeforum tauchte die Frage auf, wie man feststellen kann, ob ein neuer Prozeß hinzugekommen ist.
Ich hab das mal in ein Bsp. verpackt. Hier wird es mit HotKey (WIN+ALT+P) aufgerufen. Läßt sich im Skript zum Bsp. mit AdlibEnable einbinden.
Spoiler anzeigen
Global $oList_old = ObjCreate("Scripting.Dictionary")
Global $oList_cur = ObjCreate("Scripting.Dictionary")
Global $oList_new = ObjCreate("Scripting.Dictionary")
Global $aProcess
HotKeySet('#!p', '_showP')
HotKeySet('#!e', '_ende')
While True
Sleep(50)
WEnd
Func _showP()
Local $ar = _GetNewProcess(), $str = ''
If $ar[0][0] = -1 Then Return MsgBox(0, 'Neue Prozesse', 'Keine neuen Prozesse.')
For $i = 0 To UBound($ar) -1
$str &= $ar[$i][1] & @TAB & $ar[$i][0] & @CRLF
Next
Return MsgBox(0, 'Neue Prozesse', $str)
EndFunc
Func _ende()
Exit
EndFunc
Func _GetNewProcess()
$aProcess = ProcessList()
For $i = 1 To UBound($aProcess) -1
$oList_cur.Add($aProcess[$i][1], $aProcess[$i][0])
Next
If $oList_old.Count <> 0 Then
If $oList_new.Count > 0 Then $oList_new.RemoveAll
For $process In $oList_cur.Keys
If Not $oList_old.Exists($process) Then $oList_new.Add($process, $oList_cur.Item($process))
Next
$oList_old.RemoveAll
Else
_CopyList($oList_cur, $oList_new)
EndIf
_CopyList($oList_cur, $oList_old)
$oList_cur.RemoveAll
Local $aOut[1][2] = [[-1]], $i = 0
If $oList_new.Count > 0 Then
ReDim $aOut[$oList_new.Count][2]
For $process In $oList_new.Keys
$aOut[$i][0] = $oList_new.Item($process)
$aOut[$i][1] = $process
$i += 1
Next
EndIf
Return $aOut
EndFunc ;==>_GetNewProcess
Func _CopyList(ByRef $oDictFrom, ByRef $oDictTo)
For $key In $oDictFrom.Keys
$oDictTo.Add($key, $oDictFrom.Item($key))
Next
EndFunc