Jump to content

Adaware SE Automation


SmOke_N
 Share

Recommended Posts

  • Moderators

Thought I better post this here before I keep going back to it and playing with it (not getting any of my other work done :lmao: ). I had not used Adaware until yesterday, but this works using PixelCheckSum() to recognize the 'Start' / 'Next' / 'Finished' buttons. I had read where people had had problems automating it because if it's funny controls, but this seems to do the trick on my Windows XP Pro SP2.

**Note** I've noticed that US and Some European OS's don't have the same default Font settings, so this may not work on some European OS's settings, you can get your own PixelCheckSum() values and replace the others to get them to work. (If someone knows how to change them (fonts) as desired, I'd love to know o:) )

It also has a UDF _MsgBox() that I use... feel free to play with or add to either the script or the UDF _MsgBox() << (needs more parameters ;) but don't want to get started on that right now!! ).

Opt('MouseCoordMode', 2)
Opt('PixelCoordMode', 2)

Global $AdAwareTitle = 'Ad-Aware SE Personal'
Global $AdAwareChildTitle = 'Ad-Aware SE'
Global $AdStart = 4058524881
Global $AdNext = 704396283
Global $AdCancel = 181093911
Global $AdFinished = 2663204375
Dim $ScanChoice = ''
Dim $Click = 0

Dim $ScanMsgBox = _MsgBox(2, 'Scan Type', 'What type of scan would you like to do?')
If $ScanMsgBox = 6 Then
    $ScanChoice = 'TRadioButton1'
Else
    $ScanChoice = 'TRadioButton2'
EndIf
    
If Not ProcessExists('Ad-Aware.exe') Then
    Run(@ProgramFilesDir & '\Lavasoft\Ad-Aware SE Personal\Ad-Aware.exe')
EndIf

WinWait($AdAwareTitle)


While WinExists($AdAwareTitle)
    If Not WinActive($AdAwareTitle) Then WinActivate($AdAwareTitle)
    Sleep(500)
    Local $CheckSum = PixelChecksum(585, 346, 607, 353)
    
    If $Click = 0 Then
        If $CheckSum = $AdStart Then 
            ControlClick($AdAwareTitle, '', 'TACimage16')
            $Click = 1
            ContinueLoop
        EndIf
    EndIf
    
    If $Click = 1 Then
        ControlClick($AdAwareTitle, '', $ScanChoice)
        $Click = 2
        ContinueLoop
    EndIf
    
    If $Click = 2 Then
        If $CheckSum = $AdNext Then
            ControlClick($AdAwareTitle, '', 'TACimage16')
            $Click = 3
            ContinueLoop
        EndIf
    EndIf
    
    If $Click = 3 Then
        If $CheckSum = $AdCancel Then
            Do
                Sleep(1000)
            Until PixelChecksum(585, 346, 607, 353) <> $AdCancel
            $Click = 4
            ContinueLoop
        EndIf
    EndIf
    
    If $Click = 4 Then
        If $CheckSum = $AdFinished Then
            ProcessClose('Ad-Aware.exe')
            Do
                Sleep(100)
            Until ProcessExists('Ad-Aware.exe') = 0
            Exit
        Else
            ControlClick($AdAwareTitle, '', 'TACimage16')
            $Click = 5
            ContinueLoop
        EndIf
    EndIf
    
    If $Click = 5 Then
        ControlClick($AdAwareTitle, '', 'TVirtualStringTree1', 'Right', 1)
        ControlSend($AdAwareTitle, '', 'TVirtualStringTree1', '{DOWN 2}' & '{ENTER}')
        Sleep(250)
        ControlClick($AdAwareTitle, '', 'TACimage16')
        $Click = 6
            ContinueLoop
    EndIf
    
    If $Click = 6 Then
        Local $OPT = Opt('WinTitleMatchMode', 4)
        ControlClick($AdAwareChildTitle, '', 'TACimage1')
        $Click = 7
        Opt('WinTitleMatchMode', $OPT)
        ContinueLoop
    EndIf
    
    If $Click = 7 Then
        If $CheckSum = $AdStart Then
            ProcessClose('Ad-Aware.exe')
            Do
                Sleep(100)
            Until ProcessExists('Ad-Aware.exe') = 0
            Exit
        EndIf
    EndIf
    Local $OPT = Opt('WinTitleMatchMode', 4)
    If ControlCommand($AdAwareChildTitle, '', 'TACimage1', 'IsVisible', '') Then
        ControlClick($AdAwareChildTitle, '', 'TACimage1')
    EndIf
    Opt('WinTitleMatchMode', $OPT)
;ToolTip($Click, 0, 0)
WEnd

Func _MsgBox($mb_Icon, $mb_Title, $mb_Text, $mb_Time = '')
    Local $StrnLenText = MsgLongestString($mb_Text)
    Local $NumberOfLines = (UBound(StringSplit($mb_Text, @CRLF)) - 1) * 5
    Local $Button1Txt = "Full Scan"
    Local $Button2Txt = "Smart Scan"
    Local $MsgValue = 0
    Local $Timer = ''
    $iMsgBox = GUICreate($mb_Title, $StrnLenText + 190, 100 + $NumberOfLines, -1, -1, 0x00400000, 0x00000008)
    GUICtrlCreateLabel($mb_Text, 60, 10)
    GUICtrlCreateIcon(@SystemDir & "\User32.dll", $mb_Icon, 10, 10, 35, 35)
    $FullScan = GUICtrlCreateButton($Button1Txt, 30 + ($StrnLenText / 2), 45 + $NumberOfLines, 60 + StringLen($Button1Txt), 25)
    $SmartScan = GUICtrlCreateButton($Button2Txt, 100 + ($StrnLenText / 2), 45 + $NumberOfLines, 60 + StringLen($Button2Txt), 25)
    
    GUISetState()
    If $mb_Time <> '' Then $Timer = TimerInit()
    While 1
        $imsg = GUIGetMsg()
        Select
        Case $imsg = $FullScan
                $MsgValue = 6
                ExitLoop
            Case $imsg = $SmartScan
                $MsgValue = 7
                ExitLoop
            Case $mb_Time <> ''
                If TimerDiff($Timer) / 1000 >= $mb_Time Then ExitLoop
        EndSelect
    WEnd
    GUIDelete($iMsgBox)
    Return $MsgValue
EndFunc

Func MsgLongestString($sText)
    Local $sSplit = StringSplit($sText, @CRLF)
    Local $Times = ''
    If Not @error Then
        ArraySortByLen($sSplit)
        If StringLen($sSplit[1]) <= 100 Then $Times = 2.25
        If StringLen($sSplit[1]) >= 101 And StringLen($sSplit[1]) <= 150 Then $Times = 2.5
        If StringLen($sSplit[1]) >= 151 And StringLen($sSplit[1]) <= 201 Then $Times = 3
        If StringLen($sSplit[1]) >= 202 Then $Times = 3.25
        Return Round(StringLen($sSplit[1])*$Times)
    Else
        If StringLen($sText) <= 100 Then $Times = 2.25
        If StringLen($sText) >= 101 And StringLen($sText) <= 150 Then $Times = 2.5
        If StringLen($sText) >= 151 And StringLen($sText) <= 201 Then $Times = 3
        If StringLen($sText) >= 202 Then $Times = 3.25
        Return Round(StringLen($sText)*$Times)
    EndIf
EndFunc

Func ArraySortByLen(ByRef $nArray, $Start = 1)
    For $i = $Start To UBound($nArray) - 2
        Local $SE = $i
        For $x = $i To UBound($nArray) - 1
            If StringLen($nArray[$SE]) < StringLen($nArray[$x]) Then $SE = $x
        Next
        Local $HLD = $nArray[$i]
        $nArray[$i] = $nArray[$SE]
        $nArray[$SE] = $HLD
    Next
EndFunc
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thought I better post this here before I keep going back to it and playing with it (not getting any of my other work done :lmao: ). I had not used Adaware until yesterday, but this works using PixelCheckSum() to recognize the 'Start' / 'Next' / 'Finished' buttons. I had read where people had had problems automating it because if it's funny controls, but this seems to do the trick on my Windows XP Pro SP2.

**Note** I've noticed that US and Some European OS's don't have the same default Font settings, so this may not work on some European OS's settings, you can get your own PixelCheckSum() values and replace the others to get them to work. (If someone knows how to change them (fonts) as desired, I'd love to know o:) )

It also has a UDF _MsgBox() that I use... feel free to play with or add to either the script or the UDF _MsgBox() << (needs more parameters ;) but don't want to get started on that right now!! ).

Hey,

When it first ran, it wanted to update, which it went to the connect dialog, and then I had to click connect.

After the update the About dialog kept displaying. I End Task AdAware and tried again.

All mine does is keep displaying the About dialog. I have build 1.06r1. What should I do now?

Doug

Link to comment
Share on other sites

  • Moderators

did you do the checksum using the correct PixelCoordMode?

Edit:

I have build 1.06r1 also... it works on all my computers... XP Pro / XP Home / XP Pro Corp x2 ... I dunno :lmao:... Maybe try doing the checksum of just the lettering... I used the Top of the left hand corner of the 'Start' button text to the bottom left hand corner of the 'Start' button text, and those coords I used for all my checksums so they would always be different.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Ok, I really have to be Fraking Bored!!

I did one without PixelCheckSum() so it should work on everyones PC (Hopefully)... It goes pretty fast, so if you want to see what it is doing step by step, increase the Sleep(250) to like Sleep(2000) and uncomment the ToolTip() so you can see what $Click step your on (Normally I wouldn't do $Click Step like this, but it was easily documented this way.

Opt('MouseCoordMode', 2)
Opt('PixelCoordMode', 2)

Global $AdAwareTitle = 'Ad-Aware SE Personal'
Global $AdAwareChildTitle = 'Ad-Aware SE'
Dim $ScanChoice = ''
Dim $Click = 0

Dim $ScanMsgBox = _MsgBox(2, 'Scan Type', 'What type of scan would you like to do?')
If $ScanMsgBox = 6 Then
    $ScanChoice = 'TRadioButton1'
Else
    $ScanChoice = 'TRadioButton2'
EndIf
    
If Not ProcessExists('Ad-Aware.exe') Then
    Run(@ProgramFilesDir & '\Lavasoft\Ad-Aware SE Personal\Ad-Aware.exe')
EndIf

WinWait($AdAwareTitle)


While 1
    Sleep(250)
    If $Click = 0 Then
        If ControlCommand($AdAwareTitle, '', 'TPageControl1', 'IsVisible', '') Then; First page
        ;WinSetState($AdAwareTitle, '', @SW_MINIMIZE)
            ControlClick($AdAwareTitle, '', 'TACimage16')
            $Click = 1
            ContinueLoop
        EndIf
    EndIf
    If $Click = 1 Then
        If ControlCommand($AdAwareTitle, '', 'TACGFXcheckbox3', 'IsVisible', '') Then; 2nd page
            ControlClick($AdAwareTitle, '', 'TACimage16')
            $Click = 2
        EndIf
    EndIf
    If $Click = 2 Then
        Do
            Sleep(100)
        Until ControlCommand($AdAwareTitle, '', 'TACimage15', 'IsVisible', '')
        $Click = 3
        ContinueLoop
    EndIf
    If $Click = 3 Then
        ControlClick($AdAwareTitle, '', 'TACimage16')
        $Click = 4
        ContinueLoop
    EndIf
    If $Click = 4 Then
        If ControlCommand($AdAwareTitle, '', 'TAdvTabSet1', 'IsVisible', '') Then
            ControlClick($AdAwareTitle, '', 'TVirtualStringTree1', 'Right', 1)
            ControlSend($AdAwareTitle, '', 'TVirtualStringTree1', '{DOWN 2}' & '{ENTER}')
            ControlClick($AdAwareTitle, '', 'TACimage16')
            $Click = 5
            ContinueLoop
        Else
            $Click = 6
            ContinueLoop
        EndIf
    EndIf
    If $Click = 5 Then
        Local $OPT = Opt('WinTitleMatchMode', 4)
        If ControlCommand($AdAwareChildTitle, '', 'TACimage1', 'IsVisible', '') Then
            ControlClick($AdAwareChildTitle, '', 'TACimage1')
            $Click = 6
            Opt('WinTitleMatchMode', $OPT)
            ContinueLoop
        Else
            ControlClick($AdAwareTitle, '', 'TACimage16')
            $Click = 6
            ContinueLoop
        EndIf
    EndIf
    If $Click = 6 Then
        ProcessClose('Ad-Aware.exe')
        Do
            Sleep(100)
        Until Not ProcessExists('Ad-Aware.exe')
        Exit
    EndIf
;ToolTip("You're on step: " & $Click, 0, 0)
WEnd

Func _MsgBox($mb_Icon, $mb_Title, $mb_Text, $mb_Time = '')
    Local $StrnLenText = MsgLongestString($mb_Text)
    Local $NumberOfLines = (UBound(StringSplit($mb_Text, @CRLF)) - 1) * 5
    Local $Button1Txt = "Full Scan"
    Local $Button2Txt = "Smart Scan"
    Local $MsgValue = 0
    Local $Timer = ''
    $iMsgBox = GUICreate($mb_Title, $StrnLenText + 190, 100 + $NumberOfLines, -1, -1, 0x00400000, 0x00000008)
    GUICtrlCreateLabel($mb_Text, 60, 10)
    GUICtrlCreateIcon(@SystemDir & "\User32.dll", $mb_Icon, 10, 10, 35, 35)
    $FullScan = GUICtrlCreateButton($Button1Txt, 30 + ($StrnLenText / 2), 45 + $NumberOfLines, 60 + StringLen($Button1Txt), 25)
    $SmartScan = GUICtrlCreateButton($Button2Txt, 100 + ($StrnLenText / 2), 45 + $NumberOfLines, 60 + StringLen($Button2Txt), 25)
    
    GUISetState()
    If $mb_Time <> '' Then $Timer = TimerInit()
    While 1
        $imsg = GUIGetMsg()
        Select
        Case $imsg = $FullScan
                $MsgValue = 6
                ExitLoop
            Case $imsg = $SmartScan
                $MsgValue = 7
                ExitLoop
            Case $mb_Time <> ''
                If TimerDiff($Timer) / 1000 >= $mb_Time Then ExitLoop
        EndSelect
    WEnd
    GUIDelete($iMsgBox)
    Return $MsgValue
EndFunc

Func MsgLongestString($sText)
    Local $sSplit = StringSplit($sText, @CRLF)
    Local $Times = ''
    If Not @error Then
        ArraySortByLen($sSplit)
        If StringLen($sSplit[1]) <= 100 Then $Times = 2.25
        If StringLen($sSplit[1]) >= 101 And StringLen($sSplit[1]) <= 150 Then $Times = 2.5
        If StringLen($sSplit[1]) >= 151 And StringLen($sSplit[1]) <= 201 Then $Times = 3
        If StringLen($sSplit[1]) >= 202 Then $Times = 3.25
        Return Round(StringLen($sSplit[1])*$Times)
    Else
        If StringLen($sText) <= 100 Then $Times = 2.25
        If StringLen($sText) >= 101 And StringLen($sText) <= 150 Then $Times = 2.5
        If StringLen($sText) >= 151 And StringLen($sText) <= 201 Then $Times = 3
        If StringLen($sText) >= 202 Then $Times = 3.25
        Return Round(StringLen($sText)*$Times)
    EndIf
EndFunc

Func ArraySortByLen(ByRef $nArray, $Start = 1)
    For $i = $Start To UBound($nArray) - 2
        Local $SE = $i
        For $x = $i To UBound($nArray) - 1
            If StringLen($nArray[$SE]) < StringLen($nArray[$x]) Then $SE = $x
        Next
        Local $HLD = $nArray[$i]
        $nArray[$i] = $nArray[$SE]
        $nArray[$SE] = $HLD
    Next
EndFunc

I'm done doing this I hope :lmao::king:o:);)

Edit: Added WinSetState() so you can run it in minimized mode, just uncomment line 27 if you want to do that.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Cool script Smoke_N. Works 4 me, i'm gonna trick it up a little, as i always do a full scan. That way i can add it to scheduled tasks to run weekly. Sort of the way microsoft's program runs then :lmao:

Thanks buddy. Good work.

*** Update....

OK, i just tried this on my older laptop (still runs XP), anyway, it comes up with the definitions out of date message first, and won't get past it. I used the Active window tool and got the following info:

Press CTRL-ALT-F to pause the display.

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<

Title: Ad-Aware SE

Class: Tawmessage

Size: X: 294 Y: 304 W: 436 H: 147

>>>>>>>>>>> Mouse Details <<<<<<<<<<<

Screen: X: 400 Y: 417

Cursor ID: 0

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<

RGB: Hex: 0x297D00 Dec: 2718976

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Size: X: 74 Y: 69 W: 128 H: 32

Control ID: 1639090

ClassNameNN: TACimage1

Text:

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<

I noticed you script has "Global $AdAwareChildTitle = 'Ad-Aware SE'" defined at the top, I was just wondering, where should i place this information? If i make it a "WinWaitActive" and it doesn't appear, the script won't continue?

Edited by KegRaider
Link to comment
Share on other sites

  • 1 month later...

Hi .... just wondering if there is a similar script for older OS's. One that will run Ad-Aware or SpyBot would be kewl..

Slicxwliqw'

Cool script Smoke_N. Works 4 me, i'm gonna trick it up a little, as i always do a full scan. That way i can add it to scheduled tasks to run weekly. Sort of the way microsoft's program runs then :o

Thanks buddy. Good work.

*** Update....

OK, i just tried this on my older laptop (still runs XP), anyway, it comes up with the definitions out of date message first, and won't get past it. I used the Active window tool and got the following info:

Press CTRL-ALT-F to pause the display.

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<

Title: Ad-Aware SE

Class: Tawmessage

Size: X: 294 Y: 304 W: 436 H: 147

>>>>>>>>>>> Mouse Details <<<<<<<<<<<

Screen: X: 400 Y: 417

Cursor ID: 0

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<

RGB: Hex: 0x297D00 Dec: 2718976

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Size: X: 74 Y: 69 W: 128 H: 32

Control ID: 1639090

ClassNameNN: TACimage1

Text:

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<

I noticed you script has "Global $AdAwareChildTitle = 'Ad-Aware SE'" defined at the top, I was just wondering, where should i place this information? If i make it a "WinWaitActive" and it doesn't appear, the script won't continue?

Link to comment
Share on other sites

  • Moderators

Err... I made this simply because people said that you couldn't use the control ID's to make it work (or they were having a hard time doing it). I would assume if you used the last one, that it would work on any AdAware SE (key point here) as long as the control id's were the same. If they aren't then you specifically could do some work on it, to suit your specific needs.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • 9 months later...

Sorry if it's a bit of resurrecting an old post, but here's a wee bit I added to Sm0ke_N's code to deal with the definitions out of date message.

Might not be the best way around it (it checks pixel colour to see if there is a green tick on the button).

Add this line near the top:

Opt("WinTitleMatchMode", 3)

Declear a third window title:

Global $AdAwareChildTitle2 = 'Lavasoft Ad-Aware SE'

Add this before the while loop:

Sleep(5000)
If WinActive($AdAwareChildTitle) Then                                                   ;--------------- NEW UPDATES READY WINDOW
    WinActivate($AdAwareChildTitle, "")
    ControlCommand( $AdAwareChildTitle, "", "TACimage1" ,"Check")
    WinWaitActive($AdAwareChildTitle2, "")
    ControlCommand( $AdAwareChildTitle2, "", "TACimage3" ,"Check")
    WinWaitActive($AdAwareChildTitle, "")
    ControlCommand( $AdAwareChildTitle, "", "TACimage1" ,"Check")
    WinWaitActive($AdAwareChildTitle2, "")
    While WinActive($AdAwareChildTitle2)
        If PixelGetColor ( 346 , 236 ) = 3979776 Then
            ControlCommand( $AdAwareChildTitle2, "", "TACimage3" ,"Check")
        EndIf
        Sleep(2000)
    WEnd
EndIf

My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator

Link to comment
Share on other sites

  • 5 months later...
  • 1 month later...

this is a wicked script many thanks, i had to adapt it for the professional version, is there a way to update ad-aware before you scan? any help appreciated.

Yes, just do this before running it:

$r=InetGet("http://dlserver.download.lavasoft.com/public/defs.ref", "C:\Program Files\Lavasoft\Ad-Aware SE Personal\defs.ref", 1)
If $r=0 Then
    Msgbox(0,"Error","Ad-Aware definition file is not available.")
    Exit
EndIf

Note: I use the personal edition, so you will have to update the target path for the Pro version.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...