Running Ad-aware

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
mo
Junior Coder
Posts: 49
Joined: Thu Aug 21, 2003 11:02 pm

Running Ad-aware

Post by mo » Tue Aug 26, 2003 2:20 am

Hello,

I thought I would venture into this another step today and set up one piece of a "Clean-Up" routine I perform almost every night. The part was to run Ad-aware. The below works fine (it does not yet check for updates, but that is another day) but brings me up against two problems:

1. I could not figure out how to get it to run just using keystrokes. I could bring what looked like the focus to a button with tabs or left or right, but pressing enter did not (does not) activate that button. The only thing that seems to activate the button is the mouse. Has anyone figured out what the keystrokes are to get this running with only keystrokes?

2. How does one close a program that may take an irregular amount of time to perform it's task?


//
//Set variables
//
Let>WW_TIMEOUT=5

//
//Start Ad Aware
//
Change Directory>F:\Program Files\Lavasoft Ad-aware\Ad-aware 6
Run>Ad-aware.exe
WaitWindowOpen>Ad-aware 6.0 Personal

//
// Ensure it always opens with the same dimensions
//
MoveWindow>Ad-aware 6.0 Personal,302,311
ResizeWindow>Ad-aware 6.0 Personal,420,145

//
// Focus the app
//
SetFocus>Ad-aware 6.0 Personal


//
//Miscellaneous
//
CapsOff


//
//Scan for badguys
//
MouseMove>409,528
WaitWindowOpen>Ad-aware 6.0 Personal
MoveWindow>Ad-aware 6.0 Personal,162,170
ResizeWindow>Ad-aware 6.0 Personal,700,428
MouseMove>269,341
Wait>.5
LClick
Wait>0.5
MouseMove>760,546
Wait>.5
LClick
Wait>.5


PS: I'm having no trouble at all using MS with TextPad, they work together beautifully.
Question: Why are we not capable of recording/running Macros from within the MS Editor?
Best Wishes!
mo

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Aug 26, 2003 3:48 am

You ask:
2. How does one close a program that may take an irregular amount of time to perform it's task?
That will vary with every program. Let me make some observations about your script for Adaware.

1. It looks like this is a recorded script. You can remove most of the WindowMove and WindowSize commands.

2. Try to find Key commands vs. mouse movements. Here is an example of the flow, without the exact commands:

//Start Program
Run Program
WaitWindowOpen>AdAware*
Set Focus
WaitReady>1

//Activate buttons (Tabbing works, but Press Enter doesn't work. Move mouse instead).
MoveMouseRel to Start Button, LeftCLick (or maybe PushButton?)
MoveMouseRel to Next Button, left Click (or maybe PushButton?)

//Loop Until Scanning is done
Label>LoopForText
FindWindowWithText>Scan Complete
IF %result% = NOT FOUND, go to LoopForText, else continue

//This next section assumes data found. Need to add lines if not found. FindWindowText for both will probably be best here).
//Review data to be deleted
MoveMouseRel to Next Button, left Click
Wait> for ?? minutes allowing you to toggle checkmarks or accept them

//Delete selected data
MoveMouseRel to Next Button, Left Click
PushButton>AdAware6,OK

//Wait until processing is completed.
WaitWindowClosed>Deleting Section

//Close Adaware
Press ALT
Press F4
Release ALT

NOTE: This is untested, just a quick glance at AdAware screens as I stepped through manually. Assumes configurations are already set, not doing update for latest file, etc.

Some methods to determine if a process has completed: wait for a specific window name to close or open, you can look for a window with specific text, or look at a pixel or recatangle to see if it has changed. Get pixel color before starting final process step, then loop until it has changed. Sometimes certain menu options may/maynot be available, so you can try those commands and loop until they open up a new window or something similar to that. Look at the pixels of the command that is greyed out until the process is completed.

Hope these quick ideas will help, no time to work on specific code right now.

3. After using Macro Recorder, edit the file and remove the waits, mouse moves, etc.

4. After you work with MS a while you won't even use the recorder, it will be easier and faster just to write the script.

5. Common problem for beginners to avoid is trailing spaces on lines. Remove them if not needed. They causes variables, labels, sub routines, etc. to fail. There is an option in Editor to use: Edit, Remove Trailing Spaces. And Edit, Show all Characters will also be helpful.

6. Good on line help with examples for all commands referenced above. Check them out and see what works for you. Continue to submit code as working on it, lots of help here.

7. Follow beginning flow chart like above, and fill in commands and test sequentially. Use Single Step, Show Watch List. Use Tools, View System Windows to get window names. Jump to End and run with logging turned on. Lots of help to diagnose issues.

Hope this helps...................good luck,
Bob

mo
Junior Coder
Posts: 49
Joined: Thu Aug 21, 2003 11:02 pm

Post by mo » Tue Aug 26, 2003 4:09 am

Great help! Thanks.

Yes this was partly recorded...recorded bits to see what it was doing, try to solve the problem of getting the buttons to work (didn't solve that one).

Another bit that's coming up is going to be the "if" business: if after checking for an update there is an update, download and install, if not finish (this part I've got...but I need to wait for an update to be available to see what Ad-Aware is doing.
Best Wishes!
mo

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Aug 26, 2003 6:49 am

Perhaps run it manually now to understand operation when no updates? Write script to support that condition now.

Then when updates are avaiable, you will be able to put in an "IF" branch for doing updates.. right now you can define the branch for no updates......Final routine will test for updates and branch based on results.

:idea: Hmmm..... can you change the date of the data file to fool Adaware to think an update is needed? Look in the folder for AdAware for a file named reflist.ref and see if changing the date of the file can fool AdAware?

:idea: There may also be a backup copy of the previous reference file that you could use to replace the current one. It may be named reflist.ref.old. Check the AdAware settings, Click to Check for updates now. When the Performing Web Update window opens, click on Configure. If there is a checkmark in Misc-Backup old reference file, you probably have a backup copy. You may be able to temporarily rename the current file and replace it with the backup file as another way to fool it into doing an update.

Just a thought......

mo
Junior Coder
Posts: 49
Joined: Thu Aug 21, 2003 11:02 pm

Post by mo » Wed Aug 27, 2003 2:40 am

Below is my latest version of this script. Not much changed from the previous version, I have deleted excess "MoveWindow" and "ResizeWindow" commands. But one of the comments in the previous was: "After using Macro Recorder, edit the file and remove the waits, mouse moves, etc." which I do not yet understand, as this would result in everything the macro recorder had done being removed. I think the previous post gives a solution to the problem that the buttons do not respond to keystrokes (at least to the ones I have tried)(but I do not understand the idea), so I need to use the mouse...which to my mind means to include the "mouse moves". Or is the idea that by giving a relative position, all I need to do is to give the coordinates? A precise example here would help.

This script runs OK up to line 83, the Loop (or, see next, possibly up to line 114, Close program). With the Loop and the close program lines both in, the program gets all the way to the scanning process, begins the scanning process and then closes after checking only about 600 objects (of some nearly 50,000). The actual final window reads "Scan complete" I have tried it that way and with "Scan Complete".

If I only comment out the close routine the program continues to the end of the scan...but of course doesn't close. (Also, I am unable to abort the process as it begins the scan again if I do -- a little tiresome!)

Please do not feel any pressure to respond quickly to my posts. I am not under any pressure myself to get this done. I will keep at it and it seems to me it might be helpful as another beginner's tutorial when complete.

As a PS...this all is making me think that what I really want to be doing is learning programming period. I have got the book: "Learning to Program C++ by Steve Heller (a little sappy for my taste...but probably right for my level of understanding "zip nada")...and I would appreciate any words of wisdom concerning books to learn from and recommended compilers. I have the GNU compiler on my Linux box (Debian -- six months of hair pulling and table pounding, but I managed to get a working server up and running stable now for almost a year), but I want a commercial compiler for Windows and I need a good one because I am of an age where I need all the advantages just to retain my position at the bottom of the pile! I am tending to shy away from the Microsoft package.

best wishes!

mo

============================================================


//
//Run Ad-aware, one part of a multi-part clean-up routine.
//Tuesday, August 26, 2003 6:59 PM
//NOTE: Not yet set for accepting available updates!
//Assumes Ad-aware is configured for the scan desired.
//


//
//Set variables
//
Let>WW_TIMEOUT=5

//
//Start Ad Aware
//
Change Directory>F:\Program Files\Lavasoft Ad-aware\Ad-aware 6
Run>Ad-aware.exe
WaitWindowOpen>Ad-aware 6.0 Personal

//
// Ensure it always opens with the same dimensions
//
MoveWindow>Ad-aware 6.0 Personal,302,311
ResizeWindow>Ad-aware 6.0 Personal,420,145

//
// Focus the app
//
SetFocus>Ad-aware 6.0 Personal


//
//Miscellaneous
//
CapsOff


//
//Check for Updated database. Does not include routine for downloading
//and installing updated database
//
WaitWindowOpen>Ad-aware 6.0 Personal
MoveWindow>Ad-aware 6.0 Personal,162,170
ResizeWindow>Ad-aware 6.0 Personal,700,428
Wait>0.5
Press Right * 8
Wait>0.5
MouseMove>767,245
Wait>0.5
LClick
WaitWindowOpen>Lavasoft Ad-aware 6.0
Wait>0.05
MouseMove>640,489
Wait>0.5
LClick
WaitWindowOpen>Ad-aware 6
Wait>0.5
MouseMove>554,424
Wait>0.5
LClick
WaitWindowOpen>Lavasoft Ad-aware 6.0
MouseMove>631,482
Wait>0.5
LClick
WaitWindowOpen>Ad-aware 6.0 Personal
Wait>1.11

//
//Scan for badguys
//
WaitWindowOpen>Ad-aware 6.0 Personal
MouseMove>269,341
Wait>0.5
LClick
Wait>0.5
MouseMove>760,546
Wait>0.5
LClick
Wait>0.5

//
//Loop til scanning is completed
//
Label>LoopForText
FindWindowWithText>Scan complete
If %result% = NOT FOUND, Goto LoopForText, else continue


//
//Routine for deleting bad guys
//commented out until I get a badguy to see how it goes
//copied from R.Hanson's suggestions, not understood!
//
////This next section assumes data found. Need to add lines if not found
////FindWindowWithText for both will probably be best here
////Review data to be deleted
//MoveMouseRel to Next Button, left Click
//Wait> for ?? minutes allowing you to toggle checkmarks or accept them


////
////Delete Selected data
////
//MoveMouseRel to Next Button, Left Click
//PushButton>Ad-aware 6.0 Personal,OK
////
////Wait until processing is completed
////
//WaitWindowClosed>Deleting Section (?Selections)


//
//Close Ad-aware
//
Press ALT
Press F4
Release ALT
Best Wishes!
mo

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Aug 27, 2003 3:30 am

Hello mo......

I have copied your script and will try to look at it over the next few days.

For your information, I checked for AdAware updates and there was one with today's date (8/26/03) that was downloaded. so you may be able to run through manually, or put on recorder to record window names, etc. while you do it manually. I know the updates are not that frequent. Save the recorded macro under a new name, then you can edit, cut and paste it into your main script as part of the IF branch......

An example of relative mouse movements would be:
//Move mouse to Start Button
MouseMoveRel>585,465
LClick
Wait>1

//No need to Move mouse to Next Button, it is in same position, but should probably do anyway, in case of accidental vibration, mouse movement.
MouseMoveRel>585,465
LClick
Wait>1

//Move to OK Button
MouseMoveRel>300,250
LClick
Wait>1

Actual numbers will change based on resolution, font, size of window, etc. I find it best to maximize window before doing MouseMoveRel moves. (I almost always use MouseMoveRel vs. MouseMove). Then use the numbers from the Macro Scheduler Cursor Monitor. Seems to give me more consistent results. I am also in the habit of entering Wait>n after many mouse movements and Send> commands. These can probably be eliminated, but speed is not my usual issue. Accuracy is always more important to me than speed.

Stay tuned.......

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Aug 27, 2003 6:22 am

Hello mo......

Here is your script with my modifications. A few notes:
1. We have different versions of AdAware, so I made variables for your tests and mine.
2. Removed all the WaitWindowOpen commands, not really needed.
3. Maximized window to get best results of MouseMoveRel commands
4. FindWindowText> does not work with AdAware, that is a function of that program, not a problem with Macro Scheduler.
5. Removed Tab and Arrow movements. Again, Press Enter will not work in AdAware, need to position mouse, so tabs, arrows, etc. are useless, still have to move the mouse to the buttons.
6. PushButton will not work in AdAware.
7. MouseMoveRel values and WaitRectChanged numbers will probably be different on your system.4
8. WaitRectChanged timeout is set for 10 minutes, may want to change it.
9. I jumped out of the script before doing the KillEm section. figured you may want to stop here and not delete any bad guys until you are sure this section is working OK. I started the KillEm section to get you started on completion of the script.

//Run Ad-aware, one part of a multi-part clean-up routine.
//Tuesday, August 26, 2003 6:59 PM
//Modified by Bob Hansen, 8/27/03, 1:30am

//Set variables
Let>WW_TIMEOUT=5
CapsOff

Goto>mo
//Goto>Bob

Label>Bob
Let>WindowName=Ad-aware 6.0 Plus*
Change Directory>C:\Program Files\Lavasoft\Ad-aware 6
Goto>Start

Label>mo
Let>WindowName=Ad-aware 6.0 Personal*
Change Directory>C:\Program Files\Lavasoft Ad-aware\Ad-aware 6

Label>Start
//Start Ad Aware Program
Run>Ad-aware.exe
WaitWindowOpen>%WindowName%
SetFocus>%WindowName%
//Maximize window
WindowAction>1,%WindowName%
WaitReady>1
Wait>0.5

Label>StartButton
MouseMoveRel>690,550
Wait>1
LClick
Wait>3

Label>NextButton
MouseMoveRel>690,550
Wait>1
LClick

Label>Scanning
Wait>10
//Check for bad guys
//FindWindowText not working, need another method, Check Rectangle? YES
//Define Rectangle to monitor for "Bad Guy" = Number of New Objects
//Syntax reference: WaitRectChanged>TLX,TLY,BRX,BRY,Timeout
WaitRectChanged>255,405,270,415,600
//True = change in rectangle, False=no change
If>WRC_RESULT=FALSE,CheckStatus
Let>BadGuys=True

Label>CheckStatus
//Define Rectangle to monitor for "Completed" = Title in top cell of Screen
WaitRectChanged>380,104,395,110,600
If>WRC_RESULT=TRUE,CheckBadGuys,CheckStatus

Label>CheckBadGuys
If>BadGuys=True,KillBadGuys,Done

Label>KillBadGuys
Wait>1
//Click on Next Button
MouseMoveRel>690,550
Wait>1
LClick
Wait>1

Label>ModifyObjects
//Pause here to manually review objects to be deleted.
Message>One minute delay for you to modify objects to be deleted.
Wait>60
Message>Time Up
Wait>10

Label>TestJump
Goto>Done

//Click on Next Button
Label>KillEm
MouseMoveRel>690,550
Wait>0.5
LClick
Wait>0.5

//.................More code here
//.................
//.................
//.................

Label>Done
Press ALT
Wait>.1
Press F4
Wait>.1
Release ALT
Message>AdAware process is completed.

Label>End
This should get you going. You picked a nice program with "exceptions" to the normal tools to learn Macro Scheduler with. Enjoy!

If you cut and paste from here to Editor, be sure to remove all trailing spaces on the lines.

Hope this was helpful.................good luck,
Bob

mo
Junior Coder
Posts: 49
Joined: Thu Aug 21, 2003 11:02 pm

Post by mo » Wed Aug 27, 2003 10:09 am

Thanks again Robert,

Very helpful. I print your things out and use them in front of me as I am working on the code.
Best Wishes!
mo

mo
Junior Coder
Posts: 49
Joined: Thu Aug 21, 2003 11:02 pm

Post by mo » Sat Aug 30, 2003 1:40 pm

Just a quick word to those who are being so helpful on this (RH&C): I am long getting back on this because I am having some trouble, but I don't want to post the script until I have exhosted my own thoughts about what may be going wrong.

PS: I am trying to set up my website with proper description and keyword meta tags (as opposed to using the same ones throughout) and I have developed a little script that pastes the copied text into a new file, stripps off the tags, moves everything to the left, stripps out blank lines, and delets air...an absolutely enormous amount of time is being saved...so my delay here is no indication of disappointment with this program.

PS: since making numerous changes, deletions, and sorts without saving a file crashes TextPad (as I just found out, thereby losing about a half-hour's work) I also added a "Save As" routing to this little script. haha
Best Wishes!
mo

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts