jonnybignote Posted July 16, 2009 Share Posted July 16, 2009 Hi all sorry for rudimentary request but am stuck on simple wait for window, hit return(get out of antivirus advert window) Current code gives high cpu utilisation WinWaitActive ("Notifier of Avira AntiVir Personal - Free Antivirus") Send("^{Return}") I know I need to put some kind of wait/sleep function as this is intended to run all the time and probably some kind of loop so code keeps on running but I'm getting nowhere fast Thanks Link to comment Share on other sites More sharing options...
LurchMan Posted July 16, 2009 Share Posted July 16, 2009 (edited) Hi all sorry for rudimentary request but am stuck on simple wait for window, hit return(get out of antivirus advert window) Current code gives high cpu utilisation WinWaitActive ("Notifier of Avira AntiVir Personal - Free Antivirus") Send("^{Return}") I know I need to put some kind of wait/sleep function as this is intended to run all the time and probably some kind of loop so code keeps on running but I'm getting nowhere fast Thanks try this: Opt("WinTitleMatchMode", 2) While 1 WinWaitActive ("Notifier of Avira AntiVir Personal - Free Antivirus") Send("^{Return}") Sleep (100) WEnd This will make it an infinite loop and the Sleep(100) will drop CPU utilization dramatically, and the opt wintitlematchmode will make it so it will match any substring of the window title. Edited July 16, 2009 by LurchMan Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
UberNuss Posted July 16, 2009 Share Posted July 16, 2009 jonnybignote - The snippet you posted should not hog your CPU - post the entire relevant parts of your code so that we may examine it and find the real problem. Das Häschen benutzt Radar. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 16, 2009 Share Posted July 16, 2009 There is no way to force WinWaitActive to increase it's sleep. You need to build something that works the same way, like this:Do Sleep(50) Until WinActive("Notifier of Avira AntiVir Personal - Free Antivirus") Send("^{Return}")BUT!! There are a much easier way to disable the Avira Antivir nag screen, see http://www.elitekiller.com/files/disable_antivir_nag.htm .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
jonnybignote Posted July 16, 2009 Author Share Posted July 16, 2009 First - thanks to all you guys for posting replies - much appreciated. Opt("WinTitleMatchMode", 2) While 1 WinWaitActive ("Notifier of Avira AntiVir Personal - Free Antivirus") Send("^{Return}") Sleep (100) WEnd No change with this unfortunately... The snippet you posted should not hog your CPU - post the entire relevant parts of your code so that we may examine it and find the real problem.That was the entire script... There is no way to force WinWaitActive to increase it's sleep. You need to build something that works the same way, like this: [ autoIt ] ( Popup ) Do Sleep(50) Until WinActive("Notifier of Avira AntiVir Personal - Free Antivirus") Send("^{Return}") BUT!! There are a much easier way to disable the Avira Antivir nag screen, see http://www.elitekiller.com/files/disable_antivir_nag.htm Thanks! - that code brought it down to 1-2% which is much more manageable - however I think I'll go with your other solution to avoid it altogether. Thanks again all as this helps me understand better for my future scripting projects! Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 16, 2009 Share Posted July 16, 2009 Thanks! - that code brought it down to 1-2% which is much more manageable - however I think I'll go with your other solution to avoid it altogether. Thanks again all as this helps me understand better for my future scripting projects!No problem. I use Avira Antivir myself so I know how irritating the nag sceen can be .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface 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