E1M1 Posted February 15, 2009 Share Posted February 15, 2009 (edited) Whats the best way to check if element List[$i][0] contains any element from all $list2[$n] elements? So it will look like stringinstr(List[$i][0],And here must be all elements of $list2[$n] ) for example List[$i][0] is "Autoit scripter is cool" and $list2[1] is "text" ;$list2[2] is "word"; $list2[3] is "script" Now you can see that $list2[$n] fits in List[$i][0] because $list2[$3] is "script" and List[$i][0] is "Autoit scripter is cool", and now you can see that word "script" is in "Autoit scripter is cool" so return must be List[$i][0] (1 or Ture can be as well). I need it to be optimal so if $list2[$n] is 100 elements long and script have to repeat this search 10 times ( every time List[$i][0] has different value) then it may not eat all cpu. Edited February 15, 2009 by E1M1 edited Link to comment Share on other sites More sharing options...
AoRaToS Posted February 15, 2009 Share Posted February 15, 2009 Use _ArraySearch() or _ArrayFindAll(), you can find them in the helpfile s!mpL3 LAN Messenger Current version 2.9.9.1 [04/07/2019] s!mpL3 LAN Messenger.zip s!mpL3 Link to comment Share on other sites More sharing options...
E1M1 Posted February 15, 2009 Author Share Posted February 15, 2009 (edited) could you make example here please? I still didn't get how I have to code my func. $List = WinList() and $list2 = StringSplit (FileRead(C:\bad_keywords.txt),@crlf,1) and now lets say that if if window title contains string that is in $list2[any] then return window title Edited February 15, 2009 by E1M1 edited Link to comment Share on other sites More sharing options...
AoRaToS Posted February 15, 2009 Share Posted February 15, 2009 (edited) try this: it's from the helpfile only it's a bit stripped down... #include <Array.au3> Local $avArray[6][2] = [ _ ["String0", "SubString0"], _ ["String1", "SubString1"], _ ["String2", "SubString2"], _ ["String3", "Autoit scripter is cool"], _ ["String4", "SubString4"], _ ["String5", "SubString5"]] _ArrayDisplay($avArray, "$avArray") $sSearch = "script" If @error Then Exit ;$sColumn = 1 $iIndex = _ArraySearch($avArray, $sSearch, 0, 0, 0, 1, 0, 1) If @error Then MsgBox(0, "Not Found", '"' & $sSearch & '" was not found.') Else MsgBox(0, "Found", '"' & $sSearch & '" was found in the array at position ' & $iIndex & '.') EndIf Edited February 15, 2009 by AoRaToS s!mpL3 LAN Messenger Current version 2.9.9.1 [04/07/2019] s!mpL3 LAN Messenger.zip s!mpL3 Link to comment Share on other sites More sharing options...
E1M1 Posted February 15, 2009 Author Share Posted February 15, 2009 $i value is very strange expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Version=Beta #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <File.au3> #Include <Array.au3> Opt("GUICloseOnESC", 0) ;~ Opt("OnExitFunc","endscript") Opt("WinTitleMatchMode", 2) Opt("TrayIconHide", 0) DisAllowApp() Func DisAllowApp() $KillData = StringSplit (FileRead(@ScriptDir & "\KillList.txt"),@crlf,1) $var = WinList() For $i = 1 To $KillData[0] For $n = 1 To $KillData[0] If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then MsgBox(0, "Details", $var[$i][0]&" "&$KillData[$n]&" "&$i) EndIf ;~ If StringInStr($winlist[$i][0],$KillData[$n]) Then ;~ MsgBox (1,1,"found") ;~ EndIf Next Next EndFunc ;==>DisAllowApp Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc edited Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now