Jump to content

FileReadLine help needed


reverse
 Share

Recommended Posts

Hi.

How do I make FileReadLine command to go to the next line without exiting loop?

Here is my script.

I highlighted the place where I want my script to read next line from txt file.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
Local $file = FileOpen("lista.txt", 0)
Local $aPos = MouseGetPos()
; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf



$Coordss = AskUser()

MsgBox(0, "", $Coordss[0] & "       " & $Coordss[1])


Func AskUser()
    MsgBox(262144, "User Input", "Kliknij na I pozycję" & @CRLF & "Naciśnij OK i kliknij w I pole z nazwiskiem")
    Do
        Sleep(50)
    Until _IsPressed(01)
    $Coordss = MouseGetPos()
    Return $Coordss
EndFunc  ;==>AskUser



$Input = InputBox("InputBox", "Coords", $Coordss[0] &"," & $Coordss[1])
$aCoords = StringSplit($Input, ",", 2)




$Coordss1 = AskUser1()

MsgBox(0, "", $Coordss1[0] & "       " & $Coordss1[1])


Func AskUser1()
    MsgBox(262144, "User Input", "Kliknij na II pozycję" & @CRLF & "Naciśnij OK i kliknij w II pole z nazwiskiem")
    Do
        Sleep(50)
    Until _IsPressed(01)
    $Coordss1 = MouseGetPos()
    Return $Coordss1
EndFunc  ;==>AskUser



$Input1 = InputBox("InputBox", "Coords", $Coordss1[0] &"," & $Coordss1[1])
$aCoords1 = StringSplit($Input1, ",", 2)


$Coordss2 = AskUser2()

MsgBox(0, "", $Coordss2[0] & "       " & $Coordss2[1])


Func AskUser2()
    MsgBox(262144, "User Input", "Kliknij na III pozycję" & @CRLF & "Naciśnij OK i kliknij w III pole z nazwiskiem")
    Do
        Sleep(50)
    Until _IsPressed(01)
    $Coordss2 = MouseGetPos()
    Return $Coordss2
EndFunc  ;==>AskUser



$Input2 = InputBox("InputBox", "Coords", $Coordss2[0] &"," & $Coordss2[1])
$aCoords2 = StringSplit($Input2, ",", 2)


MsgBox(0, "", "NIE RUSZAJ TERAZ !!!")

Local $i=1
; Read in lines of text until the EOF is reached
While 1
    Local $s

    Local $line = FileReadLine($file)
    If @error = -1 Then MsgBox(262144,"KONIEC", "KONIEC !!!") ExitLoop
       
       Clipput($line)
       


While 1

       
If Mod( $i, 3) = 0 Then
   
     Do
    sleep(200) 
    until PixelGetColor(870, 252)=0xBFBFBF

    MouseClick("left", $aCoords2[0], $aCoords2[1], 3)

    Sleep(1000)
    Send("^z")
    sleep(300)
    send("^s")
    Do
    sleep(200) 
    until PixelGetColor(342, 299)=0xFFF791
    
    sleep(200)
    $i=$i+1
    $s=$s+1
    Send($s)
    Sleep(500)
    Send("{ENTER}")
    Do
    sleep(200) 
 until PixelGetColor(416, 319)=0x21A121
 Send("{ENTER}")

  
Do 
sleep(200)
until PixelGetColor(314, 70)=0xFFFFFF
    ExitLoop
Else


    sleep(200)

    MouseClick("left", $aCoords[0], $aCoords[1], 3)

    Sleep(1000)
    Send("^z")
    sleep(300)
    send("{Numpadenter}")
    
    sleep(200)
    $i=$i+1
    
;;;;;;;;;;;;;;;;;;;;;;;;;; I NEED THE SCRIPT TO READ THE NEXT LINE FROM TXT FILE HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    

    sleep(200) 


    MouseClick("left", $aCoords1[0], $aCoords1[1], 3)

    Sleep(1000)
    Send("^z")
    sleep(300)
    send("{Numpadenter}")
    
    sleep(200)
    $i=$i+1
    
    
    ExitLoop
    


   
EndIf
 
WEnd
WEnd
FileClose($file)

I can't ExitLoop there because it... exits the loop (:lol:) and does not do the rest of commands.

 

Thx for your help.

Edited by reverse
Link to comment
Share on other sites

  • Developers

The loop ends when it encounters the first ExitLoop, and this line has an error:

If @error = -1 Then MsgBox(262144, "KONIEC", "KONIEC !!!") ExitLoop

Here is your code processed byTidy:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
Local $file = FileOpen("lista.txt", 0)
Local $aPos = MouseGetPos()
; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf



$Coordss = AskUser()

MsgBox(0, "", $Coordss[0] & "       " & $Coordss[1])


Func AskUser()
    MsgBox(262144, "User Input", "Kliknij na I pozycję" & @CRLF & "Naciśnij OK i kliknij w I pole z nazwiskiem")
    Do
        Sleep(50)
    Until _IsPressed(01)
    $Coordss = MouseGetPos()
    Return $Coordss
EndFunc   ;==>AskUser



$Input = InputBox("InputBox", "Coords", $Coordss[0] & "," & $Coordss[1])
$aCoords = StringSplit($Input, ",", 2)




$Coordss1 = AskUser1()

MsgBox(0, "", $Coordss1[0] & "       " & $Coordss1[1])


Func AskUser1()
    MsgBox(262144, "User Input", "Kliknij na II pozycję" & @CRLF & "Naciśnij OK i kliknij w II pole z nazwiskiem")
    Do
        Sleep(50)
    Until _IsPressed(01)
    $Coordss1 = MouseGetPos()
    Return $Coordss1
EndFunc   ;==>AskUser1



$Input1 = InputBox("InputBox", "Coords", $Coordss1[0] & "," & $Coordss1[1])
$aCoords1 = StringSplit($Input1, ",", 2)


$Coordss2 = AskUser2()

MsgBox(0, "", $Coordss2[0] & "       " & $Coordss2[1])


Func AskUser2()
    MsgBox(262144, "User Input", "Kliknij na III pozycję" & @CRLF & "Naciśnij OK i kliknij w III pole z nazwiskiem")
    Do
        Sleep(50)
    Until _IsPressed(01)
    $Coordss2 = MouseGetPos()
    Return $Coordss2
EndFunc   ;==>AskUser2



$Input2 = InputBox("InputBox", "Coords", $Coordss2[0] & "," & $Coordss2[1])
$aCoords2 = StringSplit($Input2, ",", 2)


MsgBox(0, "", "NIE RUSZAJ TERAZ !!!")

Local $i = 1
; Read in lines of text until the EOF is reached
While 1
    Local $s

    Local $line = FileReadLine($file)
    If @error = -1 Then MsgBox(262144, "KONIEC", "KONIEC !!!") ExitLoop

    ClipPut($line)
    
    While 1

        If Mod($i, 3) = 0 Then

            Do
                Sleep(200)
            Until PixelGetColor(870, 252) = 0xBFBFBF

            MouseClick("left", $aCoords2[0], $aCoords2[1], 3)

            Sleep(1000)
            Send("^z")
            Sleep(300)
            Send("^s")
            Do
                Sleep(200)
            Until PixelGetColor(342, 299) = 0xFFF791

            Sleep(200)
            $i = $i + 1
            $s = $s + 1
            Send($s)
            Sleep(500)
            Send("{ENTER}")
            Do
                Sleep(200)
            Until PixelGetColor(416, 319) = 0x21A121
            Send("{ENTER}")

            Do
                Sleep(200)
            Until PixelGetColor(314, 70) = 0xFFFFFF
            
            ExitLoop
        Else


            Sleep(200)

            MouseClick("left", $aCoords[0], $aCoords[1], 3)

            Sleep(1000)
            Send("^z")
            Sleep(300)
            Send("{Numpadenter}")

            Sleep(200)
            $i = $i + 1

            ;;;;;;;;;;;;;;;;;;;;;;;;;; I NEED THE SCRIPT TO READ THE NEXT LINE FROM TXT FILE HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;

            Sleep(200)

            MouseClick("left", $aCoords1[0], $aCoords1[1], 3)

            Sleep(1000)
            Send("^z")
            Sleep(300)
            Send("{Numpadenter}")

            Sleep(200)
            $i = $i + 1

            ExitLoop

        EndIf

    WEnd
WEnd
FileClose($file)

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Did you see my edit?:

The loop ends when it encounters the first ExitLoop, and this line has an error:

If @error = -1 Then MsgBox(262144, "KONIEC", "KONIEC !!!") ExitLoop

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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