Anti sleep function (TestComplete, VBScript, LLPlayer)
Sometimes a PC goes to sleep, launches screensaver or locks the desktop during a long synchronization periods or other GUI inactivity periods, like generation of reports or batch processing. Adding the function below makes the script periodically moving mouse to avoid breaking of the execution. Place the call to the function within your time-consuming loops and custom synchronization functions.
Notes.
You may simulate mouse moves or clicks anywhere, depending on your needs. If your application has a response on mouse move events, make sure you position mouse cursor on safe areas, like window title or the Taskbar.
cgSleepTimeMax defines a max allowed inactivity period, in seconds. That is, if your screensaver goes on in 10 minutes, you should have cgSleepTimeMax set to 590 seconds or less.
Private Const cgSleepTimeMax = 300 ' 5 minutes Private cgAntiSleep_StopWatch 'Public Function cgAntiSleep() Dim Iter If DateDiff("s", cgAntiSleep_StopWatch, Time()) < cgSleepTimeMax Then Exit Function End If cgAntiSleep_StopWatch = Time() Call LLPlayer.MouseMove(100, 100, 100) For Iter = 100 To 120 Call LLPlayer.MouseMove(Iter, 100, 10) Next End Function
3 responses to "Anti sleep function (TestComplete, VBScript, LLPlayer)"
Wouldn’t it be better to turn off the screensaver for the duration of your test, then turn it back on when done?
It’s a pretty simple process.
Here’s how to do that with WinTask:
‘
‘ ScreenSaver – turn screen saver off during test, back on when done
‘
‘ Author: Joe Strazzere
‘
‘ Turn Screen Save OFF
‘
External(“user32.dll”,”SystemParametersInfoA”,17,0,0,0)
‘
‘ Your tests go here
‘
‘
‘ Turn Screen Save back ON (restores whatever settings were in effect)
‘
External(“user32.dll”,”SystemParametersInfoA”,17,1,0,0)
http://strazzere.blogspot.com/2005/01/wintask-screensaver.html
Would it be simple to do in TestComplete as well?
[ Albert’s response.
Hi, Joe, and thank you for contributing.
Yes, quite often it is better (and simpler!) to avoid a problem than putting heroic efforts resolving it later. And yet in this case turning off screensaver is not always sufficient.
* Turning off screensaver doesn’t prevent your computer from going to sleep (“stand by mode”).
* Turning off screensaver on a remotely accessed machine doesn’t affect settings of the client machine. These days, remote and virtual environments are used heavily, and all of my automation projects include robustness features specific for that. Screensaver is just one of them.
* It could also be a political / security question. For example, in large financial organization users are restricted to modify many system settings, including screensaver’s. In order to work, the script has to be run as a privileged user (i.e. “power user” or “local admin” level account), otherwise it will fail attempting to change the settings.
Thanks! ]
“in large financial organization users are restricted to modify many system settings”
Good point.
With having so much written content do you ever run into any problems of plagiarism or copyright violation? My blog has a lot of unique content I’ve either written myself or outsourced but it looks like a lot of it is popping it up all over the internet without my authorization. Do you know any techniques to help stop content from being ripped off? I’d genuinely appreciate it.
[ Albert’s reply.
Hi Steven,
Of course, any content published online is at risk, but if you spend too much time and effort fighting plagiarism, you can’t dedicate it to learning and writing.
If you occasionally stumble upon content taken from your site, and publsihed without proper credit given, you may try the following steps.
Some other content – like experience reports, or cross-connected articles, – bring value only on your original blog.
Ultimately, what’s the purpose of your blog? If plagiarism doesn’t affect the mission, you don’t need to worry much.
Thanks,
Albert ]