boji Posted June 24, 2009 Share Posted June 24, 2009 (edited) Hello, thank you for any response you may have. I am running a slow database, and I have autoit doing some data entry to multiple fields within the slow program. My quesiton is this: How would I go about pausing (throttleing) the script, to wait for the program to finish populating a field? I have used winwaitactive when bounceing between two windows, but I would rather not lose focus of the window I am waiting for. Any help would be appriciated. Thanks! Edited July 1, 2009 by boji Link to comment Share on other sites More sharing options...
picea892 Posted June 24, 2009 Share Posted June 24, 2009 interesting question. I think I have a good idea Pause the script in a do until memory usage drops below a certain level, periodically query the memory usage of the associated process using ProcessGetStats or MemGetStats Set a bench mark. When the memory usage drops below a certain level, assume the program processing is completed and let the script continue Link to comment Share on other sites More sharing options...
boji Posted June 24, 2009 Author Share Posted June 24, 2009 Thanks for the quick reply. I like that idea. But it seems...excessive. I would like to imagine that any program that needs to wait to perform an internal task sends a call to windows to lock the gui from being painted, then releases it after the work has been performed. If we could capture those calls, then I would have the throttle I need. Trouble is I am so new to programming I have no knoweldege on where to look for those calls (somewhere in the user32.dll I imagine) or how to exploit it to my desired effect. Thanks again. Link to comment Share on other sites More sharing options...
picea892 Posted June 24, 2009 Share Posted June 24, 2009 I agree, that is the preferred solution. Until someone comes along and provides it I'll bounce one more option of you. I'm guessing the cursor changes when it is processing. Query the cursor using MouseGetCursor( ), when it changes to an arrow it is done Link to comment Share on other sites More sharing options...
boji Posted June 25, 2009 Author Share Posted June 25, 2009 Heh, nice. That might just work. It will be a roundabout way to establish unlocked active focus, but who cares, the progam I'm writing to is so slow anyway. Thanks for the idea. If anyone has a nuts and bolts approach to this problem, im all eyes, bump! Link to comment Share on other sites More sharing options...
boji Posted June 29, 2009 Author Share Posted June 29, 2009 Babump! Link to comment Share on other sites More sharing options...
boji Posted June 30, 2009 Author Share Posted June 30, 2009 Mouse cursor thing is cool, will use it perhaps in other situations, however in the case of this database, it simply dissapears, autoit sees it as not changing. So back to square 1. Bump! Link to comment Share on other sites More sharing options...
picea892 Posted June 30, 2009 Share Posted June 30, 2009 (edited) How does the program/database notify you that processing is done? Does it write text in a window, does it pop up a box. What happens? I was guessing that the icon would change if that's not the case, what happens? If it writes text in the window, you can query for that text. Is the field empty before it populates it. If so that is easy to check if empty or not. Use control read related function I am surprised that no one has provided a better solution than the ones I have given. There has to be someway which both of us have overlooked. These are only hacks, I'm interested to see what the answer truly is...... [Edit] Change your title to something more applicable to your request, it might attract more attention. Edited June 30, 2009 by picea892 Link to comment Share on other sites More sharing options...
boji Posted July 1, 2009 Author Share Posted July 1, 2009 Thanks picea for your continued intrest and help. I changed the title a bit. About notification- that's the thing, no "notification" is given, you enter info, leave field with either tab or mouse click, and it just slowly populates and then unlocks the cursor into the next field you want to go to. I can take focus away, and ask for window focus back again with a winwaitactive and that works, just seems like a ugly way to do it. Here's a snippet of the bandaid. I think these autoit gurus won't respond unless they have a crappy piece of code to balk at. Perhaps the secret lies in taking a close look at the WinWaitActive udf. CODE Func parts_prep() Local $cg = clipget() If StringIsInt($cg) And StringLen($cg) = 6 Then If Not WinActive("Order Entry","") Then WinActivate("Order Entry","") WinWaitActive("Order Entry","") ControlSend("Order Entry", "","",$cg&"{ENTER}") _bounce("Order Entry") ControlSend("Order Entry", "","","{ENTER}{ENTER}newa1{ENTER}") _bounce("Order Entry") ControlSend("Order Entry", "","","def{ENTER}") _bounce("Order Entry") ...ect ect Func _bounce($windowz) WinActivate("Program Manager","") WinWaitActive("Program Manager","") WinActivate($windowz,"") WinWaitActive($windowz,"") EndFunc Link to comment Share on other sites More sharing options...
ResNullius Posted July 2, 2009 Share Posted July 2, 2009 (edited) About notification- that's the thing, no "notification" is given, you enter info, leave field with either tab or mouse click, and it just slowly populates and then unlocks the cursor into the next field you want to go to.Does the Au3Info tool actually show you control names/classes for the input fields?And when you say "unlocks the cursor" what do you mean exactly? Is the next field disabled and only becomes enabled once the field you're waiting on becomes populated?Or does the cursor simply disappear, and shows up in the next field once population has occurred? Edited July 2, 2009 by ResNullius Link to comment Share on other sites More sharing options...
Inverted Posted July 2, 2009 Share Posted July 2, 2009 (edited) Damn, it's too boring to read all these posts, but if the problem is only in sending keystrokes, then you can use the SendKeyDelay option to allow the slow proggy more time to process it, update its interface (?) Or you can use Sleep to give it more time. Or if the slow program is actually "doing something", maybe you can set your script to Idle priority. And maybe even set the slow proggy to higher. Edited July 2, 2009 by Inverted Link to comment Share on other sites More sharing options...
boji Posted July 7, 2009 Author Share Posted July 7, 2009 ResNullius - Thank you for your reply!"Does the Au3Info tool actually show you control names/classes for the input fields?"That's the rub. It's a child window and auinfo box populates, but running control clicks based on auinfo's "info" crashes the prog occasionally. And when you say "unlocks the cursor" what do you mean exactly?The program is a node on a server and it's hella slow. I mean the server "calls back" with updated info, refreshes the screen, lets you move on.Is the next field disabled and only becomes enabled once the field you're waiting on becomes populated or does the cursor simply disappear, and shows up in the next field once population has occurred?The latter. Wait. Actually Both! Inverted - Thanks as well for responding...or you can use Sleep to give it more time.Or if the slow program is actually "doing something", maybe you can set your script to Idle priority. And maybe even set the slow proggy to higher.I'd like the compensation to reflect the non-linear wait times that the program exhibits. Since sleep is linear, sometimes the wait is excessive and sometimes it is too short; the only remedy for that of course is to extend the sleep past all possible wait times which is a yucky solution.I'd like to know if interpreting dll calls would be of benefit. Other than that I think I have found the least unpleasant solution, which involves using WinGetCaretPos()If I know the 'pre-populated' coordinate of the caret in the present field, and know the coordinate to the caret in the new field prior to it's arrival there, then ding! throttle solved. Still want to learn more about dll calls tho. Anyone point me in a good direction? Thanks. Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 7, 2009 Share Posted July 7, 2009 ...I think I have found the least unpleasant solution, which involves using WinGetCaretPos()If the current focus of the GUI changes then you could monitor ControlGetFocus() until the one you wanted received focus. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
boji Posted July 8, 2009 Author Share Posted July 8, 2009 If the current focus of the GUI changes then you could monitor ControlGetFocus() until the one you wanted received focus.Thanks, I'll def take a look at what the focus does, see if that would work. My hunch is no, the focus does not change. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now