JohnWang Posted January 14, 2006 Share Posted January 14, 2006 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 More sharing options...
Moderators SmOke_N Posted January 14, 2006 Moderators Share Posted January 14, 2006 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 More sharing options...
Moderators SmOke_N Posted January 14, 2006 Moderators Share Posted January 14, 2006 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 More sharing options...
JohnWang Posted January 14, 2006 Author Share Posted January 14, 2006 (edited) Edit: nvm thanks 4 the help it work just Fine =D Edited January 14, 2006 by JohnWang Link to comment Share on other sites More sharing options...
Valuater Posted January 14, 2006 Share Posted January 14, 2006 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) Link to comment Share on other sites More sharing options...
masvil Posted January 14, 2006 Share Posted January 14, 2006 maybe thisIt 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] ? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 14, 2006 Moderators Share Posted January 14, 2006 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now