Suilven Posted March 23, 2010 Share Posted March 23, 2010 Hi all, I'm new to AutoIT, so apologies if I should have found the answer elsewhere (I did look, honest!). I'm using the current AutoIT3 and Scite and trying to automate a Lotus Notes application. I'm doing this across an RDP link, if that is relevant. I think I have 2 problems - 1) Can I slow the execution of the script down? It seems to be too quick for poor old Notes to get some of the field data sometimes. 2) Sleep(5000) seems to be ignored sometimes and messageboxes do not always wait the 10 seconds that I ask. It is inconsistent with the same script behaving differently on different runs. I have tried to create a small script that shows this behaviour but can never get anything that is consistent. Any pointers or ideas (or RTFM comments) will be deeply appreciated. TIA Dave Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 23, 2010 Share Posted March 23, 2010 at the top of your script you can put Opt("SendKeyDelay", 45) 45 can be changed to any number you wish, it is the delay in milliseconds between automated key presses. Also instead of using sleeps, maybe controlclick, controlsend, winwait? 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Suilven Posted March 23, 2010 Author Share Posted March 23, 2010 at the top of your script you can putOpt("SendKeyDelay", 45)45 can be changed to any number you wish, it is the delay in milliseconds between automated key presses. Also instead of using sleeps, maybe controlclick, controlsend, winwait?kaotkbliss,Many thanks - I totally missed the SendKeyDelay option, so I'll try that straightaway. re Sleep(), at one point, I have to wait until Notes sends some data back to the screen. Unfortunately with Notes, controls and text are mostly invisible to AutoIT and the window caption does not change, so I want to wait 60 seconds before restarting the script. Without Sleep(), what's a good way of putting that order of delay into the system?TIA Dave Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 23, 2010 Share Posted March 23, 2010 if winexists or winwaitactive? depending on how notes works 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Suilven Posted March 23, 2010 Author Share Posted March 23, 2010 if winexists or winwaitactive? depending on how notes worksThat was my first try, but AutoIT sees no change in the window between the state when I press a Notes button to ask the server for an id and when the id appears on the screen. The discovery tool reports exactly the same parameters for both states. I've looked at controls, visible text and invisible text. My only hope is to wait 60 seconds. Sleep(60000) should be the answer but seems buggy. Do others see it as buggy/inconsistent? Or is this me misinterpreting the symptoms?Notes, BTW, is to be avoided like WW3. Goodness knows how it works, when it works. My job is to hide the whole system from users so they can have their lives back )Thanks for you help. Dave Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 23, 2010 Share Posted March 23, 2010 so when Notes is done doing whatever it is doing, there is no change in the window? If there is even a text change that wingettext or a button that becomes dissabled or enabled then maybe controlcommand? 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Suilven Posted March 23, 2010 Author Share Posted March 23, 2010 I can see no change with the Find Tool. Is that using WinGetText? I might try that directly and see, but almost all windows text is invisible to teh Find Tool. Notes has its own GUI and is a bit like a browser in the way it reorganises the window if resized. But, as I write, I'm wondering if the text is on a child surface. I've got WinSpy somewhere here - I'll poke around with that. But what about Sleep()? I can't imagine this is broken when it would be a straight win32 call. Does anyone else have problems with timings or am I barking up the wrong tree? Dave Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 23, 2010 Share Posted March 23, 2010 Sleep does seem to be funny. I created a program to keep track of how much time was spent on a project and in 1, 8 hour work day it recorded 10 hours of work 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
jchd Posted March 23, 2010 Share Posted March 23, 2010 @Suilven Welcome to the forum. I just tried the test below and it does give very consistent results for me, either local or running thru a TS session (XP x86 SP3 everywhere). Local $t For $i = 1 To 24 ConsoleWrite("start" & @LF) $t = TimerInit() Sleep(5000) ConsoleWrite("stop - start = " & TimerDiff($t) & @LF) Next I tried various sleep values and, beside a small variation and overhead of other calls, they work as expected for me. @kaotkbliss How do you count time using Sleep()? @both It would be interesting to post a sample creipt where Sleep() clearly fails, in order to track down the issue. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
kaotkbliss Posted March 23, 2010 Share Posted March 23, 2010 @jchd I don't but I assume that both sleep and timer functions use the same timekeeping method (a count to 10 ms in one is the same as a count to 10 ms in the other) 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
jchd Posted March 23, 2010 Share Posted March 23, 2010 That's true but Sleep introduces a delay in the flow of your program and I'm just curious about how you can use it for timing run time. I believe TimerInit / TimerDiff is better suited for such measurement. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Suilven Posted March 23, 2010 Author Share Posted March 23, 2010 @Suilven Welcome to the forum. I just tried the test below and it does give very consistent results for me, either local or running thru a TS session (XP x86 SP3 everywhere). Local $t For $i = 1 To 24 ConsoleWrite("start" & @LF) $t = TimerInit() Sleep(5000) ConsoleWrite("stop - start = " & TimerDiff($t) & @LF) Next I tried various sleep values and, beside a small variation and overhead of other calls, they work as expected for me. @kaotkbliss How do you count time using Sleep()? @both It would be interesting to post a sample creipt where Sleep() clearly fails, in order to track down the issue. Well, it is very reassuring NOT to hear anyone else having trouble with Sleep(). I have tried to create a small example that fails consistently but I cannot create one. When it fails, it fails totally, so a 10 seconds sleep() is just ignored or a messagebox with a 5 second wait in it just blinks before disappearing. The same script will work sometimes and at other times fail. The work I did on the previous AutoIT version did not show this problem, so I'm going to reinstall, just in case. Would have done this sooner but I have to cajole someone at the client end to do the work... Thanks for everyone's help on this - makes a big difference when you know you're not on your own! Dave Link to comment Share on other sites More sharing options...
jchd Posted March 23, 2010 Share Posted March 23, 2010 Not being left alone Sleep($ing) in the dark in the whole purpose of a forum.More to the point: can you have it fail in a local session (no TS)? FYI, my test were only on a LAN, no Wan/VPN/you-name-it involved.Which OS do you run and could it be a virtualization side-effect? (I'm not GRU nor KGB, just trying to understand!) This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
IchBistTod Posted March 23, 2010 Share Posted March 23, 2010 (edited) Proposed solution:Very low cpu usage ~9MS off using sleep(not relative to amount of time).func _Sleep($ms) $timer = timerinit() while timerdiff($timer) < $ms sleep(1) wend endfuncMax CPU usage, exact time, down to the nanosecond(not relative to amount of time).func _Sleep($ms) $timer = timerinit() $ms = (($ms-0.1)+0.07) while timerdiff($timer) < $ms ;nothing wend endfunctell me if you have any luck with it.Green= My SleepRed=AU3 SleepTest(1000ms):1000.001079622091001.009602774941000.002566351741000.003592892441000.00102654071000.006672514531000.00256635174999.9840886192051000.001106162791000.008725595921000.0010265407999.2978461636381000.0010265407999.9989734593041000.00153981104999.9938407558211000 <<<<<<<<<<<<<<<< PERFECT!1000.017451191841000.003592892441000.000513270351000 <<<<<<<<<<<<<<<< PERFECT!999.9096644187141000.001539811041000.015398110451000.00205308139999.9938407558211000 <<<<<<<<<<<<<<<< PERFECT!1000.012831758711000.001539811041000.00564597383Test(30000ms):30000.00153981130011.338655262530000.001026540730003.294169094930000.002053081430008.3391033475as you see my sleeps are never more than ~.003 off where as AU3 sleeps can be up to ~1.0 off on a simple 1 second sleep.AU3 sleep shows much variation so when used for larger amounts of time,it can be very inaccurate.AU3 sleep is offset relevant to the amount of time the sleep is called for, neither express this attribute. Edited March 23, 2010 by IchBistTod [center][/center][center]=][u][/u][/center][center][/center] Link to comment Share on other sites More sharing options...
Suilven Posted March 24, 2010 Author Share Posted March 24, 2010 Proposed solution: Very low cpu usage ~9MS off using sleep(not relative to amount of time). func _Sleep($ms) $timer = timerinit() while timerdiff($timer) < $ms sleep(1) wend endfunc Max CPU usage, exact time, down to the nanosecond(not relative to amount of time). func _Sleep($ms) $timer = timerinit() $ms = (($ms-0.1)+0.07) while timerdiff($timer) < $ms ;nothing wend endfunc tell me if you have any luck with it. Green= My Sleep Red=AU3 Sleep Test(1000ms): 1000.00107962209 1001.00960277494 1000.00256635174 1000.00359289244 1000.0010265407 1000.00667251453 1000.00256635174 999.984088619205 1000.00110616279 1000.00872559592 1000.0010265407 999.297846163638 1000.0010265407 999.998973459304 1000.00153981104 999.993840755821 1000 <<<<<<<<<<<<<<<< PERFECT! 1000.01745119184 1000.00359289244 1000.00051327035 1000 <<<<<<<<<<<<<<<< PERFECT! 999.909664418714 1000.00153981104 1000.01539811045 1000.00205308139 999.993840755821 1000 <<<<<<<<<<<<<<<< PERFECT! 1000.01283175871 1000.00153981104 1000.00564597383 Test(30000ms): 30000.001539811 30011.3386552625 30000.0010265407 30003.2941690949 30000.0020530814 30008.3391033475 as you see my sleeps are never more than ~.003 off where as AU3 sleeps can be up to ~1.0 off on a simple 1 second sleep. AU3 sleep shows much variation so when used for larger amounts of time,it can be very inaccurate. AU3 sleep is offset relevant to the amount of time the sleep is called for, neither express this attribute. Thanks for all the ideas. I'm working on something else today while AU gets reinstalled. But I'll be back to let you know how it pans out. Thanks again, Dave 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