Jump to content

GUI to delete tasks from a given list of tasks


dexter
 Share

Recommended Posts

Hi ! I have been working on a task scheduling software, and at this point I need to incorporate this feature that will show all scheduled tasks ( or .job files in the tasks directory of windows) and the user can click on the task to be deleted and it is deleted. It will be more useful if the time when the task is scheduled to be run is also displayed.

Please help me out.

Link to comment
Share on other sites

Hi,

I made my program to add an entry in an ini file

So make a program reading out the ini.

There are many ways to display items:

1) You may fill a combobox with the names of the task.

2) You may use a listview.

For deletion create a 'Delete' button with apropriate action code.

For further assistence you should post some code and the structure of your ini file.

;-))

Stefan

Edited by 99ojo
Link to comment
Share on other sites

Hi ! This is the function I am trying to make to read out the ini and display it as a list, so that a entry can be selected and can be deleted. I am new to programing, plz bear with my errors ;)

func tasks()
    local $a, $ok, $cancel,$msg, $list1
    
    GUISetState(@SW_HIDE, $main)
    
    GUICreate("Delete Old Tasks", 400, 300)
    
    GUIsetIcon(@WindowsDir & "\alarm.ico",0)
    
    $filemenu = GUICtrlCreateMenu("&Help")
    $fileitem = GUICtrlCreateMenuItem("Open help file", $filemenu)
    GUICtrlSetState(-1, $GUI_DEFBUTTON)
    $url = GUICtrlCreateMenuItem("Open Support page", $filemenu)
    $about = GUICtrlCreateMenuItem("About", $filemenu)
    
    $ok = GUICtrlCreateButton("Delete",60,235,120,20)
    $cancel = GUICtrlCreateButton("Cancel",220,235,120,20)
    
    $List1 = GUICtrlCreateListView("Taskname" &"|" & "Time", 50, 24, 300, 200) ;
    
    GUISetState()
    
    $list1 = IniReadSection(@WindowsDir&"\tasks.ini","task")
    
    While 1
        
        GUICtrlCreateListViewItem("check", $List1)
        
        $msg = GUIGetMsg()
        
        select 
            
        case $msg = $GUI_EVENT_CLOSE
            Exit
    
        case $msg = $ok
            ExitLoop
        
        case $msg = $cancel
            ExitLoop
            
        case $msg = $fileitem
            call("help")
        
        case $msg = $url
            call("site")
        
        case $msg = $about
            msgbox(262144,"About","Auto-connect Download scheduler V 2.4 - By: Aijaz")
    
        EndSelect
        
    WEnd
    
    GUIDelete()
    
    call("choose")
    
    EndFunc

Plz let me have a working code . Thanks !

Link to comment
Share on other sites

Hi,

you missed to post more code and post your ini file structure. So i will post also some snippets fore you:

Tasks.ini structure:

[task]
taskname=test|9:30
taskname=test1|19:30

#include <GUIConstantsEx.au3>
#include <array.au3>
#Include <GuiListView.au3>
tasks ()

func tasks()
    local $a, $ok, $cancel,$msg, $artaskini
    
    GUISetState(@SW_HIDE, $main)
    
    GUICreate("Delete Old Tasks", 400, 300)
    
    GUIsetIcon(@WindowsDir & "\alarm.ico",0)
    
    $filemenu = GUICtrlCreateMenu("&Help")
    $fileitem = GUICtrlCreateMenuItem("Open help file", $filemenu)
    GUICtrlSetState(-1, $GUI_DEFBUTTON)
    $url = GUICtrlCreateMenuItem("Open Support page", $filemenu)
    $about = GUICtrlCreateMenuItem("About", $filemenu)
    
    $ok = GUICtrlCreateButton("Delete",60,235,120,20)
    $cancel = GUICtrlCreateButton("Cancel",220,235,120,20)
    
    $List1 = GUICtrlCreateListView("Taskname" &"|" & "Time", 50, 24, 300, 200) ;
    
    GUISetState()
    
    ;reading ini into array
    $listini = IniReadSection(@WindowsDir&"\tasks.ini","task")
    
    ;filling listview with ini values, more information see helpfile Return from IniReadSection       
    For $i = 1 To UBound ($listini) - 1
        GUICtrlCreateListViewItem($listini [$i] [1] , $List1)
    Next 
    
    While 1
 
        $msg = GUIGetMsg()
        
        select 
            
        case $msg = $GUI_EVENT_CLOSE
            Exit
    
        case $msg = $ok
            ;get index of 1 st selected listviewitem, no multi selection, no error control, you have to code by yourself
            ;see helpfile return of _GUICtrlListView_GetSelectedIndices
            $select = _GUICtrlListView_GetSelectedIndices ($List1, True)
            
            ;get text of selected listviewitem
            $string = _GUICtrlListView_GetItemText ($List1, $select [1])
            
            ;loop over IniReadSection array
            For $i = 1 To UBound ($listini) - 1
                
                ;find listviewitem in array
                If StringInStr ($listini [$i] [1], $string) Then
                    ;delete from array
                    _Arraydelete ($listini, $i)
                    ExitLoop
                EndIf
            Next
            
            ;open ini file in overwrite mode
            $file = FileOpen (@WindowsDir&"\tasks.ini", 2)
            
            ;1st line is section
            FileWriteLine ($file, "[task]")
            For $i = 1 To UBound ($listini) - 1
                
                ;next lines are values from IniReadSection array
                FileWriteLine ($file, $listini [$i] [0] & "=" & $listini [$i] [1])
            Next
            
            ;close file
            FileClose ($file)
            
            ;have a look at ini file
            ShellExecute (@WindowsDir&"\tasks.ini")
            ExitLoop
        
        case $msg = $cancel
            ExitLoop
            
        case $msg = $fileitem
            call("help")
        
        case $msg = $url
            call("site")
        
        case $msg = $about
            msgbox(262144,"About","Auto-connect Download scheduler V 2.4 - By: Aijaz")
    
        EndSelect
        
    WEnd
    
    GUIDelete()
EndFunc

;-))

Stefan

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...