Jump to content

Gui list processes help


 Share

Recommended Posts

Hi, I have a little problem with my GUI. I have a main window and in it i have a list, I want the list to update to view all my processes when i click a "list processes" button. I also want it to work like i click a process in the list and then it close it with ProcessClose("$process") by using a button. Here is my code that don't work:

;Main GUI
GuiCreate("Gui", 750, 376,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
;buttons
$Button_28 = GuiCtrlCreateButton("List Processes", 280, 180, 100, 20)
$Button_26 = GuiCtrlCreateButton("Kill Process", 280, 160, 100, 20)
;list
$List_34 = GuiCtrlCreateList("Processes", 280, 210, 100, 123)

GuiSetState()
;main loop
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_28
        $list = ProcessList()
            for $i = 1 to $list[0][0]
        next
        GUICtrlSetData($list_34, $list)
         Case $msg = $button_26
                ProcessClose("$process")
                ;I have no idea how to do this either.
    EndSelect
WEnd
Exit

I took the List processes code from the manual but it doesn't work.

This might be in the GUI help forum but i didn't see it :shocked:

Edited by Adjed
Link to comment
Share on other sites

Well, this moves you forward anyway:

#include <GuiConstants.au3>

;Main GUI
GUICreate("Gui", 750, 376, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
;buttons
$Button_28 = GUICtrlCreateButton("List Processes", 280, 180, 100, 20)
$Button_26 = GUICtrlCreateButton("Kill Process", 280, 160, 100, 20)
;list
$List_34 = GUICtrlCreateList("Processes", 280, 210, 100, 123)

GUISetState()
;main loop
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_28
            $list = ProcessList()
            For $i = 1 To $list[0][0]
                GUICtrlSetData($List_34, $list[$i][0])
            Next
        Case $msg = $Button_26
            ; ProcessClose("$process")
            ; I have no idea how to do this either.
    EndSelect
WEnd
Exit

Problems:

1. You didn't include GuiConstants.au3, so your GuiCreate used undefined variables.

2. You had Next immediately after For, preventing anything from being added to the list.

3. You did not make a valid reference to the $list array returned from ProcessList().

To do:

When the kill button is clicked, you need to read the list control with GuiCtrlRead() to find out which one is selected, and kill it.

Notes:

There can be more than one process with the same name. If you want to distinguish between them, you'll have to use the process ID instead of the name.

:shocked:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...