Sign in to follow this  
Followers 0
AutoITnewbee

MsgBox Pops Up Too Soon

4 posts in this topic

I have an AutoIt script that is displaying a msgbox too soon (before the preceeding task has completed processing).

My script starts by running Adobe Framemaker and passing it a filename. Once Framemaker is launched with the desired file loaded, the script Sends() a series of keystrokes (simulating the various steps a person would manually perform when processing the file inside of Framemaker).

At the very end of the script I need to display a msgbox that notifies the operator that the Framemaker file is done processing.

Unfortunately, the msgbox at the very end of my script is displaying prematurely (it's not waiting for Framemaker to finish processing).

FYI: I've read posts about using RunWait(). But it seems like RunWait() is geered more for controlling the run order between apps (i.e. run Notepad.exe first, then when that's done, run calculator.exe). In my case, I only have one app (Framemaker.exe). But within that one app, I am performing a series of sequential steps (some of which take 20 minutes to finish processing before going onto the next step).

How do I force AutoIt to wait for a step to complete before going onto the next step (all within the same app)?

FYI: I tried using the Sleep() command in between the last processing step and my "Process Complete" msgbox. Although it worked when processing my small Framemaker test file (the Sleep delay was for 2 minutes), it failed when processing a much larger Framemaker test file (it displayed the "Process Complete" msgbox while Framemaker was still processing the file). After I pressed OK to the "Process Complete" msgbox, Framemaker then continued processing the file.

How do I tell AutoIt to wait for Framemaker to finish processing the file, THEN display the "Process Complete" msgbox?

Please help... because without a solution to this timing issue, I won't be able to use this awesome script in Production! :-(

Thank you.

Share this post


Link to post
Share on other sites



AutoITnewbee,

Welcome to the AutoIt forum. ;)

You need to find something in the Framemaker GUI which changes when the processing is finished and then use that as the trigger for your MsgBox. :)

Is there a button which changes colour or text? Does the status bar alter? Is the window title changed? You get the idea. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Or can you make a check for eg

If FileExists("well known windows file in system32 folder") Then MsgBox (0, "Etc", "Etc")

It dosent have to be relevant to your script just something to tie the msgbox at the end

right at the last thing?

Chimaera

Edited by Chimaera

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

you could wait for the process usage to drop below a threshold, then have that kick off the messagebox.

My example is for firefox,

open up a bunch of tabs (such that you are over 170,000k on Mem Usage)

start closing them and when it drops under the threshold it should pop a message box displaying usage.

Global $MemUsage , $x

_RUN()

Func _Check()
If $x = 1 Then
    _RUN ()
    EndIF
EndFunc


FUNC _Run()

_checkproc()
If $Memusage < 170000000 Then
    msgbox (0, '' , "Memory Usage " & $Memusage)
    $x = 0
else
    sleep (500)
    $x = 1
    _Check()
Endif
EndFunc


Func _Checkproc()
    $wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"

$Output=""
$Output &= "Computer: " & $strComputer  & @CRLF
$Output &= "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfProc_Process Where Name='firefox'", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

   For $objItem In $colItems
      Global $MemUsage = $objItem.WorkingSet
  Next

EndFunc
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
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
Sign in to follow this  
Followers 0