Jump to content

Detecting a new Process?


 Share

Recommended Posts

hi

is there a possible way to detecing a new process with autoit program? I was wondering if there other easier way to detect a new process than using processList and manual loop though the list to find the new process. If there are any please post an example. Thank you very much.

Link to comment
Share on other sites

  • Moderators

You could just write a UDF to check the process list in the (loop you mentioned) at a desired time and store them in an array and compare the 2. would be almost instantanious.... Are you having a problem with writing the UDF?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

This only detects if a new Process was removed or added... but at least it will give an idea of what to do:

Dim $GetProcess , $CompareProcess , $LastArray, $TestThis

$GetProcessTime = TimerInit()
$Check = ''
While 1
    If TimerDiff($GetProcessTime) / 1000 >= 1 Then; checks for a change in process list ever 1 second
        $GetProcess = GetProccessInfo(Chr(01))
        If StringInStr($LastArray, $GetProcess) = 0 Then
            $LastArray = $GetProcess
            $Check = $Check + 1
            If $Check <> 1 Then MsgBox(0, 'Change', 'The Process List Changed')
        EndIf
        $GetProcessTime = TimerInit()
    EndIf
    Sleep(100)
WEnd

Func GetProccessInfo($d_Delimeter)
    Local $n_NowList = ProcessList()
    Local $r_ReturnArray = ''
    For $i = 1 To $n_NowList[0][0]
        $r_ReturnArray = $r_ReturnArray & $n_NowList[$i][0] & $d_Delimeter
    Next
    Return $r_ReturnArray;StringTrimRight($r_ReturnArray, 1)
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

maybe this

Dim $list = ProcessList()

AdlibEnable("chk_Process")

While 1
    Sleep(20)
WEnd

Func chk_Process()
    $list2 = ProcessList()
    If $list2[0][0] > $list[0][0] Then
        MsgBox(262208,"New Process", $list2[$list2[0][0]][0] & "  ")
        $list[0][0] = $list2[0][0]
    Else
        $list[0][0] = $list2[0][0]
    ; if you close processes - this resets the list
    EndIf
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

maybe this

Dim $list = ProcessList()

AdlibEnable("chk_Process")

While 1
    Sleep(20)
WEnd

Func chk_Process()
    $list2 = ProcessList()
    If $list2[0][0] > $list[0][0] Then
        MsgBox(262208,"New Process", $list2[$list2[0][0]][0] & "  ")
        $list[0][0] = $list2[0][0]
    Else
        $list[0][0] = $list2[0][0]
; if you close processes - this resets the list
    EndIf
EndFunc

8)

On my first attempt at this, I did mine really similar to this (however I did it like Mavil asked with the $list = $list2 after the EndIf)... But the problem I ran into is this doesn't detect the first instance of an .exe in the process being removed (It does detect first one being added though).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...