Jump to content

[partially solved]I need a way to check if the script is still running and notify user.


Recommended Posts

this is my situation.

i am using a CDO object to send email and its working perfectly alright in autoit just like it would on vbs or asp

but just one thing,

while it is processing, i want the user to get a time to time display that he still has some time left for operation to complete:

the thing is that situation is like this

1) create the cdo object, get stuff from user , attach a file <milliseconds>

2) get file information and notify user of what is gonna be sent , like from / to adress etc <milliseconds>

3) send file using the settings <FEW MILLISECONDS TO FEW MINUTES DEPENDING ON ATTACHED FILE>

4) notify user that the mail is sent and release the objects. <milliseconds>

<> indicates approx time taken.

now, i want user to be notified that progress is taking place. i could easily use just a splash screen and then carry out the process then confirm the ending of the process but i want a progress timer to be displayed is this gonna be possible ????

Edited by rajeshontheweb
Link to comment
Share on other sites

yeah but realtime info is not available !

as i said,

i would be starting to work @ 00:00:001

1) will complete at 00:00:1200

2) will complete at 00:00:2450

3) will complete at 00:01:5500

4) will complete at 00:01:6750

now when the user is waiting between for about two minutes, i want some status display

if i set a tray tool tip, it just shows 00:00:2450 and doesnt execute anything else till 00:01:5500 :-(

Link to comment
Share on other sites

I think something like this should work for you:

#include<GuiConstants.au3>

guicreate("Timer", 50, 30)

$lbl = GUICtrlCreateLabel("", 3, 3, 100, 25)
GUISetState()

$timer = TimerInit()


While 1
    If  GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
    $time = TimerDiff($timer)
    GUICtrlSetData($lbl, Round(($time/1000),3))
    Sleep(10)
WEnd

Cheers,

tannerli

Link to comment
Share on other sites

heading home in a Blizzard right now... but may have an answer for ya when I get there.

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

Here is one way you can go about it...

_StartProgress("Sending Email") ; Put whatever comment you want for the progress bar

; Simulating your program still running while the email is being sent
$timer = TimerInit()
$seconds = 25
While TimerDiff($timer) / 1000 < $seconds
    Sleep(100)
    ToolTip("Been running for " & Int(TimerDiff($timer) / 1000) & " seconds")
WEnd

_StopProgress()

Func _StartProgress($s_comment = "Please Stand By")
    $s_path = @ScriptDir & "\progress.au3"
    $h_file = FileOpen($s_path, 2)
    $s_code = 'AutoItSetOption ("TrayIconHide",1)' & @CRLF & _
            'AutoItWinSetTitle("MyProgressBar")' & @CRLF & _
            'Dim $percent = 0' & @CRLF & _
            'ProgressOn("In Progress...", "' & $s_comment & '")' & @CRLF & _
            'While 1' & @CRLF & _
            'ProgressSet($percent)' & @CRLF & _
            '$percent += 5' & @CRLF & _
            'If $percent > 100 Then $percent = 0' & @CRLF & _
            'Sleep(500)' & @CRLF & _
            'WEnd' & @CRLF
    FileWrite($h_file, $s_code)
    FileClose($h_file)
    Run(@AutoItExe & " /AutoIt3ExecuteScript progress.au3", @ScriptDir)
EndFunc   ;==>_StartProgress

Func _StopProgress()
    If WinExists("MyProgressBar") Then WinKill("MyProgressBar")
    FileDelete(@ScriptDir & "\progress.au3")
EndFunc   ;==>_StopProgress

Basically what I am doing is making the script write and execute a second script that is just a progress bar, then killing that second script when you are done.

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

u read my mind , buddy

i came back here to ask how bad it would affect the overall course, how much overheads would it cost, to do such athing

coz i was gonna try this exact thing.

my thoughts were,

1) i was wondering if such an action would allow me to terminate the process / interrupt it because now i am using a com object model and any in-script termination commands or manipulations commands dont work till the control comes back from the COM object.

2) what u have shown above is exactly my picture in mind to show the progres bar. i am planning to show a timer or just a auto refilling progress bar to show that the software is currently running (exactly what i had in mind is what u have done there!) .

3) i have a sort of error handling functionality now designed based on the errrors i have come accross

viz., if GMAil server rejects the user name / password a typical error occurs - which is not understood by a specific error code but by the error text so what i am doing is capturing the output error.desc and reading it, basedon the error message, i am trying to give the user a better explanation of error (like the error returned would be simple ' Transport to SMTP Server failed' which should actually mean ' there was a problem communication to the server / user name or password was wrong!' )

the last is my most important concern if i try to run my sendmail module as a seperate application! thats why i have come back here to ask a question, is there a way i can capture the error as such. coz if it is an in-script module i can use ObjEvent("Autoit.error","XXX")

Edited by rajeshontheweb
Link to comment
Share on other sites

My first thoughts were to "try to run my sendmail module as a separate application" also. That way the Main script can keep working.

1 way...

Run has StdoutRead functions that can be utilized

2nd way...

@EXITCODE can be used for ther main prog to interpret

3rd way...

Have the Child Prog Write to a File And the main prog using Adlib to retrieve the message while the Child is running/ending

4th way...

Read memory...???

8)

NEWHeader1.png

Link to comment
Share on other sites

Link to comment
Share on other sites

just noticed your reply, mate

worst trouble is i am gonna give this script to a novice user and i donno about host environ other than it being win xp sp2

now, if fire wall blocks one exe or the other????

i need to think anyways i will sure give your thoughts a try and get back here in a couple of days

thanks a lot , mate

Link to comment
Share on other sites

a doubt,

before i start looking into multi threading or script calling another script,

is there any way like i had asked for , say i have the function sendmail() which is gonna run, but i need a function ShowProgress() which will be running entirely seperate. Is this possible at all?

My plan was to use something just like spookmiester showed. but the trouble is , Once the SendMail() is called its gonna use a CDO Object to send email to the GMail server and the control IS NOT returned back to the script till the process is complete !(even exit tray command doesnt work will process is complete.. - be it the inbuilt or custom made!)

i think someone is gonna say multi threading is the only way out, or two scripts , isnt it? then i will have to work. i am posting it here just in case there is some simple solution i am not aware of.

Link to comment
Share on other sites

alrite,

just had a closer look at spookmiesters code and found that it was what we were discussing here. i had a small problem thinking using SendEmail as a seperate script rather , he used the progress bar as a seperate script which is wonderfully good.

now , i got the script to work for me perfectly well, but still, the end user aint got autoit in his pc and again, i would think adding another exe is not an option due to reasons i have in mind.

i have come up myself with a best option i have in mind the simplest is using a windows animated cursor itself ! i would open a thread for that animated splash image if i have issues due to reasons i will state shortly.

i will get back here.. sorry for adding up posts one after another :-(

Link to comment
Share on other sites

would say solved, only for the case of using CDO Object send, which is gonna let the script remain totally in responsive till the process is complete, i am try using the above model or try adlibenable and show a progressbar. i know it is gonna cost me few milliseconds 4 times every second, but i think i would have no option as the process itself is very time consuming and it is gonna be non responsive for sure...

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