loonghin Posted November 24, 2011 Share Posted November 24, 2011 Hi! I am really new at this and I managed to get some codings to automate to run a program to perform a conversion of telephone numbers. Where my input file of 7 digits should get a result of 8 digits. So I used a Function key to start the program and will input the file based on the input file called "phone_list.txt" then results will be in "result.txt"My code looks like thisexpandcollapse popupRun("C:\Program Files\HR2000 Software\Telekom 8 Digit\telekom8.exe", "","") WinWaitActive("HR2000") HotKeySet("{F1}", "Start") ;F1 Key HotKeySet("{ESC}", "Pause");Esc Button - Pause for a while HotKeySet("{F4}", "Close") ;CLOSE telekom8 apps and autoit instance. While 1 Sleep(100) WEnd Func Start() ;------------ loop tru all the phone numbers in textfile $PhoneList_FilePath = "phone_list.txt" $PhoneList_Result = "result.txt" FileDelete($PhoneList_Result) $CountLines = _FileCountLines($PhoneList_FilePath) $Inputfile = FileOpen($PhoneList_FilePath,0) $Outputfile = FileOpen($PhoneList_Result,1) $counter = 0 ;------------------------------ While 1 $line = FileReadLine($Inputfile) If @error = -1 Then ExitLoop $counter = $counter + 1 ;------ convert $phoneNo = StringReplace($line," ","") ;--remove empty space. Send($phoneNo) MouseClick("left",738,351,1) $var = ControlGetText("", "", "[CLASS:TMemo; INSTANCE:1]") $var = StringReplace($var,"Your 8 Digit number is ...","") $var = StringReplace($var,@CRLF,"") ;-------- FileWriteLine($Outputfile,$phoneNo & @TAB & $var & @CRLF) MouseClickDrag("left",488,421,543,421) Wend FileClose($Inputfile) FileClose($Outputfile) MsgBox(0,"DONE",$counter & " records converted !") Pause() EndFunc Func Pause() ;Exits the program ;This is not really pause, it will start all over again. ;Need to find a way how to resume it back where it stop previously. While 1=1 WEnd EndFunc Func Close() Send("!{F4}") Send("{ENTER}") Exit 0 EndFuncThe challenge now is that the output always gives the 1st line results.The values of the input is not refreshed so that the results are different.I have my input files with 3 lines:-341874234295913912363but my output files can only get the results from 1st line:-3418742 334187423429591 334187423912363 33418742It seems that the input screen is not filled with the next input lines so it keeps copying the 1st result.Any ideas how to fix the script? Link to comment Share on other sites More sharing options...
loonghin Posted November 24, 2011 Author Share Posted November 24, 2011 Just in case you need to test the program, its available here http://www.arejae.com/download/MyPhoneConverter.zip Link to comment Share on other sites More sharing options...
Clark Posted November 24, 2011 Share Posted November 24, 2011 I'm just wondering if you are opening the files in the correct mode. Perhaps try using this to open the files: ; Open up the input and output files ====== $message = "Please select a file to convert" $initialDir = "W:TestingToolsDiehard" $InputFile = FileOpenDialog($message, $initialDir & "", "All (*.*)", 1 ) If @error Then MsgBox(4096,"","No File(s) chosen") exit Else $InputFile = StringReplace($InputFile, "|", @CRLF) EndIf $message="Please select a file to write to" $OutputFile = FileSaveDialog($message, $initialDir & "", "All (*.*)", 2 ) If @error Then MsgBox(4096,"","No File(s) chosen") exit Else $OutputFile = StringReplace($OutputFile, "|", @CRLF) EndIf ; === end of file management ============== 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