Jump to content

how to sort this list


Recommended Posts

Try this:

; Sort ProcessList

#include <Array.au3>

Global $sa2_ProcessList = ProcessList()

_ArrayDisplay($sa2_ProcessList, "$sa2_ProcessList")

_ArraySort($sa2_ProcessList, 0 , 1, 0, 1) ; Sort by 2nd column

_ArrayDisplay($sa2_ProcessList, "$sa2_ProcessList")

 

Edited by taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

10 minutes ago, taurus905 said:

Try this:

; Sort ProcessList

#include <Array.au3>

Global $sa2_ProcessList = ProcessList()

_ArrayDisplay($sa2_ProcessList, "$sa2_ProcessList")

_ArraySort($sa2_ProcessList, 0 , 1, 0, 1) ; Sort by 2nd column

_ArrayDisplay($sa2_ProcessList, "$sa2_ProcessList")

 

my bad , i didnt explain it clearly, i want only the item in the second column, and the PIDs should > 4

Link to comment
Share on other sites

This isn't the shortest or best way, but it should allow you to follow and edit to suit your needs.

; Sort ProcessList

#include <Array.au3>

Global $sa2_ProcessList = ProcessList()

_ArrayDisplay($sa2_ProcessList, "Original")

_ArraySort($sa2_ProcessList, 0 , 1, 0, 1) ; Sort by 2nd column

_ArrayDisplay($sa2_ProcessList, "Sorted")

For $i = 1 To UBound($sa2_ProcessList) - 1
    If $sa2_ProcessList[$i][1] <= 5 Then
        _ArrayDelete($sa2_ProcessList, $i)
        $sa2_ProcessList[0][0] -= 1
        $i -= 1
    Else
        ExitLoop
    EndIf
Next

_ArrayDisplay($sa2_ProcessList, "PIDs > 4")

$sa2_ProcessList[0][1] = $sa2_ProcessList[0][0] & " PIDs > 4"

_ArrayColDelete($sa2_ProcessList, 0)

_ArrayDisplay($sa2_ProcessList, "Just PIDs > 4")

 

Edited by taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

6 minutes ago, taurus905 said:

This isn't the shortest or best way, but it should allow you to follow and edit to suit your needs.

; Sort ProcessList

#include <Array.au3>

Global $sa2_ProcessList = ProcessList()

_ArrayDisplay($sa2_ProcessList, "Original")

_ArraySort($sa2_ProcessList, 0 , 1, 0, 1) ; Sort by 2nd column

_ArrayDisplay($sa2_ProcessList, "Sorted")

For $i = 1 To UBound($sa2_ProcessList) - 1
    If $sa2_ProcessList[$i][1] <= 5 Then
        _ArrayDelete($sa2_ProcessList, $i)
        $sa2_ProcessList[0][0] -= 1
        $i -= 1
    Else
        ExitLoop
    EndIf
Next

_ArrayDisplay($sa2_ProcessList, "PIDs > 4")

$sa2_ProcessList[0][1] = $sa2_ProcessList[0][0] & "PIDs > 4"

_ArrayColDelete($sa2_ProcessList, 0)

_ArrayDisplay($sa2_ProcessList, "Just PIDs > 4")

 

this script works , thanks for the effort man 😂

Edited by jacky998877
Link to comment
Share on other sites

Another way based on  @taurus905 code:

#include <Array.au3>

Global $aProcesses = ProcessList()
_ArrayDelete($aProcesses, 0)    ;~ Delete first row
_ArrayColDelete($aProcesses, 0) ;~ Delete first column
_ArraySort($aProcesses)         ;~ Sort Array
_ArrayDisplay($aProcesses, ":: Before ::")
For $i = UBound($aProcesses) - 1 To 0 Step - 1
    If $aProcesses[$i][0] <=5 Then _ArrayDelete($aProcesses, $i)
Next
_ArrayDisplay($aProcesses, ":: After ::")

 

Link to comment
Share on other sites

30 minutes ago, Subz said:

Another way based on  @taurus905 code:

#include <Array.au3>

Global $aProcesses = ProcessList()
_ArrayDelete($aProcesses, 0)    ;~ Delete first row
_ArrayColDelete($aProcesses, 0) ;~ Delete first column
_ArraySort($aProcesses)         ;~ Sort Array
_ArrayDisplay($aProcesses, ":: Before ::")
For $i = UBound($aProcesses) - 1 To 0 Step - 1
    If $aProcesses[$i][0] <=5 Then _ArrayDelete($aProcesses, $i)
Next
_ArrayDisplay($aProcesses, ":: After ::")

 

first thanks for the solution you provided, i was trying to make further progress based on you code ,so that i can close the items in the list ,
this is the code 
 

for $a in $aProcesses    
    ProcessClose($a)
Next

my code didnt work , neither any errors are being displayed in the console , do you have any idea?

Link to comment
Share on other sites

5 minutes ago, Subz said:

You would need to use the following to loop through the list, although note that a number of processes cannot be closed using this method, what is the objective?

For $a = 0 To Ubound($aProcesses) - 1

 

i tried it also , no luck , i wnat to build a litte program to shut down the computer, for the default shut down fucntion of windows7, each time it will ask again to close the opened programs

Edited by jacky998877
Link to comment
Share on other sites

6 minutes ago, Subz said:

Sorry forgot the rest of the code:

For $a = 0 To Ubound($aProcesses) - 1
    ProcessClose($aProcesses[$a])
Next

Shutdown function should also ask the user to close programs, it only forces the shutdown if you use Shutdown(BitOr($SD_SHUTDOWN,$SD_FORCE))

it is ok, i already tried it before you update, still , an error 
 

==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
ProcessClose($aProcesses[$a])
ProcessClose(^ ERROR

 

Edited by jacky998877
Link to comment
Share on other sites

15 minutes ago, Subz said:

Sorry, forgot when you convert a 2D array to 1D array you still need to reference the column, so try:

For $a = 0 To Ubound($aProcesses) - 1
    ProcessClose($aProcesses[$a][0])
Next

 

yep , it worked out pefectly according to its own will, the moment it is being executed, my computer give me a blue screen , accutually i already took care of the problem , at least i think so, by deleting the process PID which is lesser then 4 , this is a dangerous program 

Edited by jacky998877
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...