Running files from ListBox

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Nocturnal
    Forum Member
    • Jun 2006
    • 29

    Running files from ListBox

    I found some code from another thread on here that explains how to run files through the ListBox.

    I have a listobx with several items and each time you double click on an item, it will install a program.

    I like it but I'm wondering if it's possible to get the listbox to be alphabetized as well as the code corresponding to the right item in the listbox.

    I did the sort action for the listbox but found that the items that I want to run are out of order.



    I used that example on how to do it but you cannot sort it by alpha order without the actual on double click action being out of order itself.

    Code:
    tsel = ListBox.GetSelected("ListBox1")
    
    if tsel[1] == 1 then
    --Here you have to put your code to open the file: For example
    --File.Open("", "")
    result = File.Run("Avast\\setupeng.exe", "/VERYSILENT /NORESTART /SP-", "", SW_SHOWNORMAL, true);
    File.Open("Avast\\key.txt", "", SW_SHOWNORMAL);
    result = File.Run("C:\\Program Files\\Alwil Software\\Avast4\\VisthLic.exe", "", "", SW_SHOWNORMAL, false);
    result = File.Run("C:\\Program Files\\Alwil Software\\Avast4\\VisthUpd.exe", "", "", SW_SHOWNORMAL, false);
    result = File.Run("C:\\Program Files\\Alwil Software\\Avast4\\sched.exe", "/A:* /RA:delete /RS:yes", "", SW_SHOWNORMAL, false);
    elseif tsel[1] == 2 then
    result = File.Run("SSS\\ccsetup.exe", "/S", "", SW_SHOWNORMAL, false);
    elseif tsel[1] == 3 then
    result = File.Run("AntiSpyware\\HJTInstall.exe", "", "", SW_SHOWNORMAL, false);
    elseif tsel[1] == 4 then
    result = File.Run("Misc Tools\\msicuu2.exe", "", "", SW_SHOWNORMAL, false);
    elseif tsel[1] == 5 then
    result = File.Run("Misc Tools\\wu2.bat", "", "", SW_SHOWNORMAL, false);
    elseif tsel[1] == 6 then
    -- step 1: connect anonymously to drweb.com
    FTP.Connect("ftp.symantec.com");
    err = Application.GetLastError();
    if err ~= FTP.OK then
        Dialog.Message("Error", _tblErrorMessages[err]);
    end
    
    -- step 2: change to the directory where the text file is located
    FTP.ChangeDir("/public/english_us_canada/removal_tools");
    err = Application.GetLastError();
    if err ~= FTP.OK then
        Dialog.Message("Error", _tblErrorMessages[err]);
    end
    
    -- step 3a: enable the status dialog's cancel button
    StatusDlg.ShowCancelButton();
    
    -- step 3b: show the status dialog
    StatusDlg.Show();
    
    -- step 3c: download the file as <temp>\Hamlet.txt
    FTP.Download("Norton_Removal_Tool.exe", "C:\\Documents and Settings\\All Users\\Desktop\\Norton_Removal_Tool.exe");
    err = Application.GetLastError();
    
    -- step 3d: hide the status dialog
    StatusDlg.Hide();
    
    -- step 4: log off
    FTP.Disconnect();
    
    -- ...now check whether FTP.Download generated an error
    if err == FTP.OK then
    Dialog.Message("Success!", "Norton Removal Tool was downloaded successfully!");
    else
        Dialog.Message("Error", _tblErrorMessages[err]);
    end
    elseif tsel[1] == 7 then
    result = File.Run("Misc Tools\\keyfinder.2.0.6\\keyfinder.exe", "", "", SW_SHOWNORMAL, false);
    elseif tsel[1] == 8 then
    result = File.Run("Misc Tools\\produkey\\ProduKey.exe", "", "", SW_SHOWNORMAL, false);
    elseif tsel[1] == 9 then
    result = File.Run("Misc Tools\\produkey-x64\\ProduKey.exe", "", "", SW_SHOWNORMAL, false);
    elseif tsel[1] == 10 then
    elseif tsel[1] == 11 then
    elseif tsel[1] == 12 then
    elseif tsel[1] == 13 then
    elseif tsel[1] == 14 then
    elseif tsel[1] == 15 then
    elseif tsel[1] == 16 then
    elseif tsel[1] == 17 then
    elseif tsel[1] == 18 then
    elseif tsel[1] == 19 then
    elseif tsel[1] == 20 then
    elseif tsel[1] == 21 then
    elseif tsel[1] == 22 then
    elseif tsel[1] == 23 then
    elseif tsel[1] == 24 then
    elseif tsel[1] == 25 then
    elseif tsel[1] == 26 then
    elseif tsel[1] == 27 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    elseif tsel[1] == 6 then
    end
    If you guys can show me how to make it so that I can sort by alpha order and also keep the code the same.
Working...
X