amakrkr Posted January 24, 2014 Posted January 24, 2014 (edited) Hello, i have found quite some examples on forum but this array compare still bugs me. What am i trying to do is, i have one array of opened processes and one array of processes listed in ini file. I am trying to compare those two arrays and eliminate processes that are already in ini file (or in second array). But my code instead of displaying those that are not in ini file it displays every single process because i suspect that my code checks arrays like this: ARRAY1: [0] PID 345 ARRAY2:[0] PID: 0 -> FALSE ARRAY2: [1] PID 3544 ARRAY2:[1] PID: 345 -> FALSE Above example should return only 3544. Here is my code: #include <Array.au3> local $avArray[3] = ["1255","0","23423"] Local $aList = ProcessList("notepad.exe") for $i = 0 to UBound($aList,1) - 1 if $aList[$i][1] <> "23423" Then MsgBox(0,"This: ",$aList[$i][1]) EndIf Next Edited January 24, 2014 by amakrkr
Solution Geir1983 Posted January 24, 2014 Solution Posted January 24, 2014 I think the PID will change for every time you start a process, how can you store a bunch of PID and know what it is? ProcessList will return in element 0 the number of results so you should start your loop with i=1
amakrkr Posted January 24, 2014 Author Posted January 24, 2014 hI, Geir1983 thats not the problem. Problem is i need to compare strings in array 1 with every string in array 2 and display the one which is not in array2 or is in arry 2 doesnt matter. Thanks
amakrkr Posted January 24, 2014 Author Posted January 24, 2014 nvm i solved it my self. thanks all who tried to help!
Geir1983 Posted January 24, 2014 Posted January 24, 2014 (edited) #include <Array.au3> local $avArray[3] = ["1255","0","12540"] Local $aList = ProcessList("notepad.exe") for $i = 1 to Ubound($aList)-1 $IsInArray=False For $j = 0 to Ubound($avArray)-1 if $aList[$i][1] = $avArray[$j] Then $IsInArray=True Next IF $IsInArray Then MsgBox(0,"This: ",$aList[$i][1]) Next Like this? Edit: to late Edited January 24, 2014 by Geir1983
JohnOne Posted January 24, 2014 Posted January 24, 2014 It's common courtesy to post solution to problem. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
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