Sign in to follow this  
Followers 0
Nahuel

ProcessList problem

9 posts in this topic

I wanted to update my processmanager and was trying to find a way of refreshing the process list only if there's a new process or one ended. This is an example:

#include <GUIConstants.au3>
#Include <GuiList.au3>

 GUICreate("Form2", 249, 305, 208, 147)
$ListadeProcesos = GUICtrlCreateList("", 32, 16, 185, 253)
GUISetState(@SW_SHOW)
pros()
AdlibEnable("pros",2000)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func pros()
$Procesos=ProcessList()
$NumDePros=_GUICtrlListCount($ListadeProcesos)
MsgBox(0,"","ProcessList: "&$Procesos[0][0]&@CR&"ListView: "&$NumDePros)
If $Procesos[0][0]<>$NumDePros Then
    GUICtrlSetData($ListadeProcesos,"")
    for $i = 1 to $Procesos[0][0]
        GUICtrlSetData($ListadeProcesos,$Procesos[$i][0])
    next
EndIf
EndFunc

My problem is that, for some reson, the number of processes returned by ProcessList doesn't match the number of items. There's a difference of 2, but sometimes it's 3. I checked with _ArrayDisplay() and I see what the problem is, there are three processes called 'svchost.exe'. ProcessList DOES return them but GUICtrlSetData($ListadeProcesos,$Procesos[$i][0]) will only add it once!! :)

Can anyone explain why this happens?

Share this post


Link to post
Share on other sites



I wanted to update my processmanager and was trying to find a way of refreshing the process list only if there's a new process or one ended. This is an example:

#include <GUIConstants.au3>
#Include <GuiList.au3>

 GUICreate("Form2", 249, 305, 208, 147)
$ListadeProcesos = GUICtrlCreateList("", 32, 16, 185, 253)
GUISetState(@SW_SHOW)
pros()
AdlibEnable("pros",2000)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func pros()
$Procesos=ProcessList()
$NumDePros=_GUICtrlListCount($ListadeProcesos)
MsgBox(0,"","ProcessList: "&$Procesos[0][0]&@CR&"ListView: "&$NumDePros)
If $Procesos[0][0]<>$NumDePros Then
    GUICtrlSetData($ListadeProcesos,"")
    for $i = 1 to $Procesos[0][0]
        GUICtrlSetData($ListadeProcesos,$Procesos[$i][0])
    next
EndIf
EndFunc

My problem is that, for some reson, the number of processes returned by ProcessList doesn't match the number of items. There's a difference of 2, but sometimes it's 3. I checked with _ArrayDisplay() and I see what the problem is, there are three processes called 'svchost.exe'. ProcessList DOES return them but GUICtrlSetData($ListadeProcesos,$Procesos[$i][0]) will only add it once!! :)

Can anyone explain why this happens?

What happens if you replace:
for $i = 1 to $Procesos[0][0]
        GUICtrlSetData($ListadeProcesos,$Procesos[$i][0])
    nextoÝ÷ Ùh­«­¢+Ø$ÀÌØíÍ!½±ôÅÕ½ÐìÅÕ½Ðì(%½ÈÀÌØí¤ôÄѼÀÌØíAɽͽÍlÁulÁt($ÀÌØíÍ!½±µÀìôÀÌØíAɽͽÍlÀÌØí¥ulÁtµÀìÌäíðÌäì(%¹áÐ(%U%
ÑɱMÑÑ ÀÌØí1¥ÍÑAɽͽ̰ÀÌØíÍ!½±¤

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.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Perfect!! :) Thank you.

But.. why does it do that?

Edited by SmOke_N

Share this post


Link to post
Share on other sites

Well, you could try this as well, and if it works you might be able to see why:

#include <GUIConstants.au3>
#Include <GuiList.au3>

GUICreate("Form2", 249, 305, 208, 147)
$ListadeProcesos = GUICtrlCreateList("", 32, 16, 185, 253)
GUISetState(@SW_SHOW)
pros()
AdlibEnable("pros",2000)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func pros()
$Procesos=ProcessList()
$NumDePros=_GUICtrlListCount($ListadeProcesos)
MsgBox(0,"","ProcessList: "&$Procesos[0][0]&@CR&"ListView: "&$NumDePros)
If $Procesos[0][0]<>$NumDePros Then
    GUICtrlSetData($ListadeProcesos,"")
    for $i = 1 to $Procesos[0][0]
        GUICtrlSetData($ListadeProcesos,$Procesos[$i][0]&"|")
    next
EndIf
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.

Share this post


Link to post
Share on other sites

Yes that works perfectly! I see why your fix is doing, but my question was why can't we add many items with the same name? I guess that means that if I try:

Guictrlsetdata($Mylist,"hello")
Guictrlsetdata($Mylist,"hello")

it wouldn't work? Weird.

Share this post


Link to post
Share on other sites

Yes that works perfectly! I see why your fix is doing, but my question was why can't we add many items with the same name? I guess that means that if I try:

Guictrlsetdata($Mylist,"hello")
Guictrlsetdata($Mylist,"hello")

it wouldn't work? Weird.

You didn't notice the separator necessary I guess? "|"?

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.

Share this post


Link to post
Share on other sites

You didn't notice the separator necessary I guess? "|"?

No no no, I did! You are not getting my point. Apparently it can work without a separator if the items are different, but not if they are the same word. I was just wondering why that happens...

This will add both 'hello' and 'bye' items

Guictrlsetdata($Mylist,"hello")
Guictrlsetdata($Mylist,"Bye")

This will only add hello once

Guictrlsetdata($Mylist,"hello")
Guictrlsetdata($Mylist,"hello")

But never mind, it's just curiosity :) Thanks a lot for your help.

Share this post


Link to post
Share on other sites

From the help file for GUICtrlSetData:

Remarks

For Combo or List control :

If the "data" corresponds to an already existing entry it is set as the default.

If the "data" starts with GUIDataSeparatorChar or is an empty string "" the previous list is destroyed.


"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

OH I see.. thanks :)

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