fas Posted December 16, 2021 Posted December 16, 2021 Hello Everyone, I am new in this I want to know. How to copy some values(numbers) from a .txt Each line got 2 values separated with ","(comma) and there are so many lines. What I want to do is copy 1st value paste it to a box on my screen and then copy 2nd value and paste it to 2nd box which is next to the 1st box on screen then press search button once it`s done go to 2nd line then 3rd line of the same .txt file and onward and do the same. Content of the file looks like this. i.e, from 1st line I want to copy "220" and paste it to a location which I can find using "PixelSearch" or using coordinates then copy "290" which is 2nd value in first line and paste it to another location next to first location. .txt file format will remain same but lines can varies. (220,290) test (208,23) cool (295,30) school (25,133) gem (26,321) washed (251,132) cheers (35,182) look (151,171) dare (36,20) morning (27,344) good (362,19) mare9 (182,125) Night (345,30) brilliant (353,162) tom
ad777 Posted December 16, 2021 Posted December 16, 2021 (edited) this code help ya take 10 min to coded: expandcollapse popup;(220,290) test MsgBox(0,"", _ReadItemLeft("txt.txt",1));it will read 220 by the line (1) MsgBox(0,"", _ReadItemRight("txt.txt",1));it will read 290 by the line (1) Func _ReadItemRight($filename,$linenumber) Local $add,$add2,$eread,$i FileReadToArray($filename) For $i = 1 To @extended Step 1 $eread = FileReadLine($filename,$linenumber) $ia = StringInStr($eread,",") Do $ia = $ia + 1 if StringMid($eread,$ia,1) = "," or StringMid($eread,$ia,1)= ")" Then Else $add &= StringMid($eread,$ia,1) EndIf Until StringMid($eread,$ia,1) = ")" Return $add ContinueLoop Next EndFunc Func _ReadItemLeft($filename,$linenumber) Local $add,$add2,$eread,$i FileReadToArray($filename) For $i = 1 To @extended Step 1 $eread = FileReadLine($filename,$linenumber) $ia = StringInStr($eread,"(") Do $ia = $ia + 1 if StringMid($eread,$ia,1) = "," or StringMid($eread,$ia,1)= ")" Then Else $add &= StringMid($eread,$ia,1) EndIf Until StringMid($eread,$ia,1) = "," Return $add ContinueLoop Next EndFunc Edited December 16, 2021 by ad777 none
fas Posted December 16, 2021 Author Posted December 16, 2021 50 minutes ago, ad777 said: this code help ya take 10 min to coded: Global $add,$eread,$i ;(220,290) test MsgBox(0,"", _ReadItemRight("txt.txt",1,3));it will read 290 by the line (1) MsgBox(0,"", _ReadItemLeft("txt.txt",1,3));it will read 220 by the line (1) Func _ReadItemLeft($filename,$linenumber,$count) FileReadToArray($filename) For $i = 1 To @extended Step 1 $eread = FileReadLine($filename,$linenumber) Do $i = $i +1 if StringMid($eread,$i,1) = "," or StringMid($eread,$i,1)= ")" Then Else $add &= StringMid($eread,$i,1) EndIf Until StringMid($eread,$i,1) = ")" Return StringLeft($add,$count) ContinueLoop Next EndFunc Func _ReadItemRight($filename,$linenumber,$count) FileReadToArray($filename) For $i = 1 To @extended Step 1 $eread = FileReadLine($filename,$linenumber) Do $i = $i +1 if StringMid($eread,$i,1) = "," or StringMid($eread,$i,1)= ")" Then Else $add &= StringMid($eread,$i,1) EndIf Until StringMid($eread,$i,1) = ")" Return StringRight($add,$count) ContinueLoop Next EndFunc Thanks. But it doesn`t do what I was looking for. maybe I am not clear about what I mentioned earlier. I want to copy first value i.e, 220 and paste it to a search bar on a application, then copy same line 2nd value copy and paste it to another search bar on the application and then press the search button. And continuously doing it until the lines finished. I hope I mentioned clearly. Thanks for your help again. Cheers.
ad777 Posted December 16, 2021 Posted December 16, 2021 (edited) i dont get it clearly but may this help ya: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 623, 449, 192, 114) $Input1 = GUICtrlCreateInput("Input1", 80, 64, 121, 21) $Input2 = GUICtrlCreateInput("Input2", 264, 64, 121, 21) $Button1 = GUICtrlCreateButton("Search", 176, 200, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 FileReadToArray("txt.txt") For $i = 1 To @extended Step 1 if _ReadItemLeft("txt.txt",$i) = GUICtrlRead($Input1) Then MsgBox(64,"","Found At:"&$i) EndIf if _ReadItemRight("txt.txt",$i) = GUICtrlRead($Input2) Then MsgBox(64,"","Found At:"&$i) EndIf Next EndSwitch WEnd ;(220,290) test Func _ReadItemRight($filename,$linenumber) Local $add,$add2,$eread,$i FileReadToArray($filename) For $i = 1 To @extended Step 1 $eread = FileReadLine($filename,$linenumber) $ia = StringInStr($eread,",") Do $ia = $ia + 1 if StringMid($eread,$ia,1) = "," or StringMid($eread,$ia,1)= ")" Then Else $add &= StringMid($eread,$ia,1) EndIf Until StringMid($eread,$ia,1) = ")" Return $add Next EndFunc Func _ReadItemLeft($filename,$linenumber) Local $add,$add2,$eread,$i FileReadToArray($filename) For $i = 1 To @extended Step 1 $eread = FileReadLine($filename,$linenumber) $ia = StringInStr($eread,"(") Do $ia = $ia + 1 if StringMid($eread,$ia,1) = "," or StringMid($eread,$ia,1)= ")" Then Else $add &= StringMid($eread,$ia,1) EndIf Until StringMid($eread,$ia,1) = "," Return $add Next EndFunc or maybe this: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 623, 449, 192, 114) $Input1 = GUICtrlCreateInput("Input1", 80, 64, 121, 21) $Input2 = GUICtrlCreateInput("Input2", 264, 64, 121, 21) $Button1 = GUICtrlCreateButton("Search", 176, 200, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $i While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $i = $i + 1 GUICtrlSetData($Input1,_ReadItemLeft("txt.txt",$i)) GUICtrlSetData($Input2,_ReadItemRight("txt.txt",$i)) EndSwitch WEnd ;(220,290) test Func _ReadItemRight($filename,$linenumber) Local $add,$add2,$eread,$i FileReadToArray($filename) For $i = 1 To @extended Step 1 $eread = FileReadLine($filename,$linenumber) $ia = StringInStr($eread,",") Do $ia = $ia + 1 if StringMid($eread,$ia,1) = "," or StringMid($eread,$ia,1)= ")" Then Else $add &= StringMid($eread,$ia,1) EndIf Until StringMid($eread,$ia,1) = ")" Return $add Next EndFunc Func _ReadItemLeft($filename,$linenumber) Local $add,$add2,$eread,$i FileReadToArray($filename) For $i = 1 To @extended Step 1 $eread = FileReadLine($filename,$linenumber) $ia = StringInStr($eread,"(") Do $ia = $ia + 1 if StringMid($eread,$ia,1) = "," or StringMid($eread,$ia,1)= ")" Then Else $add &= StringMid($eread,$ia,1) EndIf Until StringMid($eread,$ia,1) = "," Return $add Next EndFunc Edited December 16, 2021 by ad777 none
fas Posted December 16, 2021 Author Posted December 16, 2021 3 minutes ago, ad777 said: i dont get it clearly but may this help ya: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 623, 449, 192, 114) $Input1 = GUICtrlCreateInput("Input1", 80, 64, 121, 21) $Input2 = GUICtrlCreateInput("Input2", 264, 64, 121, 21) $Button1 = GUICtrlCreateButton("Search", 176, 200, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 FileReadToArray("txt.txt") For $i = 1 To @extended Step 1 if _ReadItemLeft("txt.txt",$i) = GUICtrlRead($Input1) Then MsgBox(64,"","Found At:"&$i) EndIf if _ReadItemRight("txt.txt",$i) = GUICtrlRead($Input2) Then MsgBox(64,"","Found At:"&$i) EndIf Next EndSwitch WEnd ;(220,290) test Func _ReadItemRight($filename,$linenumber) Local $add,$add2,$eread,$i FileReadToArray($filename) For $i = 1 To @extended Step 1 $eread = FileReadLine($filename,$linenumber) $ia = StringInStr($eread,",") Do $ia = $ia + 1 if StringMid($eread,$ia,1) = "," or StringMid($eread,$ia,1)= ")" Then Else $add &= StringMid($eread,$ia,1) EndIf Until StringMid($eread,$ia,1) = ")" Return $add Next EndFunc Func _ReadItemLeft($filename,$linenumber) Local $add,$add2,$eread,$i FileReadToArray($filename) For $i = 1 To @extended Step 1 $eread = FileReadLine($filename,$linenumber) $ia = StringInStr($eread,"(") Do $ia = $ia + 1 if StringMid($eread,$ia,1) = "," or StringMid($eread,$ia,1)= ")" Then Else $add &= StringMid($eread,$ia,1) EndIf Until StringMid($eread,$ia,1) = "," Return $add Next EndFunc Ok let me try to explain again. for ex. there is a file on desktop named test.txt test.txt file content(file content will be change once I completed 1 file) (220,290) test(208,23) cool(295,30) school(25,133) gem(26,321) washed(251,132) cheers(35,182) look(151,171) dare(36,20) morning(27,344) good(362,19) mare9 (182,125) Night (345,30) brilliant(353,162) tom so what I want is each line got 2 numeric figures separated by ","(comma) for ex. (220,290) test so script can read 1st numeric figure of 1st line then copy it and paste it to a search bar then copy 2nd figure of 1st line copy it and paste on 2nd bar and hit a button which is search button. then go to 2nd line 1st numeric figure then 2nd line 2nd figure and do the same till lines ended. If anyone can do it it will a great help. I am clueless
ad777 Posted December 16, 2021 Posted December 16, 2021 (edited) i post 2 ex top if you see it> TRY TO UPDATE THE PAGE Edited December 16, 2021 by ad777 none
fas Posted December 16, 2021 Author Posted December 16, 2021 15 minutes ago, ad777 said: i post 2 ex top if you see it> TRY TO UPDATE THE PAGE Yes Thanks alot for that I am working on it. definitely I am clueless
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