Jump to content

What do I wait for?


Recommended Posts

I have been tasked with automating a monthly data entry update into a Foxpro application. My script can open the app, open the input data files, parse the records into the required fields, find the proper record to update and move the fields to the proper text boxes. The problem I have is selecting the proper record set to update.

To select the proper record set, I have to select from drop down list boxes, the facility ID, start month, start year, end month, end year and measure set. Each time I select an option from any of the drop downs, the data window updates with a new record set. How do I know when the data window is finished and my script can proceed? (see attached)

I have tried:

WinTitleMatchMode=4, ControlShow, ControlCommand, WinWait, WinWaitActive, and WinWaitNotActive with combinations of Title, Class, and ClassNameNN.

The Active Window Info for the data window is:

Title: MHACO - Version: 4.6.0

Class: coremeas7c000000

Size: X: -4 Y: -4 W: 1032 H: 776

>>>>>>>>>>> Mouse Details <<<<<<<<<<<

Screen: X: 312 Y: 348

Cursor ID: 2

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<

RGB: Hex: 0xC0C0C0 Dec: 12632256

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Size: X: 6 Y: 106 W: 439 H: 369

Control ID:

ClassNameNN: AfxWnd422

Text:

(Control is hidden)

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<

Module Shortcuts

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<

The Class, and Visible Window Text does not change at all.

The Color of the data window does not change either.

How do I know when to proceed? Is there anything else I can check?

This one has me Stumped!

Thanks,

Glenn

Link to comment
Share on other sites

I think that the control is hidden somehow. I get this impression from the, "(Control is hidden)" after where it says what the text is. As a result, i think that showing the control may allow autoit to see what text is in it. The following code should enable the control:

ControlShow ( "MHACO - Version: 4.6.0", "", "AfxWnd422" )

For more information about these functions, look in the help file for:

ControlCommand

ControlDisable, ControlEnable, ControlFocus, ControlGetPos, ControlGetText, ControlHide, ControlClick, ControlMove, ControlSetText, ControlShow, StatusbarGetText, WinMenuSelectItem, WinGetClassList

I hope that was a start. :lmao:

The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

How do I know when to proceed? Is there anything else I can check?

You don't mention whether you have access to source, or whether modifying the behavior an option. One method I have used is to cause the foxpro app to pop up a windows message box when processing a new set of report criteria- enabling you to make the selection, wait for the dialog box to appear, then wait for it to go away, using a $max_wait value to ensure that if things happen really quickly I don't wait forever.

If modification of the application is out of the question, and no discernible clues indicate success, then you have two options:

1) use worst case wait times for sleep() statements after each criteria selection

2) Try the operation , and recover from the (presumably detectable [and hopefully non-fatal] ) failure mode that occurs if the app wasn't ready.

Edited by flyingboz

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

I think that the control is hidden somehow. ...

You are absolutely correct. Though it seems to remain hidden even after using ControlShow. I got the Window Info I pasted into my original post after running the following in my script.

$test = ControlShow("MHA Core Options - Version: 4.6.0", "", "AfxWnd422")
$msgval = MsgBox(262144,"Check attributes ", $test)
  Do
    Sleep(100)
  Until $msgval = 1

The ControlShow return value was 1.

...For more information about these functions, look in the help file for:

... I hope that was a start. :lmao:

The list did give me an idea to try. If I use ControlSetText then change a selection criterion, will the application change the text just set when it updates the data window? If so, I can use ControlGetText to check for the change.

Thank you.

You don't mention whether you have access to source, or whether modifying the behavior an option. ...

It is a third party application and I do not have access to the source code or even the database files. The only way we are allowed to update the records in through the application. My first choice would have been to load the data directly into the database.

... If modification of the application is out of the question, and no discernible clues indicate success, then you have two options:

1) use worst case wait times for sleep() statements after each criteria selection

2) Try the operation , and recover from the (presumably detectable [and hopefully non-fatal] ) failure mode that occurs if the app wasn't ready.

1) That's one option I would rather not employ. I already tried that and it makes it painfully slow.

2) The script continues and (almost randomly) changes the values in the drop downs to cause "record not found" conditions. Not too bad by itself but how do I if a drop down has an incorrect selection or it is a true not found condition without running into the same scenerio?

3) Another option is to have a user select the proper time frames and other criteria manually and click a button in a msgbox when the app is ready.

I'll let you know what the end solution is.

Thanks,

Glenn

Link to comment
Share on other sites

I have a question B540glenn, do the ControlSetText() and ControlGetText() functions work? If they do then you could have them check the control until it was completely filled. I am not sure exactly how that works, but i am betting that the control has blank boxes until it fills them with data. You could, like you said, therefore have it check to see if the control was filled with data. Once the script has determined that it is filled, you could have it edit the control.

$begin = TimerInit()
While 1
    If TimerDiff ($begin)> 1000 Then
        If ControlGetText ( "MHA Core Options - Version: 4.6.0", "", "AfxWnd422" ) <> "" Then Exitloop
        $begin = TimerInit()
    Endif
        sleep(20)
Wend
;fill out the control here

Not sure what the control returns when it has text, so you will have to mess with that. I used the TimerInit() and TimerDiff() functions since they are much better than using long duration sleep() functions and don't lock up the rest of the script.

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

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