Jump to content

Automating Eset online scanner with UIA_


Go to solution Solved by LarsJ,

Recommended Posts

Posted (edited)

Hi, I want to automate the Eset online scanner, because I like to scan  a lot...:-)

Eset online scanner 

The problem that I have is after the scan is done there is a hyperlink / button to save the logfile. 

I am trying for days now to get this "save logfile" clicked, I always get a error when finding this Hyperlink / button

code so far...

 

#RequireAdmin
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
;#AutoIt3Wrapper_UseX64=n ; If target application is running as 32 bit code
;#AutoIt3Wrapper_UseX64=y ; If target application is running as 64 bit code

#include "UIA_Constants.au3"  ; Can be copied from UIASpy Includes folder
#include "UIA_Functions.au3" ; 
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <GUIConstants.au3>



Example()

Func Example()

    ; Create UI Automation object
    Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation8, $sIID_IUIAutomation6, $dtag_IUIAutomation6 )
    If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF )
    ConsoleWrite( "$oUIAutomation OK" & @CRLF )

    ; Get Desktop element
    Local $pDesktop, $oDesktop
    $oUIAutomation.GetRootElement( $pDesktop )
    $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
    If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF )
    ConsoleWrite( "$oDesktop OK" & @CRLF 

Local $pCondition0
$oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "#32770", $pCondition0 )
If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF )
ConsoleWrite( "$pCondition0 OK" & @CRLF )

Local $pWindow1, $oWindow1
While Not IsObj($oWindow1)
$oDesktop.FindFirst( $TreeScope_Children, $pCondition0, $pWindow1 )
$oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
;~ If Not IsObj( $oWindow1 ) Then Return ConsoleWrite( "$oWindow1 ERR" & @CRLF )
;~ ConsoleWrite( "$oWindow1 OK" & @CRLF )
    If IsObj( $oWindow1 ) Then
        ConsoleWrite( "$oWindow1 OK" & @CRLF)
    Else
        Sleep(1000)
        ConsoleWrite("Debug, scherm nog niet gevonden..." &  @CRLF)
    EndIf
WEnd


ConsoleWrite( "--- Find window/control ---" & @CRLF )

Local $pConditionauto
$oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "59648", $pConditionauto )
If Not $pConditionauto Then Return ConsoleWrite( "$pConditionauto ERR" & @CRLF )
ConsoleWrite( "$pConditionauto OK" & @CRLF )

Local $pPane1, $oPane1
$oWindow1.FindFirst( $TreeScope_Descendants, $pConditionauto, $pPane1 )
$oPane1 = ObjCreateInterface( $pPane1, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
If Not IsObj( $oPane1 ) Then Return ConsoleWrite( "$oPane1 ERR" & @CRLF )
ConsoleWrite( "$oPane1 OK" & @CRLF )

Local $pCondition1
$oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_HyperlinkControlTypeId, $pCondition1 )
;~ $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Scanlogboek opslaan", $pCondition1 )
If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF )
ConsoleWrite( "$pCondition1 OK" & @CRLF )

Local $pHyperlink1, $oHyperlink1
$oPane1.FindFirst( $TreeScope_Descendants, $pCondition1, $pHyperlink1 )
$oHyperlink1 = ObjCreateInterface( $pHyperlink1, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
If Not IsObj( $oHyperlink1 ) Then Return ConsoleWrite( "$oHyperlink1 ERR" & @CRLF )
ConsoleWrite( "$oHyperlink1 OK" & @CRLF )


Endfunc

 

 

 

eset.png

Edited by MightyWeird
add link to eset online
Posted (edited)

I am not familiar with web driver. I thought web driver was only for browsers etc. Because eset online is not browser based, it starts an application, not a web browser.! Therefore I don't think web driver wil work...

But I wil look into it..

Edited by MightyWeird
Format
Posted (edited)

Thank you Larsj!, 

This would take me ages to figure it out.

If anyone is interested I posted the complete working script (or should i start a new topic?). It is rough and might needs some improvements, but I am new to autoit and UIA, so please be kind....

The script copies eset folder from an older installation  to the target os. So when Eset start, I dont get the initial setup screens.

After the scan it looks for a specific window (virus found or not.) From there it saves the log and exists the program)

Language is dutch, so adjust where needed..

Suggestions are welcome, 

 

_Esetmain()

Func _Esetmain()
            HotKeySet("x", "_Interrupt_HotKey")
            $fInterrupt = 0

            Global $esetsourcefolder = @ScriptDir & "\Resources\ESET\ESETOnlineScanner\"
            Global  $esetdestfolder = @LocalAppDataDir & "\Eset\"
            Global $ESETPID = Run(@ScriptDir & "\Resources\ESET" & "\esetonlinescanner.exe")

            DirCopy($esetsourcefolder, $esetdestfolder & "\ESETOnlineScanner\", $FC_OVERWRITE)
            
            Winwait("[CLASS:#32770]","")

            ; Create UI Automation object
            Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation8, $sIID_IUIAutomation6, $dtag_IUIAutomation6 )
            If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF )
            ConsoleWrite( "$oUIAutomation OK" & @CRLF )

            ; Get Desktop element
            Local $pDesktop, $oDesktop
            $oUIAutomation.GetRootElement( $pDesktop )
            $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
            If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF )
            ConsoleWrite( "$oDesktop OK" & @CRLF )

            ;bij instellingen toepassing vewijderen aanzetten!
            Local $pConditionesetwin0, $pConditionesetwin1, $pAndConditionesetwin1
            $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "#32770", $pConditionesetwin0 )
            $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_WindowControlTypeId, $pConditionesetwin1 )
            $oUIAutomation.CreateAndCondition( $pConditionesetwin0, $pConditionesetwin1, $pAndConditionesetwin1 )
            If Not $pAndConditionesetwin1 Then Return ConsoleWrite( "$pAndConditionesetwin1 ERR" & @CRLF )
            ConsoleWrite( "$pAndConditionesetwin1 OK" & @CRLF )

            Local $pConditionesetwin2, $pAndConditionesetwin2
            $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "ESET Online Scanner", $pConditionesetwin2 )
            $oUIAutomation.CreateAndCondition( $pAndConditionesetwin1, $pConditionesetwin2, $pAndConditionesetwin2 )
            If Not $pAndConditionesetwin2 Then Return ConsoleWrite( "$pAndCondition2 ERR" & @CRLF )
            ConsoleWrite( "$pAndConditionesetwin2 OK" & @CRLF )


            Local $pWindow1, $oWindow1
            While Not IsObj($oWindow1)
            $oDesktop.FindFirst( $TreeScope_Children, $pAndConditionesetwin2, $pWindow1 )
            $oWindow1 = ObjCreateInterface( $pWindow1, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
            If IsObj( $oWindow1 ) Then
            ConsoleWrite( "$oWindow1 OK" & @CRLF)
            Else
                Sleep(500)
                ConsoleWrite("Debug, scherm nog niet gevonden..." &  @CRLF)
            EndIf
            WEnd

            ; instellingen openen
            UIA_WinActivate( $oWindow1 )

            Local $pConditioninstellingen1,$pConditioninstellingen2,$pAndConditioninstellingen
            $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TextControlTypeId, $pConditioninstellingen1 )
            $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Instellingen", $pConditioninstellingen2 )
            $oUIAutomation.CreateAndCondition( $pConditioninstellingen1, $pConditioninstellingen2, $pAndConditioninstellingen)
            If Not $pAndConditioninstellingen Then Return ConsoleWrite( "$pAndConditioninstellingen ERR" & @CRLF )
            ConsoleWrite( "$pAndConditioninstellingen OK" & @CRLF )

            Local $pinstellingenbtn, $oinstellingenbtn
            While Not IsObj($oinstellingenbtn)
            $oDesktop.FindFirst( $TreeScope_Descendants, $pAndConditioninstellingen, $pinstellingenbtn )
            $oinstellingenbtn = ObjCreateInterface( $pinstellingenbtn, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
            
            If IsObj( $oinstellingenbtn ) Then
                ConsoleWrite( "$oinstellingenbtn  OK / scherm met instelingen gevonden" & @CRLF )
            Else
                ConsoleWrite("Debug, Error, $oinstellingenbtn nog niet gevonden..." &  @CRLF)
                Sleep(5000) ;hier nog interrupt!!!!
            EndIf
        WEnd

            UIA_mouseclick($oinstellingenbtn)
            consolewrite ("Debug, knop instellingen indrukken")

            ;knoppen identificeren / toepassing verwijderen
            Local $pConditioninstellingencheck1,$pConditioninstellingencheck2,$pAndConditioninstellingencheck
            $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_CheckBoxControlTypeId, $pConditioninstellingencheck1 )
            $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Toepassingsgegevens verwijderen tijdens sluiten", $pConditioninstellingencheck2 )
            $oUIAutomation.CreateAndCondition( $pConditioninstellingencheck1, $pConditioninstellingencheck2, $pAndConditioninstellingencheck)
            If Not $pAndConditioninstellingencheck Then Return ConsoleWrite( "$pAndConditioninstellingencheck ERR" & @CRLF )
            ConsoleWrite( "$pAndConditioninstellingencheck OK" & @CRLF )

            Local $pinstellingencheckbtn, $oinstellingencheckbtn
            While Not IsObj($oinstellingencheckbtn)
            $oDesktop.FindFirst( $TreeScope_Descendants, $pAndConditioninstellingencheck, $pinstellingencheckbtn )
            $oinstellingencheckbtn = ObjCreateInterface( $pinstellingencheckbtn, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
            
            If IsObj( $oinstellingencheckbtn ) Then
                ConsoleWrite( "$oinstellingencheckbtn OK" & @CRLF )
            Else
                ConsoleWrite("Debug, Error, $oinstellingencheckbtn nog niet gevonden..." &  @CRLF)
                Sleep(5000) ;hier nog interrupt!!!!
            EndIf
        WEnd

            sleep(2000)
            ;toepassing verwijderen indrukken
            UIA_mouseclick($oinstellingencheckbtn)
            consolewrite ("Debug, Toepassingsgegevens verwijderen indrukken" & @CRLF )

            WinActivate("ESET Online Scanner")
            ControlClick(("ESET Online Scanner"), "", "")

            ;Dit ooit nog eens automatiseren ipv via send...
            send ("{tab 4}")
            sleep (2000)
            send ("{space}")
            
            ################################### instellingen ##########################
            ;knoppen identificeren / toepassing verwijderen
            Local $pCondition1,$pCondition2,$pAndCondition2
            $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition1 )
            $oUIAutomation.CreatePropertyConditionex( $UIA_NamePropertyId, "Computerscan", $PropertyConditionFlags_MatchSubstring, $pCondition2 )
            $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pAndCondition2 )
            If Not $pAndCondition2 Then Return ConsoleWrite( "$pAndCondition2 ERR" & @CRLF )
            ConsoleWrite( "$pAndCondition2 OK" & @CRLF )

            Local $pButton1, $oButton1
            While Not IsObj($oButton1)
            $oWindow1.FindFirst( $TreeScope_Descendants, $pAndCondition2, $pButton1 )
            $oButton1 = ObjCreateInterface( $pButton1, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
            If IsObj( $oButton1 ) Then
                ConsoleWrite( "$oButton1 OK" & @CRLF )
            Else
                ConsoleWrite("Debug, Error, $OButton1 nog niet gevonden..." &  @CRLF)
                Sleep(1000) ;hier nog interrupt!!!!
            EndIf
        WEnd

            UIA_mouseclick($obutton1)
            ConsoleWrite("debug, volldige scan knop indrukken" & @CRLF)
            Sleep(1000)

            ;wacht op volgend scherm
            Local $pCondition4,$pCondition5,$pAndCondition3
            $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition4 )
            $oUIAutomation.CreatePropertyConditionex( $UIA_NamePropertyId, "Volledige scan", $PropertyConditionFlags_MatchSubstring, $pCondition5 )
            $oUIAutomation.CreateAndCondition( $pCondition4, $pCondition5, $pAndCondition3 )
            If Not $pAndCondition3 Then Return ConsoleWrite( "$pAndCondition3 ERR" & @CRLF )
            ConsoleWrite( "$pAndCondition3 OK" & @CRLF )

            Local $pButton3, $oButton3
            $oWindow1.FindFirst( $TreeScope_Descendants, $pAndCondition3, $pButton3 )
            $oButton3 = ObjCreateInterface( $pButton3, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
            If Not IsObj( $oButton3 ) Then Return ConsoleWrite( "$oButton3 ERR" & @CRLF )
            ConsoleWrite( "$oButton3 OK" & @CRLF )

            Sleep (1000)

            UIA_mouseclick($obutton3)
            ConsoleWrite("debug, Volledige scan knop ingedrukt met mouseclick" & @CRLF)

            Sleep(1000)
            ;radio button ongewenste toepassing
            Local $pConditpotent4,$pconditpotent5,$pAndConditpotent3
            $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_RadioButtonControlTypeId, $pConditpotent4 )
            $oUIAutomation.CreatePropertyConditionex( $UIA_NamePropertyId, "ESET potentieel ongewenste", $PropertyConditionFlags_MatchSubstring, $pconditpotent5 )
            $oUIAutomation.CreateAndCondition( $pConditpotent4, $pconditpotent5, $pAndConditpotent3 )
            If Not $pAndConditpotent3 Then Return ConsoleWrite( "$pAndConditpotent3 ERR" & @CRLF )
            ConsoleWrite( "$pAndConditpotent3 OK" & @CRLF )

            Local $ppotButton3, $opotButton3
            $oWindow1.FindFirst( $TreeScope_Descendants, $pAndConditpotent3, $ppotButton3 )
            $opotButton3 = ObjCreateInterface( $ppotButton3, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
            If Not IsObj( $opotButton3 ) Then Return ConsoleWrite( "$opotButton3 ERR" & @CRLF )
            ConsoleWrite( "$opotButton3 OK" & @CRLF )

            UIA_mouseclick($opotButton3)
            ConsoleWrite("debug, Potentieel knop ingedrukt met mouseclick" & @CRLF)
            sleep (2000)

            ;Volgende knop
            Local $pConditionstartscan4,$pConditionstartscan5,$pAndConditionstartscan3
            $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pConditionstartscan4 )
            $oUIAutomation.CreatePropertyConditionex( $UIA_NamePropertyId, "Scan starten", $PropertyConditionFlags_MatchSubstring, $pConditionstartscan5 )
            $oUIAutomation.CreateAndCondition( $pConditionstartscan4, $pConditionstartscan5, $pAndConditionstartscan3 )
            If Not $pAndConditionstartscan3 Then Return ConsoleWrite( "$pAndConditionstartscan3 ERR" & @CRLF )
            ConsoleWrite( "$pAndConditionstartscan3 OK" & @CRLF )
            
            Local $pButtonscanstart3, $oButtonscanstart3
            $oWindow1.FindFirst( $TreeScope_Descendants, $pAndConditionstartscan3, $pButtonscanstart3 )
            $oButtonscanstart3 = ObjCreateInterface( $pButtonscanstart3, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
            If Not IsObj( $oButtonscanstart3 ) Then Return ConsoleWrite( "$oButtonscanstart3 ERR" & @CRLF )
            ConsoleWrite( "$oButtonscanstart3 OK" & @CRLF )

            UIA_mouseclick($oButtonscanstart3)
            ConsoleWrite("debug, Scan starten knop" & @CRLF)

            ##############NU scan bezig, wachten op einde scan venster ##########################   

            ;mogelijke vensters beschrijven / identificeren
            Local $ponderbroken0
            $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Scan onderbroken door gebruiker", $ponderbroken0 )
            If Not $ponderbroken0 Then Return ConsoleWrite( "$ponderbroken0 ERR" & @CRLF )
            ConsoleWrite( "$ponderbroken0 OK" & @CRLF )

            Local $pdetecties0
            $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Detecties plaatsgevonden en opgelost",$pdetecties0 )
            If Not $pdetecties0 Then Return ConsoleWrite( "$pdetecties0 ERR" & @CRLF )
            ConsoleWrite( "$pdetecties0 OK" & @CRLF )

            Local $pgeendetecties0
            $oUIAutomation.CreatePropertyConditionex( $UIA_NamePropertyId, "Geen bedreigingen gevonden", $PropertyConditionFlags_MatchSubstring, $pgeendetecties0 )
            If Not $pgeendetecties0 Then Return ConsoleWrite( "$pgeendetecties0 ERR" & @CRLF )
            ConsoleWrite( "$pgeendetecties0 OK" & @CRLF )

            ;hier begint de loop  (if scan onderbroken / scan voltooid  / virus gevonden..e.d)
            Local $pText1, $oText1,$pText2,$oText2,$pText3,$oText3
            While Not IsObj($oText1) Or ($oText2) or ($oText3);while
            $oDesktop.FindFirst( $TreeScope_Descendants, $ponderbroken0, $pText1 )
            $oText1 = ObjCreateInterface( $pText1, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )

            $oDesktop.FindFirst( $TreeScope_Descendants, $pdetecties0, $pText2 )
            $oText2 = ObjCreateInterface( $pText2, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )

            $oDesktop.FindFirst( $TreeScope_Descendants, $pgeendetecties0, $pText3 )
            $oText3 = ObjCreateInterface( $pText3, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )


            ; scan onderbroken, nu verder met deze tree...

            If IsObj( $oText1 ) Then
                ConsoleWrite( "$oText1 OK" & @CRLF )
                Local $pConditiondoogaan1,$pConditiondoorgaan2,$pAndConditiondoorgaan2
                $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pConditiondoogaan1 )
                $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Doorgaan", $pConditiondoorgaan2 )
                $oUIAutomation.CreateAndCondition( $pConditiondoogaan1, $pConditiondoorgaan2, $pAndConditiondoorgaan2 )
            If Not $pAndConditiondoorgaan2 Then Return ConsoleWrite( "$pAndConditiondoorgaan2 ERR" & @CRLF )
                ConsoleWrite( "$pAndConditiondoorgaan2 OK" & @CRLF )
                    

            Local $pdoorgaanButton1, $odoorgaanButton1
            While Not IsObj($odoorgaanButton1)
                $oWindow1.FindFirst( $TreeScope_Descendants, $pAndConditiondoorgaan2, $pdoorgaanButton1 )
                $odoorgaanButton1 = ObjCreateInterface( $pdoorgaanButton1, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
            If IsObj( $odoorgaanButton1 ) Then
                ConsoleWrite( "$odoorgaanButton1 OK" & @CRLF )
            Else
                ConsoleWrite("Debug, $odoorgaanButton1 nog niet gevonden..." &  @CRLF)
                Sleep(1000) ;hier nog interrupt!!!!
            EndIf
        WEnd ;einde binnen loop

            WinActivate("ESET Online Scanner")
            ControlClick(("ESET Online Scanner"), "", "")

            UIA_mouseclick($odoorgaanButton1) ;doorgaan knop
            sleep (1000)
            exitloop ;hier einde van de loop, doorgaan na wend...
            Else
                ConsoleWrite("Debug, $oText1 (onderbroken nog niet gevonden..." &  @CRLF)
                Sleep(1000) ;hier nog interrupt!!!!
            EndIf
            ;einde $text1

            ;virus gevonden, nu verder met deze tree

            If IsObj( $oText2 ) Then
                ConsoleWrite( "$oText2 OK" & @CRLF )

            Local $pConditionresult0
            $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_PaneControlTypeId, $pConditionresult0 )
            If Not $pConditionresult0 Then Return ConsoleWrite( "$pConditionresult0 ERR" & @CRLF )
            ConsoleWrite( "$pConditionresult0 OK" & @CRLF )

            Local $pPane1result, $oPane1result
            $oDesktop.FindFirst( $TreeScope_Descendants, $pConditionresult0, $pPane1result )
            $oPane1result = ObjCreateInterface( $pPane1result, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
            If Not IsObj( $oPane1result ) Then Return ConsoleWrite( "$oPane1result ERR" & @CRLF )
            ConsoleWrite( "$oPane1result OK" & @CRLF )

            ; --- Find window/control ---

            ConsoleWrite( "--- Find window/control ---" & @CRLF )

            Local $pConditionresult1
            $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Gedetailleerde resultaten weergeven   ", $pConditionresult1 )
            If Not $pConditionresult1 Then Return ConsoleWrite( "$pConditionresult1 ERR" & @CRLF )
            ConsoleWrite( "$pConditionresult1 OK" & @CRLF )

            Local $pPaneresult2, $oPaneresult2
            $oDesktop.FindFirst( $TreeScope_Descendants, $pConditionresult1, $pPaneresult2 )
            $oPaneresult2 = ObjCreateInterface( $pPaneresult2, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
            If Not IsObj( $oPaneresult2 ) Then Return ConsoleWrite( "$oPaneresult2 ERR" & @CRLF )
            ConsoleWrite( "$oPaneresult2 OK" & @CRLF )

            ;gedetailleerde resultaten weergeven knop
            Local $pConditionresult4,$pConditionresult5,$pAndConditionresult3
            $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pConditionresult4 )
            $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Gedetailleerde resultaten weergeven", $pConditionresult5 )
            $oUIAutomation.CreateAndCondition( $pConditionresult4, $pConditionresult5, $pAndConditionresult3 )
            If Not $pAndConditionresult3 Then Return ConsoleWrite( "$pAndConditionresult3 ERR" & @CRLF )
            ConsoleWrite( "$pAndConditionresult3 OK" & @CRLF )

            Local $pButtonresult3, $oButtonresult3
              While Not IsObj($oButtonresult3)
            $oPaneresult2.FindFirst( $TreeScope_Descendants, $pAndConditionresult3, $pButtonresult3 )
            $oButtonresult3 = ObjCreateInterface( $pButtonresult3, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )

            If IsObj( $oButtonresult3 ) Then
                ConsoleWrite( "$oButtonresult3 OK" & @CRLF )
            Else
                ConsoleWrite("Debug, $oButtonresult3 nog niet gevonden..." &  @CRLF)
                Sleep(1000) ;hier nog interrupt!!!!
            EndIf
            WEnd ;einde binnen loop

            WinActivate("ESET Online Scanner")
            ControlClick("ESET Online Scanner", "", "")

            UIA_mouseclick($oButtonresult3)

            ;nu logboek opslaan
            Local $pConditionlogb3, $pConditionlogb4, $pAndConditionlogb4
            $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TextControlTypeId, $pConditionlogb3 )
            $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Scanlogboek opslaan", $pConditionlogb4 ) ; <<<< Edit text to your own language
            $oUIAutomation.CreateAndCondition( $pConditionlogb3, $pConditionlogb4, $pAndConditionlogb4 )
            If Not $pAndConditionlogb4 Then Return ConsoleWrite( "$pAndConditionlogb4 ERR" & @CRLF )
            ConsoleWrite( "$pAndConditionlogb4 OK" & @CRLF )

            Local $pTextlogb1, $oTextlogb1
            $oDesktop.FindFirst( $TreeScope_Descendants, $pAndConditionlogb4, $pTextlogb1 )
            $oTextlogb1 = ObjCreateInterface( $pTextlogb1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement )
            If Not IsObj( $oTextlogb1 ) Then Return ConsoleWrite( "$oTextlogb1 ERR" & @CRLF )
            ConsoleWrite( "$oTextlogb1 OK" & @CRLF )

            UIA_WinActivate( $oWindow1 )
            ConsoleWrite( "UIA_WinActivate( $oWindow1 )" & @CRLF )

            UIA_MouseClick1( $oTextlogb1, 97 )
            ConsoleWrite( "UIA_MouseClick1( $oText1, 97 )" & @CRLF )

            UIA_WinActivate( $oWindow1 )
            Sleep(500)
            ControlClick("ESET Online Scanner", "Scanlogboek opslaan", 1065)
            Sleep(500)
            WinWait("Opslaan als", "")
            WinActivate("Opslaan als", "")
            Sleep(500)
            ControlSend("", "", "", "c:\logs\esetlog.txt")
            Sleep(500)
            Send("{Enter}")
            Sleep(500)
            
            ;vervolgens doorgaan knop

            #################################### Logboek opgeslagen, nu toepassing sluiten ####################################################
            winclose("[CLASS:#32770]","")
            ############################################ toepassing Sluiten ##############################################################

            Local $pConditiontoepassingsluiten1
            $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_PaneControlTypeId, $pConditiontoepassingsluiten1 )
            If Not $pConditiontoepassingsluiten1 Then Return ConsoleWrite( "$pConditiontoepassingsluiten1 ERR" & @CRLF )
            ConsoleWrite( "$pConditiontoepassingsluiten1 OK" & @CRLF )

            Local $pPaneltoepassingsluiten1, $oPaneltoepassingsluiten1
            $oDesktop.FindFirst( $TreeScope_Descendants, $pConditiontoepassingsluiten1, $pPaneltoepassingsluiten1 )
            $oPaneltoepassingsluiten1 = ObjCreateInterface( $pPaneltoepassingsluiten1, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
            If Not IsObj( $oPaneltoepassingsluiten1 ) Then Return ConsoleWrite( "$oPaneltoepassingsluiten1 ERR" & @CRLF )
            ConsoleWrite( "$oPaneltoepassingsluiten1 OK" & @CRLF )

            ; --- Find window/control ---

            ConsoleWrite( "--- Find window/control ---" & @CRLF )

            Local $pConditiontoepassingsluiten2
            $oUIAutomation.CreatePropertyConditionex( $UIA_NamePropertyId, "Uw scan resulteert in uw inbox", $PropertyConditionFlags_MatchSubstring, $pConditiontoepassingsluiten2 )
            If Not $pConditiontoepassingsluiten2 Then Return ConsoleWrite( "$pConditiontoepassingsluiten2 ERR" & @CRLF )
            ConsoleWrite( "$pConditiontoepassingsluiten2 OK" & @CRLF )

            Local $pPaneltoepasssingsluiten2, $oPaneltoepassingsluiten2
            $oDesktop.FindFirst( $TreeScope_Descendants, $pConditiontoepassingsluiten2, $pPaneltoepasssingsluiten2 )
            $oPaneltoepassingsluiten2 = ObjCreateInterface( $pPaneltoepasssingsluiten2, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
            If Not IsObj( $oPaneltoepassingsluiten2 ) Then Return ConsoleWrite( "$oPaneltoepassingsluiten2 ERR" & @CRLF )
            ConsoleWrite( "$oPaneltoepassingsluiten2 OK" & @CRLF )

            ConsoleWrite( "--- Find window/control ---" & @CRLF )

            Local $pConditiontoesluiten3, $pConditiontoesluiten4, $pAndConditiontoesluiten4
            $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pConditiontoesluiten3 )
            $oUIAutomation.CreatePropertyConditionex( $UIA_NamePropertyId, "Toepassing sluiten", $PropertyConditionFlags_MatchSubstring, $pConditiontoesluiten4 )
            $oUIAutomation.CreateAndCondition( $pConditiontoesluiten3, $pConditiontoesluiten4, $pAndConditiontoesluiten4 )
            If Not $pAndConditiontoesluiten4 Then Return ConsoleWrite( "$pAndConditiontoesluiten4 ERR" & @CRLF )
            ConsoleWrite( "$pAndConditiontoesluiten4 OK" & @CRLF )

            Local $ptoesluiten1, $otoesluiten1
            While Not IsObj($otoesluiten1)
            $oPaneltoepassingsluiten2.FindFirst( $TreeScope_Descendants, $pAndConditiontoesluiten4, $ptoesluiten1 )
            $otoesluiten1 = ObjCreateInterface( $ptoesluiten1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement )

            If IsObj( $otoesluiten1 ) Then
                ConsoleWrite( "$otoesluiten1 OK" & @CRLF )
            Else
                ConsoleWrite("Debug, $otoesluiten1 nog niet gevonden..." &  @CRLF)
                Sleep(1000) ;hier nog interrupt!!!!
            EndIf
        wend

            UIA_WinActivate( $oWindow1 )
            ConsoleWrite( "UIA_WinActivate( $oWindow1 )" & @CRLF )

            UIA_MouseClick( $otoesluiten1 )

            consolewrite("Debug, exitloop einde script, op naar volgende functie" & @CRLF)
            exitloop

            Else
                    ConsoleWrite("Debug, $oText2 (detecties nog niet gevonden..." &  @CRLF)
                    Sleep(1000) ;hier nog interrupt!!!!
            EndIf

        ######################################################################################################
                        #################### Geen Virus ###################
        ######################################################################################################

            UIA_WinActivate( $oWindow1 )

            If IsObj( $oText3 ) Then ; scan klaar, geen virus
                ConsoleWrite( "$oText3 OK" & @CRLF )


            Local $pConditionlogbgv3, $pConditionlogbgv4, $pAndConditionlogbgv4
            $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TextControlTypeId, $pConditionlogbgv3 )
            $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Scanlogboek opslaan", $pConditionlogbgv4 ) ; <<<< Edit text to your own language
            $oUIAutomation.CreateAndCondition( $pConditionlogbgv3, $pConditionlogbgv4, $pAndConditionlogbgv4 )
            If Not $pAndConditionlogbgv4 Then Return ConsoleWrite( "$pAndConditionlogbgv4 ERR" & @CRLF )
            ConsoleWrite( "$pAndConditionlogbgv4 OK" & @CRLF )

            Local $pTextlogb1gv, $oTextlogb1gv
            $oDesktop.FindFirst( $TreeScope_Descendants, $pAndConditionlogbgv4, $pTextlogb1gv )
            $oTextlogb1gv = ObjCreateInterface( $pTextlogb1gv, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement )
            If Not IsObj( $oTextlogb1gv ) Then Return ConsoleWrite( "$oTextlogb1gv ERR" & @CRLF )
            ConsoleWrite( "$oTextlogb1gv OK" & @CRLF )

            UIA_WinActivate( $oWindow1 )
            ConsoleWrite( "UIA_WinActivate( $oWindow1 )" & @CRLF )

            UIA_MouseClick1( $oTextlogb1gv, 97 )
            ConsoleWrite( "UIA_MouseClick1( $oText1, 97 )" & @CRLF )

            UIA_WinActivate( $oWindow1 )
            Sleep(500)
            ControlClick("ESET Online Scanner", "Scanlogboek opslaan", 1065)
            Sleep(500)
            WinWait("Opslaan als", "")
            WinActivate("Opslaan als", "")
            Sleep(500)
            ControlSend("", "", "", "c:\logs\esetlog.txt")
            Sleep(500)
            Send("{Enter}")
            Sleep(500)

            ##################### Logboek opgeslagen, nu toepassing sluiten ####################################################

            winclose("[CLASS:#32770]","")

            ############################################ toepassing Sluiten ##############################################################

            Local $pConditiontoepassingsluiten1gv
            $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_PaneControlTypeId, $pConditiontoepassingsluiten1gv )
            If Not $pConditiontoepassingsluiten1gv Then Return ConsoleWrite( "$pConditiontoepassingsluiten1gv ERR" & @CRLF )
            ConsoleWrite( "$pConditiontoepassingsluiten1gv OK" & @CRLF )

            Local $pPaneltoepassingsluiten1gv, $oPaneltoepassingsluiten1gv
            $oDesktop.FindFirst( $TreeScope_Descendants, $pConditiontoepassingsluiten1gv, $pPaneltoepassingsluiten1gv )
            $oPaneltoepassingsluiten1gv = ObjCreateInterface( $pPaneltoepassingsluiten1gv, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
            If Not IsObj( $oPaneltoepassingsluiten1gv ) Then Return ConsoleWrite( "$oPaneltoepassingsluiten1gv ERR" & @CRLF )
            ConsoleWrite( "$oPaneltoepassingsluiten1gv OK" & @CRLF )

            ; --- Find window/control ---

            ConsoleWrite( "--- Find window/control ---" & @CRLF )

            Local $pConditiontoepassingsluiten2gv
            $oUIAutomation.CreatePropertyConditionex( $UIA_NamePropertyId, "Uw scan resulteert in uw inbox", $PropertyConditionFlags_MatchSubstring, $pConditiontoepassingsluiten2gv )
            If Not $pConditiontoepassingsluiten2gv Then Return ConsoleWrite( "$pConditiontoepassingsluiten2gv ERR" & @CRLF )
            ConsoleWrite( "$pConditiontoepassingsluiten2gv OK" & @CRLF )

            Local $pPaneltoepasssingsluiten2gv, $oPaneltoepassingsluiten2gv
            $oDesktop.FindFirst( $TreeScope_Descendants, $pConditiontoepassingsluiten2gv, $pPaneltoepasssingsluiten2gv )
            $oPaneltoepassingsluiten2gv = ObjCreateInterface( $pPaneltoepasssingsluiten2gv, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 )
            If Not IsObj( $oPaneltoepassingsluiten2gv ) Then Return ConsoleWrite( "$oPaneltoepassingsluiten2gv ERR" & @CRLF )
            ConsoleWrite( "$oPaneltoepassingsluiten2gv OK" & @CRLF )

            ConsoleWrite( "--- Find window/control ---" & @CRLF )

            Local $pConditiontoesluiten3gv, $pConditiontoesluiten4gv, $pAndConditiontoesluiten4gv
            $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pConditiontoesluiten3gv )
            $oUIAutomation.CreatePropertyConditionex( $UIA_NamePropertyId, "Toepassing sluiten", $PropertyConditionFlags_MatchSubstring, $pConditiontoesluiten4gv )
            $oUIAutomation.CreateAndCondition( $pConditiontoesluiten3gv, $pConditiontoesluiten4gv, $pAndConditiontoesluiten4gv )
            If Not $pAndConditiontoesluiten4gv Then Return ConsoleWrite( "$pAndConditiontoesluiten4gv ERR" & @CRLF )
            ConsoleWrite( "$pAndConditiontoesluiten4gv OK" & @CRLF )

            Local $ptoesluiten1gv, $otoesluiten1gv
            While Not IsObj($otoesluiten1gv)
            $oPaneltoepassingsluiten2gv.FindFirst( $TreeScope_Descendants, $pAndConditiontoesluiten4gv, $ptoesluiten1gv )
            $otoesluiten1gv = ObjCreateInterface( $ptoesluiten1gv, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement )

            If IsObj( $otoesluiten1gv ) Then
                ConsoleWrite( "$otoesluiten1gv OK" & @CRLF )
            Else
                ConsoleWrite("Debug, $otoesluiten1gv nog niet gevonden..." &  @CRLF)
                Sleep(1000) ;hier nog interrupt!!!!
            EndIf
        wend

            ; --- Code Snippets ---

            ConsoleWrite( "--- Code Snippets ---" & @CRLF )

            UIA_WinActivate( $oWindow1 )
            ConsoleWrite( "UIA_WinActivate( $oWindow1 )" & @CRLF )

            UIA_MouseClick( $otoesluiten1gv )

            consolewrite("Debug, exitloop einde script, op naar volgende functie" & @CRLF)
            exitloop

            Else
                ConsoleWrite("Debug, $oText3 (Geen virus nog niet gevonden..." &  @CRLF)
                Sleep(1000) ;hier nog interrupt!!!!
            EndIf

            ;Hier interrupt funcite:

            If $fInterrupt <> 0 Then
            ; The flag was set
            Switch $fInterrupt
                Case 1
                    ConsoleWrite("!Func 1 interrrupted by Func 2" & @CRLF)
                    Case 2
                        ConsoleWrite("!Func 1 interrrupted by HotKey" & @CRLF)
                    Case 3
                        ConsoleWrite("!Func 1 interrrupted by Accelerator" & @CRLF)
                    EndSwitch
                    Return
                 EndIf
                 Sleep(100)
             ;Next
             ConsoleWrite(">Func 1 Ended" & @CRLF)

                    ;einde interrupt functie
                    wend
         EndFunc






Func UIA_MouseClick1( $oElement, $iBoundRectWidth, $bRight = False, $fScale = 0 )
  If Not IsObj( $oElement ) Then Return SetError(1,0,1)

  ; Rectangle
  Local $aRect ; l, t, w, h
  $oElement.GetCurrentPropertyValue( $UIA_BoundingRectanglePropertyId, $aRect )
  If Not IsArray( $aRect ) Then Return SetError(1,0,1)
  $aRect[2] = $iBoundRectWidth
  If $fScale > 1.00 Then
    $aRect[0] = Round( $aRect[0] * $fScale )
    $aRect[1] = Round( $aRect[1] * $fScale )
    $aRect[2] = Round( $aRect[2] * $fScale )
    $aRect[3] = Round( $aRect[3] * $fScale )
  EndIf

  ; Click element
  Local $aPos = MouseGetPos()
  Local $sButton = Not $bRight ? "primary" : "secondary"
  DllCall( "user32.dll", "int", "ShowCursor", "bool", False )
  MouseClick( $sButton, $aRect[0]+$aRect[2]/2, $aRect[1]+$aRect[3]/2, 1, 0 )
  MouseMove( $aPos[0], $aPos[1], 0 )
  DllCall( "user32.dll", "int", "ShowCursor", "bool", True )
EndFunc

 

Edited by MightyWeird

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
  • Recently Browsing   0 members

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