Sign in to follow this  
Followers 0
JohnWang

Detecting a new Process?

7 posts in this topic

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.

Share this post


Link to post
Share on other sites



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?


[center]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.[/center]

Share this post


Link to post
Share on other sites

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


[center]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.[/center]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Edit: nvm thanks 4 the help it work just Fine =D

Edited by JohnWang

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

maybe this

It works great, but why:

$list[0][0] = $list2[0][0]
    Else
        $list[0][0] = $list2[0][0]
   ; if you close processes - this resets the list
    EndIf

instead of:

EndIf
$list[0][0] = $list2[0][0]

?

Share this post


Link to post
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)

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).

[center]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.[/center]

Share this post


Link to post
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
Sign in to follow this  
Followers 0