Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/29/2021 in all areas

  1. 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
    1 point
  2. Is it homework? Whats the bigger context Can your arrays be bigger? Do you need speed? Is your array precoded or coming from a file or database? You could sort first run 1/n the size of the array in steps of n and add more compares in the same loop (probably not faster) .... You cannot run in parallel in AutoIt (you could however embed C#)
    1 point
  3. Because it´s no "ASM" code, it can´t be "easily" assembled (by i.e. FASM/MASM) and converted to AutoIt. AFAIK the code is a (part of a) CheatEngine Script...and of cause could be transformed to AutoIt with some lines of code. That requires the knowledge of some details of the program the call is pointing to.....but the OP/TS mentioned All said.
    1 point
  4. This is a continuation of Custom drawn TreeViews and ListViews. However, only with respect to listviews. The crucial difference between the new and the old code is that the new code is a complete UDF and therefore much easier to use. Because the UDF is about colors and fonts in listview items and subitems, it's only for listviews in Details or Report view. Main features The UDF supports the following main features. Colors and fonts: 1 Single items/subitems Back colors Fore colors Fonts and styles 2 Colors/fonts for entire columns 3 Alternating colors (entire listview) Alternating colors for rows, columns or both Both default and alternating color can be set Number of rows/columns between color change can be set 4 Custom default colors/font instead of standard default colors/font Custom default back and fore colors can be set for Normal listview items (instead of white and black) Selected listview items (instead of dark blue and white) Unfocused selected items (instead of button face and black) 5 Colors for selected listview items Back and fore colors for selected items when listview has focus Back and fore colors for selected items when listview has not focus Features 1, 2 and 3 cannot be mixed together. 4 and 5 can be mixed with the previous features. 5 extends the functionality of the previous features by adding colors to selected items. 5 cannot be used alone. Listviews: Multiple listviews Native and non-native listviews Native and non-native listview items The UDF can be used with existing listviews WM_NOTIFY message handlers: WM_NOTIFY message handlers can be used completely as usual The UDF can be used with existing WM_NOTIFY message handlers Colors and fonts for single listview items/subitems are stored in an array. The index in this array for a given listview item is stored in ItemParam. Except for this usage of ItemParam nothing in the UDF assumes that listviews or items/subitems are created in a certain way, or that any WM_NOTIFY handlers exists or are designed in a certain way. It should be easy to use the UDF with existing listviews with or without a WM_NOTIFY message handler or other message handlers. WM_NOTIFY message handlers Colors and fonts in listviews are implemented through custom draw notifications in the form of WM_NOTIFY messages. A WM_NOTIFY message handler is needed to implement colors/fonts. If a listview is included in a GUI and a little more than just very basic functionality is wanted, another WM_NOTIFY handler is soon needed to implement this functionality. To register a WM_NOTIFY handler you use the function GUIRegisterMsg. This function can register only one message handler at a time for the same message type. The result of code like this is that only WM_NOTIFY2 message handler is working: GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY1" ) ; Register WM_NOTIFY1 GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY2" ) ; Register WM_NOTIFY2 (unregisters WM_NOTIFY1) This makes it difficult to implement colors/fonts in a UDF, if you at the same time want to implement advanced functionality in your own code. A solution is to register the WM_NOTIFY message handler, that takes care of custom draw notifications, in a different way. This can be done by a technique called subclassing, which is implemented through the four functions SetWindowSubclass, GetWindowSubclass, RemoveWindowSubclass and DefSubclassProc (coded in WinAPIShellEx.au3). Subclassing Subclassing a window (or control) means to create a message handler for the window, that will receive messages to the window before the original message handler for the window. This section is information on the implementation of a WM_NOTIFY message handler through subclassing: The UDF The UDF is implemented in UDFs\ListViewColorsFonts.au3. This is a list of the most important functions copied from the UDF (around line 200): ; Initiating and exiting ; ---------------------- ; ListViewColorsFonts_Init ; ListViewColorsFonts_Exit ; ; Set colors/fonts for items/subitems ; ----------------------------------- ; ListViewColorsFonts_SetItemColors ; ListViewColorsFonts_SetItemFonts ; ListViewColorsFonts_SetItemColorsFonts ; ; Set colors/fonts for entire listview ; ------------------------------------ ; ListViewColorsFonts_SetColumnColorsFonts ; ListViewColorsFonts_SetAlternatingColors ; ListViewColorsFonts_SetDefaultColorsFonts ; ; Maintenance functions ; --------------------- ; ListViewColorsFonts_Redraw Some of the functions in the complete list in the file are not coded in this version. To use the UDF you first calls ListViewColorsFonts_Init which stores information about the listview and the parent window, and creates the subclass that takes care of the actual drawing of the colors and fonts. Then you call one or more of the ListViewColorsFonts_Set-functions to define the colors and fonts. Depending on the functions you might also need to call ListViewColorsFonts_Redraw. And that's all. Finally you can call ListViewColorsFonts_Exit to remove the subclass before the script exits. If you don't call ListViewColorsFonts_Exit it's called automatically by the UDF. This is the syntax for ListViewColorsFonts_Init and the information about $fColorsFonts flag also copied from ListViewColorsFonts.au3: ; ListViewColorsFonts_Init( $idListView, $fColorsFonts = 7, $iAddRows = 100, $bNative = False ) ; $idListView - Listview control ID or handle ; $fColorsFonts - Specifies options for usage of colors and fonts in the listview. Add required options together. ; 1: Back colors for items/subitems ; Can not be specified separately in this version ; 2: Fore colors for items/subitems ; Can not be specified separately in this version ; 4: Fonts and styles for items/subitems ; Can not be specified separately in this version ; 7: Back and fore colors, fonts and styles ; Flags 1/2/4 are combined in flag 7 in this version ; ; 8: Colors/fonts for entire columns ; ; 16: Alternating row colors (for entire listview) ; 32: Alternating column colors (for entire listview) ; ; 64: Custom default colors and font (for entire listview) ; Custom default back and fore colors can be set for ; - Normal listview items (instead of white and black) ; - Selected listview items (instead of dark blue and white) ; - Unfocused selected listview items (instead of button face and black) ; ; 128: Colors for selected items when listview has focus ; 256: Colors for selected items when listview has not focus The limitations with respect to flags 1, 2 and 4 in this version is only a matter of optimizations. It has nothing to do with features. Drawing of selected items is largely controlled by Windows. A lot of extra code is needed to implement custom colors for selected items through flags 128 and 256. For $fColorsFonts flag is further noted that: ; - Flags 1/2/4 can be combined in a total of seven different ways ; - Flags 1/2/4 (items/subitems), flag 8 (columns) and flags 16/32 (listview) cannot be combined ; - Flag 64 is used to replace the standard default colors/font by custom default colors/font ; Flag 64 can be used alone or in combination with flags 1-32 ; Custom default colors/font must be set before all other colors/fonts ; Flag 64 leads to some restrictions on the features for items/subitems (flags 1/2/4) ; - Flags 128/256 extends the functionality of flags 1-64 by adding colors to selected items ; Flags 128/256 cannot be used alone An array $aListViewColorsFontsInfo is used to store information about the listview, the parent window and the usage of colors/fonts in the listview. For flags 1/2/4 about single items/subitems another array $aListViewColorsFonts is used to store the colors and fonts for the items and subitems. The number of columns in this array depends on whether the flags 128/256 are set or not. The first 160 lines in the UDF contains information about these arrays. For flags 1/2/4 ItemParam field in the listview is used to store the zero based row index in $aListViewColorsFonts for a given listview item. For native listview items created with GUICtrlCreateListViewItem the existing value of ItemParam (control ID) is used as index in an intermediate array $aListViewColorsFonts_Index, and $aListViewColorsFonts_Index holds the index in $aListViewColorsFonts stored as index+1. For non-native listview items the index in $aListViewColorsFonts is stored in ItemParam as -index-20. For non-native listview items an existing value of ItemParam is overwritten. The best way to add colors and fonts to listviews is to put each listview in its own child window. The child window should not contain any other controls, and it should have the same size as the listview. However, this is not a requirement. See the UDF for documentation of the other functions. The implementation of the functions starts in line 230 and onwards. The UDF also contains a group of internal functions. Among other the subclass callback functions to draw the colors and fonts in response to NM_CUSTOMDRAW notifications from the listview. So far the UDF contains seven callback functions which starts around line 2100 and runs over the next 1300 lines nearly to the bottom of the file. The code This section is about some code details related partly to the subclass callback functions and partly to drawing of selected items. Subclass callback functions: Drawing of selected items: In the current version of the UDF the callback function that is implemented to draw single items/subitems ($fColorsFonts = 1/2/4) is the function that can handle all features ($fColorsFonts = 1+2+4 = 7). If only a part of the features is needed, it's possible to create smaller and faster functions, which only implements this part of the features. These functions (six functions in total) are postponed to next version. Features A few comments on the features. The main features in terms of colors and fonts are (a repeat of the list in top of post): 1 Single items/subitems 2 Colors/fonts for entire columns 3 Alternating colors (entire listview) 4 Custom default colors/font instead of standard default colors/font 5 Colors for selected listview items 1, 2 and 3 are features for different kind of elements in the listview and cannot be mixed together. 4 can be used either as an independent feature or mixed with 1, 2 or 3. 5 cannot be used as an independent feature but can only be used together with 1, 2, 3 or 4. 5 extends the functionality of these features by adding colors to selected items. When features 1, 4 and 5 are mixed together, it may look as shown in the following illustrations (screen dumps of examples 3.1 and 4.1 in folder \Examples\5) Selected items\). The first illustration shows how it looks when colors for single items/subitems are mixed with colors for selected items: In the upper picture rows 3-6 are provided with back and fore colors. All subitems in row 3 and 4. Only a few subitems in row 5 and 6. The rows are normal (unselected) rows. In the middle picture rows 2-7 are selected and the listview has focus. Rows 3-6 are also provided with back and fore colors for selected items. In the lower picture rows 2-7 are selected but the listview has not focus. Rows 3-6 are also provided with back and fore colors for selected but unfocused items. In the second illustration the standard default colors are replace with custom default colors. The standard default back and fore colors are: Normal (unselected) items: White and black Selected items in focused listview: Dark blue and white Selected items in unfocused listview: Button face and black These custom default colors are used in the illustration: Normal (unselected) items: Light green and brown Selected items in focused listview: Shiny green (chartreuse) and black Selected items in unfocused listview: Dark green and black Examples Two folders with examples is included in the zip below. The first folder is named Examples and contains examples about the usage of the functions in the UDF. The second folder is named UDF topics and contains examples related to the implementation of the UDF. It's about the use of the subclassing technique as a substitute for a WM_NOTIFY message handler. Particularly about the message flow and performance issues. These examples are addressed in next section. The Examples folder contains these subfolders and files: 0) UDF examples\ - The small examples from the documentation of the functions in the UDF 1) Items-subitems\ - Colors and fonts for single items/subitems 2) Entire columns\ - Colors and fonts for entire columns 3) Alternating colors\ - Alternating row/column colors in an entire listview 4) Custom defaults\ - Replace standard default colors/font with custom defaults 5) Selected items\ - Colors for selected items when listview has focus and has not focus 6) Help file examples\ - Shows how to add colors to a few examples from AutoIt Help file 7) Original examples\ - An implementation of the examples in the old thread with this UDF Listview templates\ - A collection of listview templates ready to add colors/fonts Features demo.au3 - A brief demonstration of all features No colors or fonts.au3 - Reference example All examples runs on Windows XP and later without any performance issues. Folder 1 - 5 demonstrates the five main color/font features listed in top of post. In most of the subfolders you can find a _Readme.txt file with a brief description of the examples. Multiple selections is enabled in most listviews. A few examples will not pass an Au3Check. In particular the examples in subfolder 1 and 2 and the examples in UDF topics folder (see next section) were used to test the subclassing technique as a substitute for a WM_NOTIFY message handler. More information about some of the examples: Examples\0) UDF examples\0) ListViewColorsFonts_Init\Example 1.au3: #include <GUIConstantsEx.au3> #include "..\..\..\UDFs\ListViewColorsFonts.au3" #include "..\..\..\UDFs\GuiListViewEx.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Create GUI Local $hGui = GUICreate( "ListViewColorsFonts_Init\Example 1", 420, 200, -1, -1, $GUI_SS_DEFAULT_GUI-$WS_MINIMIZEBOX ) ; Create ListView Local $idListView = GUICtrlCreateListView( "", 10, 10, 400, 180, $GUI_SS_DEFAULT_LISTVIEW-$LVS_SINGLESEL, $WS_EX_CLIENTEDGE ) _GUICtrlListView_SetExtendedListViewStyle( $idListView, $LVS_EX_DOUBLEBUFFER+$LVS_EX_FULLROWSELECT ) Local $hListView = GUICtrlGetHandle( $idListView ) ; Reduces flicker ; Add columns to ListView _GUICtrlListView_AddColumn( $idListView, "Column 1", 94 ) _GUICtrlListView_AddColumn( $idListView, "Column 2", 94 ) _GUICtrlListView_AddColumn( $idListView, "Column 3", 94 ) _GUICtrlListView_AddColumn( $idListView, "Column 4", 94 ) ; Fill ListView Local $iItems = 100 For $i = 0 To $iItems - 1 GUICtrlCreateListViewItem( $i & "/Column 1|" & $i & "/Column 2|" & $i & "/Column 3|" & $i & "/Column 4", $idListView ) Next ; Perform initializations to add colors/fonts to single items/subitems ListViewColorsFonts_Init( $idListView, 7 ) ; $fColorsFonts = 7, ( $iAddRows = 100, $bNative = False ) ; Set a green back color for an entire item and a yellow back color for a single cell ListViewColorsFonts_SetItemColors( $idListView, 3, -1, 0xCCFFCC ) ; Green back color for entire item ListViewColorsFonts_SetItemColors( $idListView, 3, 2, 0xFFFFCC ) ; Yellow back color for cell 2 in item ; Force an update of local variables in drawing function ListViewColorsFonts_Redraw( $idListView ) ; Adjust height of GUI and ListView to fit ten rows Local $iLvHeight = _GUICtrlListView_GetHeightToFitRows( $hListView, 10 ) WinMove( $hGui, "", Default, Default, Default, WinGetPos( $hGui )[3] - WinGetClientSize( $hGui )[1] + $iLvHeight + 20 ) WinMove( $hListView, "", Default, Default, Default, $iLvHeight ) ; Show GUI GUISetState( @SW_SHOW ) ; Message loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Delete color/font info for listview ListViewColorsFonts_Exit( $idListView ) GUIDelete() EndFunc UDF topics The examples in UDF topics folder is about the use of subclassing as a substitute for a WM_NOTIFY message handler. Particularly about the message flow and performance issues. These examples illustrates some of the issues, that was discussed in the Subclassing section above, with code. The UDF topics folder contains these subfolders: 1) Subclassing\ - Creating listviews in GUI or child windows? 2) Performance\ - How many listviews can you create in GUI? More information about the examples: Next version In The code section above is already mentioned a number of subclass callback functions which are postponed to next version. The purpose of these additional functions is merely to optimize the code in terms of speed. A number of ListViewColorsFonts_Get-functions to complement the corresponding ListViewColorsFonts_Set-functions are also deferred to next version. For single items/subitems ($fColorsFonts = 1/2/4) colors and fonts are stored in $aListViewColorsFonts array which again is stored in $aListViewColorsFontsInfo. The three functions ListViewColorsFonts_SetItemColors / SetItemFonts / SetItemColorsFonts are used to update $aListViewColorsFonts item by item or subitem by subitem. It would be much faster to update $aListViewColorsFonts directly. Two functions are needed to get a copy of the array from $aListViewColorsFontsInfo and store the array again after the updates. And there is also a need for a couple of examples to illustrate the technique. Examples to dynamically update colors and fonts are missing in this version. Perhaps there is also a need for a few functions to support dynamically updates. For non-native listviews created with _GUICtrlListView_Create it's not uncommon to use ItemParam to store a user defined value. If index in $aListViewColorsFonts is stored in ItemParam, it's no longer possible to use ItemParam for such purposes. A couple of functions to give the user an opportunity to still be able to store a user defined value would be nice. Several global variables are defined in this version. They will be removed in the next version except for a few variables which probably will need to be global in performance terms. If there will be reported any issues or problems in this version, they of course also need to be addressed. The next version should be ready in 2-3 months, and it should also be the final version. Zip file The zip is structured in this way Examples\ UDF topics\ UDFs\ ListViewColorsFonts.au3 GuiImageListEx.au3 GuiListViewEx.au3 NamedColors.au3 OtherColors.au3 NamedColors.au3 contains global constants of named colors copied from .NET Framework Colors Class. You need AutoIt 3.3.10 or later. Tested on Windows 7 32/64 bit and Windows XP 32 bit. Comments are welcome. Let me know if there are any issues. (Set tab width = 2 in SciTE to line up comments by column.) ListViewColorsFonts.7z
    1 point
  5. JohnOne

    Absolute Beginners

    Here is a little tutorial I decided to make. (yes another tutorial) It is intended for people with absolutely no knowledge of programming/scripting at all. It also assumes you do not know how to use autoit3 help file. What it does assume, is that you have installed autoit3 and scite4autoit which can be found here Autoit > Scite4autoit The most important thing to know, is how to navigate and use the helpfile Please do not underestimate how valuable this resource is. By default the help file is located in your myprograms or myprogramsx86 of you OS drive in the folder AutoIt3 It looks like this with the ? on it, click it Once the helpfile loads you will see essentially two panels, the one on the left is about navigation The one on the right is about information, and for now, just focus on the index tab and click it to see something like this in the left panel Notice it says "Type in the keyword to find", this is where we can find what we are looking for. For example, if I want to find a string function, or browse all the string functions, I simply type "string" into the field below the prompt, and it navigates automatically to the items in the index, like so. If you highlight one of the items in the list and hit enter, or double click on an item, it will bring up information about that item in the right side panel, like so. Above I clicked on the String function and it shows me everything i need to know about that function. Firstly, it tells me in essence what it does. "Returns the string representation of an expression." Secondly, it shows me how to enter the function into scite editor "String ( expression )" In the scope of this post, the expession here is the paramater we pass to the function for processing. A paramater is any variable or literal we put inside the braces of a function. It also tells me the return value - "Returns a string." - a string it what is between those two quotes (text if you will) So what is a return value? Its what the function pumps out after you pass it the correct paramaters, you can test it in the example at the bottom of the right panel. But not before you take a look at another important part of the information, The remarks. "Maximum string length is 2147483647 characters (but keep in mind that no line in an AutoIt script can exceed 4095 characters.)" Here its telling us that if we put a string of over 4095 characters on one line in our script, it will fail. Never skip the remarks, it will cost you valuable time and cause you headaches. Every time you are going to use a function, you should have that function open in the helpfile and refer to it every step of the way. All the information in that panel is important, read it all, and then, notice the little button at the bottom of the example entitled "Open this Script", press that, and the script will automagically open in your scite4autoit editor, and is ready to run, by hitting the F5 key Q. What is a variable? A. $this_is_a_variable = "this is a literal string"; A variable will always have the $ at the beginning and never have a space in it (those are rules) Look at the example $var = String(10) ;$var is the string "10" ;$var is the variable here, and 10 is a literal paramater passed to the String function. Lets take the String function out of the equasion and consider this statement (in the scope of this post a statement is information you type into scite which is telling autoit3 something it needs to know) $var = 10 Here the variable $var is now equal to the literal value 10, it is named a variable because it can change its value. $var = $var + 1 $var is now equal to 11, 10 however, will always be 10. Lets have a look at another function, you remember how to find what we need in the helpfile? then find FileRead. Heres what it tells us. Read in a number of characters from a previously opened text file. This means it will read into the variable it is assigned, (think $var) the amount of individual characters we want from a file that autoit3 has already opened. FileRead ( "filehandle/filename" [, count] ) This is like a prototype of the function we will enter into our editor, notice the bracets "[" and "]" they are telling us that this paramater is optional! more below. Parameters filehandle/filename - The handle of a file, as returned by a previous call to FileOpen. Alternatively you may use a string filename as the first parameter. Forget filehandle for now, filename here is the path to the file we want to read from, for example "c:usersscriptsmyfile.txt" count - [optional] The number of characters to read. Default read the entire file. Its quite common for beginners to misunderstand these [ and ], you dont type them literally into your script, they are just to let you know that you can completely leave out that paramater if you do not need it. In this case, if you want to read the whole file into your variable ($var) you would leave out everything between and including those bracets. If you do need it you would remove the bracets and enter your paramater. Return Value Success: Returns the binary/string read. @extended is set to the number of bytes/characters returned. This tells us the function will return a string if we gave it a filename as a paramater, since we are reading the file, the string will be the contents of the file. Special: Sets @error to -1 if end-of-file is reached. @error information tells us information about why the call to a function may have failed. It is important to check the @error state after each function you use. Failure: Sets @error to 1 if file not opened in read mode or other error. Looking at the example usually shows you how to check for errors. Remarks If a filename is given rather than a file handle - the file will be opened and closed during the function call - for parsing large text files this will be much slower than using filehandles. Note: Do not mix filehandles and filenames, i.e., don't FileOpen a file and then use a filename in this function. Use either filehandles or filenames in your routines, not both! Both ANSI and UTF16/UTF8 text formats can be read - AutoIt will automatically determine the type. A file can be read as binary(byte) data by using FileOpen with the binary flag - in this case count is in bytes rather than characters. There are plenty of good tutorials on this forum created by various members, which is why it is important to know how to search the forums. But hang on, this tutorial is about how to use the helpfile, so cast your mind way back to when we learnt how to find what we need It was typing it into the index tab prompt field, so type "tutorial" into that, and you will find basic tuts in their also.
    1 point
×
×
  • Create New...