Jump to content

Need best usage of stringinstr


E1M1
 Share

Recommended Posts

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 by E1M1

edited

Link to comment
Share on other sites

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 by E1M1

edited

Link to comment
Share on other sites

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 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

$i value is very strange

#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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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