Jump to content

Need Help on Exiting a script and Process status Bar


PCI
 Share

Recommended Posts

Hi all

I have a simple script ( Thanks to Bowmore ) that prompt user to input 2 files ( Test_file1.txt and Test_file2.txt )

It will then compare the files .

I have an issue , maybe i'm blind or need to go sleep , i cannot exit the script from the GUI ( Exit without comparing Button ) unless the compare process is completed.

Test_file1 and Test_file2 have each 1000 lines but when these files will have 20000 lines the process takes longer and you cannot exit unless the process is completed.

Could you please give me help adding a Process status Bar or when Comparing files to show how many line left to process.

Please advise.

See attached files

Thank you

Compare.au3

Test_file1.txt

Test_file2.txt

Edited by PCI
Link to comment
Share on other sites

This turns the progress bar on:

ProgressOn("Compare Files", "Comparing files...", "0% Complete")

Put that somewhere before your "compare loop" starts.

Insert ProgressSet()...

For $i = 1 To UBound($aArray1) - 1
                $iNumber = Round($i / UBound($aArray1) * 100, 2)
                ProgressSet($iNumber, $iNumber & "% Complete")
                $sID1 = StringLeft($aArray1[$i],StringInStr($aArray1[$i],"ý",1,1)-1)

This turns the progress bar off when comparing is done so put it at the end of the compare loop:

ProgressOff()

Edited by MrMitchell
Link to comment
Share on other sites

And if you want to exit the script midprocess you should be able to do it the same way you exit the script normally using your button...

For $i = 1 To UBound($aArray1) - 1
    $iNumber = Round($i / UBound($aArray1) * 100, 2)
    ProgressSet($iNumber, $iNumber & "% Complete")
    $msg = GUIGetMsg()
    If $msg=$ConfigurationExitWithoutSaving Then
     $ExitDialog = MsgBox(36, "Are You Sure?", "Are you sure you want to exit?")
     If $ExitDialog = 6 then Exit
    EndIf

Basically you can click the button which will send the message to the GUI so you're "compare loop" will need to check that message every once in a while to see if the button was clicked.

Edited by MrMitchell
Link to comment
Share on other sites

If the comparison process now slows down too much then update the progressbar and check $msg only every n-th exection of the loop.

Something like (for n = 100):

If Mod($i, 100) Then ...

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Another thing I just noticed is that the progress bar is on top of all other windows including your GUI and and any message boxes that pop up so maybe modify the ProgressOn() function to relocate the progress bar so it's not on top of your GUI.

Link to comment
Share on other sites

Could not Run the Script properly , the script was consuming a lot of CPU 78% and also the process bar was just flickering and not normal increment.

Please advise.

Thank you

If you haven't already, I think you need to take Water's suggestion and implement it. Do you want to post the new code?

Edit: Here's taking into account mine and Water's methods... Compare.au3

Edited by MrMitchell
Link to comment
Share on other sites

If you haven't already, I think you need to take Water's suggestion and implement it. Do you want to post the new code?

Edit: Here's taking into account mine and Water's methods... Compare.au3

Thank You MrMitchell and water , it did worked fine.

I forgot some coding on the script like

Dim $iNumber = 0 and so on...

Sorry

I learned few things today and yesterday thanks to you and to AIFM ( AutoIT Forum Members )

Now it's time for me to output the result for this script to Excel and intergrate the Process bar into the same GUI instead of another screen.

Thank you

Edited by PCI
Link to comment
Share on other sites

If you run into performance problems when populating Excel please post the code you use here (and the time it takes to process). There are some solutions available to speed up processing.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

If you run into performance problems when populating Excel please post the code you use here (and the time it takes to process). There are some solutions available to speed up processing.

Will Do , thank you water fot the great help as usual.

Thank you

Link to comment
Share on other sites

Thanks. But I just try to do my very best ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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