Jump to content

Input field is not being refreshed


loonghin
 Share

Recommended Posts

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 this

Run("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
EndFunc

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

3418742

3429591

3912363

but my output files can only get the results from 1st line:-

3418742 33418742

3429591 33418742

3912363 33418742

It 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

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

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