Search the Community
Showing results for tags 'StringInStr'.
-
What am I missing here? The Help file clearly shows the default for occurrence = 1. But the "Default" keyword seems to be interpreted as -1. ConsoleWrite( "AutoItVersion: " & @AutoItVersion & @CRLF ) Local $S = "ABCDABCD" Local $Start = StringInStr( $S, "AB" ) ConsoleWrite( "$Start = " & $Start & @CRLF ) Local $EndOne = StringInStr($S, "AB", Default, 1, $Start +1 ) ConsoleWrite( "$EndOne = " & $EndOne & @CRLF ) Local $EndDefault = StringInStr($S, "AB", Default, Default, $Start +1 ) ConsoleWrite( "$EndDefault = " & $EndDefault & @CRLF ) Local $EndMinusOne = StringInStr($S, "AB", Default, -1, $Start +1 ) ConsoleWrite( "$EndMinusOne = " & $EndMinusOne & @CRLF ) --------------------------------------------------------------------- AutoItVersion: 3.3.16.1 $Start = 1 $EndOne = 5 $EndDefault = 1 $EndMinusOne = 1
-
Hi guys, really need your help. How can i check every 5 min if my text file include String "Markus". Btw i need this function to run on my Logs file that are updated whenever some event is triggered (logs appear in same txt file). So i did test some codding to test isit possible. But somehow, it only detect for the 1st time String check, and keep coming the same output every time, it didnt check/read on the current txt file that has been updated. For this purpose i update txt file manually so i put String "Markus" and check, and try to remove it agn. Here is my code: $file = FileOpen("c:\hello.txt", 0) $read = FileRead($file) func _CheckString() If StringInStr($read, "Markus") Then $position = StringInStr($read, "Markus") MsgBox(0,"","Alert Found - Logs Line No "&$position, 5) FileClose($file) Else MsgBox(0,"","No Alert found", 5) FileClose($file) EndIf EndFunc $Mins = 0.5 ; i change to fewer min for testing purpose $Timer = TimerInit() While 1 If TimerDiff($Timer) > ($Mins * 60000) Then ; count per minute multiplied by 60sec. _CheckString() ConsoleWrite("30 Sec have passed!" & @CRLF) ; console to see if its running. $Timer = TimerInit() EndIf WEnd
-
Hey there! I've been developing a artificial intelligence. My first hard task was letting the A.I know when a sentence is found in memory with different words What i tried to do here is simply, get all the words in user sentence that could be used as a identifier example: Steve Jobs then identify the sentence purpose with the words we found in the past "for" loop example: Do/Know/You/Who/Steve/Jobs Compare the example in the following matching sentences in memory. 1-Steve jobs was a known person 2-Do you know who barack obama is? 3-Do you know Steve jobs? 4-Do you know who steve jobs is? 5-How much money steve jobs had Then find the sentence that has way more matches than the other ones, remember that if the identifier words were not found (Steve jobs) then the sentence is invalid. Every sentence has a different answer and is important that the right one is chosen. If there's no more than the half of words in matches, then assign a variable the result of function, such as a return but for a global var. I couldn't figure out how to do that with StringRegExp. I honestly need help with detecting identifiers on memory sentences. I would also like to let the AI know typos, meaning that moeny and money means the same thing. Any help is hugely appreciated.
- 10 replies
-
- big data
- artificial intelligence
-
(and 3 more)
Tagged with:
-
Hi guys! I have these checkbox that I'm trying to click on. They have the same inner-text string but a different ID. Sometime there can be as many as 4 checkbox with the same string but the ID is always different. I tried a few methods down below but I'm unable to make any real results. Any suggestions or solutions I would appreciate it very much. <ul><li class="cx-list-item-wrapper" data-day="Aug 2 2018 07:27:37 GMT-0700 (Pacific Daylight Time)"><div class=""><div class="cx-list-item-container"><div class="cx-list-item cx-item-icon-2 pointer-cursor"><div class="cx-item-contents cx-item-time col-md-2"><!-- react-text: 675 -->Morning<!-- /react-text --><!-- react-text: 676 --> <!-- /react-text --></div><div class="cx-item-contents col-md-1"><!-- react-text: 678 -->OTHER<!-- /react-text --><!-- react-text: 679 -- > <!-- /react-text --></div><div class="cx-item-contents col-md-2"><!-- react-text: 681 -->8:30 AM<!-- /react-text --><!-- react-text: 682 --> <!-- /react-text --></div><div class="cx-item-contents col-md-2"><!-- react-text: 684 -->10:30 AM<!-- /react-text --><!-- react-text: 685 --> <!-- /react-text -- ></div><div class="cx-item-contents col-md-1"><!-- react-text: 687 -->SRV<!-- /react-text --><!-- react-text: 688 --> <!-- /react-text --></div></div></div><div class="pull-right cx-listitem-chk"><div><input id="cx_checkbox1" class="cx-fa-chk cx-selfschedule-chk" value="on" type="checkbox"><label for="cx_checkbox1"></label></div></div></div></li><li class="cx-list-item-wrapper" data-day="Aug 2 2018 07:27:37 GMT-0700 (Pacific Daylight Time)"><div class=""><div class="cx-list-item-container"><div class="cx-list-item cx-item-icon-2 pointer-cursor"><div class="cx-item-contents cx-item-time col-md-1"><!-- react-text: 698 -- >Morning<!-- /react-text --><!-- react-text: 699 --> <!-- /react-text --></div><div class="cx-item-contents col-md-1"><!-- react-text: 701 -->OTHER<!-- /react- text --><!-- react-text: 702 --> <!-- /react-text --></div><div class="cx-item-contents col-md-2"><!-- react-text: 704 -->8:30 AM<!-- /react-text --><!-- react-text: 705 --> <!-- /react-text --></div><div class="cx-item-contents col-md-2"><!-- react-text: 707 -->2:30 PM<!-- /react-text --><!-- react-text: 708 -- > <!-- /react-text --></div><div class="cx-item-contents col-md-1"><!-- react-text: 710 -->SRV<!-- /react-text --><!-- react-text: 711 --> <!-- /react-text --></div></div></div><div class="pull-right cx-listitem-chk"><div><input id="cx_checkbox2" class="cx-fa-chk cx-selfschedule-chk" value="on" type="checkbox"><label for="cx_checkbox2"></label></div></div></div></li></ul> I tried the _IETagNameGetCollection() but it only check the box but doesn't fire the event! And I'm unable to submit that without a click action. Func _Box1() $oInputs = _IETagNameGetCollection($oIE, "input") For $oInput In $oInputs If $oInput.id == "cx_checkbox1" Then $oInput.checked = true Next Sleep(10) ToolTip('box1') EndFunc ;==>_Box1 I also tried click by text.The boxes do get check by a click but the problem with that is it will select every box that has the same string. I'm allowed only to check 1 box selection at a time per day for the submit button to work. Any preference to select only the second box and bypass the other? Func _Morning() For $a In _IETagNameGetCollection($oIE, "div") If StringInStr(_IEPropertyGet($a, "innerText"), "Morning") Then _IEAction($a, "click") EndIf Next Sleep(10) ToolTip('Morning selected') EndFunc ;==>Morning The last method I tried was _IEGetObjById(). It doesn't click or respond to the checkbox. Func _Click1() $oChk = _IEGetObjById($oIE, "cx_checkbox1") _IEAction($oChk, 'click') Sleep(20) ToolTip('box1') EndFunc ;==>_Click1
- 6 replies
-
- checkbox
- event fire
-
(and 3 more)
Tagged with:
-
Hi everybody, i have a log file with several entries like the following one: INFO [26.04.2017 11:37:48] [main] XML-Data: <online-activation> <general> <userid>XYZ</userid> <mac-address/> <OU>VG-DE</OU> <ROLE>KDT</ROLE> <FOA>PRO;FC;DOM;MDD</FOA> <BRD>XYZ;IMP</BRD> </general> <applications> <app expiration-date="2017-10-01" name="BB-INFO"/> <app expiration-date="2017-10-01" name="MMSKD"/> <app expiration-date="2017-10-01" name="FM-TOOL"/> <app expiration-date="2017-04-05" name="WEB-BTD"/> <app expiration-date="2017-10-01" name="OFFLINE-BTD"/> <app expiration-date="2017-10-01" name="MDU-UPD"/> <app expiration-date="2017-10-01" name="MDU"/> <app expiration-date="2017-04-05" name="WEB-WDA"/> <app expiration-date="2017-04-05" name="WEB-ETD"/> <app expiration-date="2017-10-01" name="OFFLINE-WDA"/> <app expiration-date="2017-10-01" name="OFFLINE-ETD"/> </applications> </online-activation> I need to collect all the XML-Data, my search doesn't work: Func FileSearch() $j=0 For $i = 0 To UBound($content_array) - 1 $search_result=StringInStr($content_array[$i],$search) If $search_result<>0 Then ReDim $searchResultArray[UBound($searchResultArray) + 1] $searchResultArray [$j] = $content_array[$i] _ArrayDisplay($searchResultArray) $j+=1 EndIf Next EndFunc If i search for "online-activation", it retrieves only the first and the last tag, but not what is within. In addition, when i use FileReadToArray, all the entries between <online-activation> and </online-activation>
-
I have a good handle on how to read a file line by line, and search for a given string. Basically using, FileOpen, FileReadLine, and StringInStr. I have been trying to figure out why my search keeps coming back with no match. For example, if my string line was "Where is Waldy", and I was searching for Waldy that comes back fine. But in my file, Let's say it is Where is "Waldy" So i read that line in and do a search for Waldy, but i comes back with no match since there is quotes around it. Is there a way to resolve this? Here is my actual example The line comes back like this <JposEntry logicalName="LineDisp_iSC480"> I'm searching for LineDisp_iSC480, but its coming back with no match due to the quotes. Thanks in advance, James
- 7 replies
-
- stringinstr
- filereadline
-
(and 1 more)
Tagged with:
-
Hello, I want to be able to search for multiple strings and if any of the strings are found I want it returned which one it is. I've been able to search for multiple strings using the OR command, but I'm not sure how I am supposed to make it return which of my strings is found. I've given an example below If StringInStr($html, Batman) OR StringInStr($html, Superman) Then MsgBox(0, "Success", "The string found was: Superman") EndIf So it will search for the two strings and whichever it founds it will return me with. How can I make that work?
- 18 replies
-
- stringinstr
- search for string
-
(and 1 more)
Tagged with:
-
#include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Local $path="C:\Users\rootx\Desktop\Nuova cartella",$mask = "*.jpg;*.png;*.ico",$Pos $FileArr = _FileListToArrayRec($path,$mask,1,1,1,2) For $x = 1 to UBound($FileArr)-1 If $Pos = StringInStr($FileArr[$x],"-") Then ConsoleWrite("------"&$FileArr[$x]&@CRLF) Else ConsoleWrite($FileArr[$x]&@CRLF) FileDelete($FileArr[$x]) EndIf ConsoleWrite($x&@CRLF) Next ConsoleWrite($x-1&@CRLF) I would write a loop that individuals and delete files that contain this feature.... File name-150x100.jpg, or other -SizexSize But in this case how can I filter properly? File name 150x100-150x100.jpg File name -100-150x100.jpg
-
Hello, As always, sorry for my bad english. here is the code i have #include <File.au3> #include <String.au3> $file1 = "d:\doppioniautoit\international.txt" FileOpen($file1, 0) $file2 = "d:\doppioniautoit\standard.txt" FileOpen($file2, 0) For $i = 1 to _FileCountLines($file1) $line = FileReadLine($file1, $i) $aExtract = _StringBetween($line, "(", ")") ;MsgBox(0, $line, $aExtract[0]) $itime = TimerInit() For $x = 1 to _FileCountLines($file2) $line2 = FileReadLine($file2, $x) Local $iPosition = StringInStr($line2, $aExtract[0], 1) ;Local $iPosition = StringRegExp($line2,$aExtract[0], 0) if $iPosition <> 0 then ;MsgBox(0, "Trovato", $aExtract & " " & $line2) endif ConsoleWrite($line2 & @CRLF) Next ConsoleWrite(@TAB&'Str='&TimerDiff($itime)&' ms'&@lf) MsgBox(0, "TIME", @TAB&'Str='&TimerDiff($itime)&' ms'&@lf) Next FileClose($file1)So, what do i want to do? I try to explain with my poor english Basically, i have 2 text files (see attachments below). They both contains movie titles with Director and Year in this form Movie Title (Director, Year) "Standard.txt" contains, mostly, italian titles. "International.txt", as you can image, contains the internationals one. With the script i would like to search for the Director, Year of "international.txt" in the "standard.txt" file. For example... first row of "international.txt" is "¡Atraco! (Cortés, 2012)". The script takes just the "Cortés, 2012" and it searches for it in the standard. txt file. The simple code i wrote works... I tried using StringInStr and using StringRegExp.. they both need about 2 minutes and 30 seconds (stringinstr is little faster) to process one row. I was wondering... is there any other method to make it faster using autoit? Any help would be much appreciated, thx! standard.txt international.txt
- 36 replies
-
- stringinstr
- stringregexp
-
(and 1 more)
Tagged with:
-
Good Morning All, I'm hoping someone here can work their AutoIT magic I'm doing a pretty "simple" string search in a HUGE variable. But I'm doing the basics almost straight out of the Help File... ( sorry, I'm leaving out my main code for privacy reasons ) Local $hFileOpen = FileOpen($sFilePath, $FO_READ) Local $sFileRead = FileRead($hFileOpen) Local $sEmailPosition01 = StringInStr ($sFileRead, $sEmailAddress )Everything looks good with my troubleshooting I ran IsString against $sFileRead and $sEmailAddress and was okay: "The variable is a string" So then I ran StringLen($sFileRead) and got string length 68352786 Yeah, I know... That's HUGE - But it worked with the older version of AutoIT (upgraded yesterday) v3.3.14.2 Is there an "Excessive" variable I should set?!? lol. Should I search the string a different way maybe? I know the string is in there... but I'm getting a StringInStr @error : 0 @extended: 0 Please help! Thank you all
- 11 replies
-
#include <MsgBoxConstants.au3> #include <array.au3> $File = FileOpen(@DesktopDir & "\email addresses 11-17-2015.txt") $aArray = FileReadToArray($File) For $i=0 To UBound($aArray)-1 Local $x = StringInStr($aArray[$i],"@") If @error Then MsgBox(0,0,$aArray[$i] & " on line " & $i+1 & " is not a valid address.") EndIf Next MSgBox(0,0,"Done")I have a list of 3600 email addresses and I need to check if there is an @ symbol in the email address. This is my code. I only get a message box with "Done" every time no matter what is in the email list. Here's an example list that I want to msgbox "Tedyahoo.com on line 3 is not a valid address." Ted@charter.net Ted@gmail.com Tedyahoo.com Ted@AOL.com
-
_ReplaceStringInFile() RegEx version?
ViciousXUSMC posted a topic in AutoIt General Help and Support
I was working on something last night and decided to use StringRegExpReplace() for a config file, I never noticed that you cant just "overwrite" the file with the update so easily it required a few more pieces of code to work properly. Is this the simplest way (what I used) and while I searched for it and did not find it do we have or will we have a RegEx equivalent for _ReplaceStringInFile()? $sFile = FileRead(@ScriptDir & "\test.txt") $hFile = FileOpen(@ScriptDir & "\test.txt", 2) $sNewContent = StringRegExpReplace($sFile, "(test)", "new$1") FileWrite($hFile, $sNewContent) FileClose($hFile)- 5 replies
-
- regex
- replacestringinfile
-
(and 2 more)
Tagged with:
-
When I am searching a word from a sentence through StringInStr, it is not giving exact match but it is giving the word if the letters in the word are included in it. Ex: If I am searching for a word Sun in a sentence below. Sun is hot today. --> Here it is working as expected. But it is returning a word exist even for below sentence also. even though it is sunday. As sun is there in the word sunday. How to exclude this and only it should return true when it finds the word sun.
- 11 replies
-
- stringinstr
- exact match
-
(and 1 more)
Tagged with:
-
substring search not excluding extra characters
ur posted a topic in AutoIt General Help and Support
I am trying to getan exact word match in searching a substring using function StringInStr. Like my search word is oFSO sentence may contain oFSO or OFSO= and not case-sensitive.so I created conditional syntax as $sentence is the complete sentence and $searchword contains the searching word. If StringInStr($sentence, " "&$searchword&" ") or StringInStr($sentence, " "&$searchword&"=") It is working fine for most cases and it excluding words like ofs,ofs1 ,etc words But if the word is ofso1 (i.e., contains the word we specified + extra characters) then it is not excluding that. Could you please help how to exclude that and write condition so that it will get exact match i.e, oFSO or ofso or OFSO (not case-sensitive). -
Hi guys, I didn't find an answer to my problem in other do until topics, that's why I am here. I need to pause my script until the text in a static control changes to something like "File prepared" or "New image". Here is what I tried: Do Sleep(500) $Status = ControlGetText("Prepare and Resize", "", "[CLASS:Static; Instance:8]") Until StringInStr($Status, "prepared") > 0 AutoIt doesn't like it after "Until" and complains: Statement cannot be just an expression. Is there another way to say that a word shall be included in a static control? Glad for help.
- 2 replies
-
- stringinstr
- do
-
(and 1 more)
Tagged with:
-
Hi, im struggling with this issue, StringInStr could do the trick, but it doesn't seem to support 3 different strings to compare, StringRegExp is messy, i tried some ways, help was no help, so i hope you can. So this will exemplify what i need: $StrDropCheckFolder = StringInStr($__aGUIDropFiles[$i], ".mp3;.wav;.wma", 2) Anything that contains those = true I made the StringRegExp work, but only with one string at a time. Couldn't find in help file the corresponding OR parameter.. and OR doesn't work in StringInStr. Best regards.
- 7 replies
-
- string
- StringInStr
-
(and 1 more)
Tagged with:
-
I've bumped on next problem: I have txt file with bunch of mails, and I want to write script that search for specific one and put it in other txt file. Example: Email1@gmail.com Email2@gmail.com Email3@yahoo.com Email4@hotmail.com Now what I want is to search if domain is @gmail and output entire mail in new file. I have tried StringInString but I have no idea what to do with number of place where is found line starting. I'm pretty sure this should be done with StringCompare but I seams not to be able to find anyone with similar task who have posted online about this. I would appreciate any help or idea you could have and could share with me. Thanks
-
[Resolved]Help me completing this script
Command3r posted a topic in AutoIt General Help and Support
Hello, i'm making this tool to convert "English" letters To "Arabic" letters but i have some problems in reading "input1" Notice: it isn't translator!! here's the script: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> $Form1 = GUICreate("Form1", 257, 155, 339, 282) $Input1 = GUICtrlCreateInput("", 32, 32, 201, 21) $Input2 = GUICtrlCreateInput("", 32, 88, 201, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_RIGHT)) $Label1 = GUICtrlCreateLabel("English", 104, 8, 38, 17) $Button1 = GUICtrlCreateButton("Ta7weel", 96, 120, 75, 25) $Label2 = GUICtrlCreateLabel("Franco", 104, 64, 37, 17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Local $Read1 = GUICtrlRead($Input1) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; If StringInStr($Read1, "3") Then _GUICtrlEdit_AppendText($Input2, "ع") EndIf If StringInStr($Read1, "3'") Then _GUICtrlEdit_AppendText($Input2, "غ") EndIf If StringInStr($Read1, "5") Then _GUICtrlEdit_AppendText($Input2, "خ") EndIf If StringInStr($Read1, "7") Then _GUICtrlEdit_AppendText($Input2, "ح") EndIf If StringInStr($Read1, "9") Then _GUICtrlEdit_AppendText($Input2, "ص") EndIf If StringInStr($Read1, "a") Then _GUICtrlEdit_AppendText($Input2, "ا") EndIf If StringInStr($Read1, "b") Then _GUICtrlEdit_AppendText($Input2, "ب") EndIf If StringInStr($Read1, "c") Then _GUICtrlEdit_AppendText($Input2, "س") EndIf If StringInStr($Read1, "d") Then _GUICtrlEdit_AppendText($Input2, "د") EndIf If StringInStr($Read1, "e") Then _GUICtrlEdit_AppendText($Input2, "ي") EndIf If StringInStr($Read1, "f") Then _GUICtrlEdit_AppendText($Input2, "ف") EndIf If StringInStr($Read1, "g") Then _GUICtrlEdit_AppendText($Input2, "ج") EndIf If StringInStr($Read1, "h") Then _GUICtrlEdit_AppendText($Input2, "ه") EndIf If StringInStr($Read1, "i") Then _GUICtrlEdit_AppendText($Input2, "ي") EndIf If StringInStr($Read1, "j") Then _GUICtrlEdit_AppendText($Input2, "ج") EndIf If StringInStr($Read1, "k") Then _GUICtrlEdit_AppendText($Input2, "ك") EndIf If StringInStr($Read1, "l") Then _GUICtrlEdit_AppendText($Input2, "ل") EndIf If StringInStr($Read1, "m") Then _GUICtrlEdit_AppendText($Input2, "م") EndIf If StringInStr($Read1, "n") Then _GUICtrlEdit_AppendText($Input2, "ن") EndIf If StringInStr($Read1, "o") Then _GUICtrlEdit_AppendText($Input2, "و") EndIf If StringInStr($Read1, "p") Then _GUICtrlEdit_AppendText($Input2, "ب") EndIf If StringInStr($Read1, "q") Then _GUICtrlEdit_AppendText($Input2, "ق") EndIf If StringInStr($Read1, "r") Then _GUICtrlEdit_AppendText($Input2, "ر") EndIf If StringInStr($Read1, "s") Then _GUICtrlEdit_AppendText($Input2, "س") EndIf If StringInStr($Read1, "t") Then _GUICtrlEdit_AppendText($Input2, "ت") EndIf If StringInStr($Read1, "u") Then _GUICtrlEdit_AppendText($Input2, "و") EndIf If StringInStr($Read1, "v") Then _GUICtrlEdit_AppendText($Input2, "ف") EndIf If StringInStr($Read1, "w") Then _GUICtrlEdit_AppendText($Input2, "و") EndIf If StringInStr($Read1, "x") Then _GUICtrlEdit_AppendText($Input2, "ق") EndIf If StringInStr($Read1, "y") Then _GUICtrlEdit_AppendText($Input2, "ي") EndIf If StringInStr($Read1, "z") Then _GUICtrlEdit_AppendText($Input2, "ز") EndIf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EndSwitch WEnd the script working well. but the problem is arranging the output letters e.g. i want convert this word "fas"... it must be "فاس" but it converted to "افس". problem reason: autoit has read "A" letter before "F" & "S" so output will be arranged as reading. what i need: convert and arragne "Arabic" letters wherever it is as "English" letters. !! e.g. A= 1 B= 2 C= 3 D=4 Text what will be converted: "CBDA" so it must be convert like that "3241" but in the script above it converting like that "123". sorry for bad english and thanks for help Resolved: Edit: resolved- 9 replies
-
- If
- StringInStr
-
(and 1 more)
Tagged with: