Sign in to follow this  
Followers 0
Tamaro

Help With Loop And Text From File

10 posts in this topic

After several hours and many atempts i still cant make it work would someone please help me?

i need to get text from a file lets name it Text.txt, in to a field and also loop until there is no more text in the file. the text file looks like this:

123456

456789

jgf1234

etc.

what i have for script so far is:

Note: the output is not going on notepad just did for testing purposes.

Thanks for your help

#include <GuiConstants.au3>
#include <Date.au3>

$gui = GUICreate("NEW MEMBER", 428, 120, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Member_1 = GUICtrlCreateLabel("Member ID:", 30, 50, 200, 20)
$Member_2 = GUICtrlCreateLabel("Member 2 Digits:", 30, 80, 210, 20)
$GetMember_4 = GUICtrlCreateInput("", 160, 50, 140, 20)
$GetMember2_5 = GUICtrlCreateInput("", 160, 80, 140, 20)
$Group_7 = GUICtrlCreateGroup("Member ID format ###-##-####", 20, 20, 390, 140)
$ok = GUICtrlCreateButton("Ok", 315, 50, 60, 20)
$exit = GUICtrlCreateButton("Exit", 315, 80, 60, 20)
$Gui2 = GUICreate("Verify", 329, 177, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), -1, $gui)
GUICtrlCreateLabel("Member ID:", 20, 20, 50, 20)
GUICtrlCreateLabel("Member 2:", 20, 60, 50, 20)
GUICtrlCreateLabel(GUICtrlRead($GetMember_4), 110, 20, 210, 20)
GUICtrlCreateLabel(GUICtrlRead($GetMember2_5), 110, 60, 210, 20)
$Button_7 = GUICtrlCreateButton("OK", 180, 140, 90, 30)
$Button_8 = GUICtrlCreateButton("Cancel", 60, 140, 90, 30)
GUISetState(@SW_SHOW, $gui)
GUISetState(@SW_HIDE, $Gui2)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    Case $msg = $exit
            Exit
        Case $msg = $ok
            GUISetState(@SW_SHOW, $Gui2)
            GUICtrlCreateLabel(GUICtrlRead($GetMember_4), 110, 20, 210, 20)
            GUICtrlCreateLabel(GUICtrlRead($GetMember2_5), 110, 60, 210, 20)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_7
        WinWaitActive("Untitled - Notepad")
LOOP START  
    $timestamp = _Now()
    $day5 = @MDAY - 5
    $timestamp = @MON & "/" & $day5 & "/" & @YEAR
    send ($timestamp)
    Send("{ENTER}")
    Send("Y")
    Send("{ENTER}")
    Send("RXC05")
    Send("{ENTER}")
    Send(GUICtrlRead($GetMember_4))
    Send("{ENTER}")
    Send(GUICtrlRead($GetMember2_5))
    Send("{ENTER 2}")
    Send("HICL")
    Send("{ENTER}")
    Send("***TEXT FROM FILE HERE***")
    Sleep(5000)
    Send("PA")
    Send("{ENTER 6}")
    Send("15")
    Send("{ENTER 4}")
    Send("T")
    Send("{ENTER 5}")
    Send("APPROVED")
    Send("{ENTER 7}")
    Send("{F8}")
    Send("{ENTER 9}")
    Send("Y")
 END OF LOOP
            Exit
        Case $msg = $Button_8
            GUISetState(@SW_HIDE, $Gui2)
        Case Else
   ;;;
    EndSelect
WEnd

Share this post


Link to post
Share on other sites



After several hours and many atempts i still cant make it work would someone please help me?

i need to get text from a file lets name it Text.txt, in to a field and also loop until there is no more text in the file. the text file looks like this:

123456

456789

jgf1234

etc.

what i have for script so far is:

Note: the output is not going on notepad just did for testing purposes.

Thanks for your help

First off, where are you wanting this text to go?

Secondly, are you saying that you want line by line of the text file to be inserted during the loop?

So that it looks something like this for the first loop:

05/6/2006
Y
RXC05
516451
10

HICL
123456PA





15



T




APPROVED

Share this post


Link to post
Share on other sites

Please provide more information on what it is exactly that you want.

i need to get text from a file lets name it Text.txt, in to a field and also loop until there is no more text in the file.

What do you mean by field? Possibly _FileReadToArray ?


AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Big_Daddy:

you are correct i want the text to look like that in the first loop :

05/6/2006
Y
RXC05
516451
10

HICL
123456PA





15



T




APPROVED

the output goes in to a program tru Putty.

Simucal:

By field I mean in the program this info is going to be entered.

Edited by Tamaro

Share this post


Link to post
Share on other sites

Big_Daddy:

you are correct i want the text to look like that in the first loop :

05/6/2006
Y
RXC05
516451
10

HICL
123456PA
15
T
APPROVED

the output goes in to a program tru Putty.

Simucal:

By field I mean in the program this info is going to be entered.

Try this with a text.txt file in the same dir as the script:

#include <GuiConstants.au3>
#include <Date.au3>
#include <File.au3>

Dim $aFile[1]

$gui = GUICreate("NEW MEMBER", 428, 120, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Member_1 = GUICtrlCreateLabel("Member ID:", 30, 50, 200, 20)
$Member_2 = GUICtrlCreateLabel("Member 2 Digits:", 30, 80, 210, 20)
$GetMember_4 = GUICtrlCreateInput("", 160, 50, 140, 20)
$GetMember2_5 = GUICtrlCreateInput("", 160, 80, 140, 20)
$Group_7 = GUICtrlCreateGroup("Member ID format ###-##-####", 20, 20, 390, 140)
$ok = GUICtrlCreateButton("Ok", 315, 50, 60, 20)
$exit = GUICtrlCreateButton("Exit", 315, 80, 60, 20)

$Gui2 = GUICreate("Verify", 329, 177, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), -1, $gui)
GUICtrlCreateLabel("Member ID:", 20, 20, 60, 20)
GUICtrlCreateLabel("Member 2:", 20, 60, 50, 20)
GUICtrlCreateLabel(GUICtrlRead($GetMember_4), 110, 20, 210, 20)
GUICtrlCreateLabel(GUICtrlRead($GetMember2_5), 110, 60, 210, 20)
$Button_7 = GUICtrlCreateButton("OK", 180, 140, 90, 30)
$Button_8 = GUICtrlCreateButton("Cancel", 60, 140, 90, 30)
GUISetState(@SW_SHOW, $gui)
GUISetState(@SW_HIDE, $Gui2)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $exit
            Exit
        Case $msg = $ok
            GUISetState(@SW_SHOW, $Gui2)
            GUICtrlCreateLabel(GUICtrlRead($GetMember_4), 110, 20, 210, 20)
            GUICtrlCreateLabel(GUICtrlRead($GetMember2_5), 110, 60, 210, 20)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_7
            $sFilePath = @ScriptDir & "\Text.txt"
            _FileReadToArray($sFilePath, $aFile)
            For $i = 1 To $aFile[0]
                WinWaitActive("Untitled - Notepad")
            ;LOOP START
                $timestamp = _Now()
                $day5 = @MDAY - 5
                $timestamp = @MON & "/" & $day5 & "/" & @YEAR
                Send($timestamp)
                Send("{ENTER}")
                Send("Y")
                Send("{ENTER}")
                Send("RXC05")
                Send("{ENTER}")
                Send(GUICtrlRead($GetMember_4))
                Send("{ENTER}")
                Send(GUICtrlRead($GetMember2_5))
                Send("{ENTER 2}")
                Send("HICL")
                Send("{ENTER}")
                Send($aFile[$i])
                Sleep(5000)
                Send("PA")
                Send("{ENTER 6}")
                Send("15")
                Send("{ENTER 4}")
                Send("T")
                Send("{ENTER 5}")
                Send("APPROVED")
                Send("{ENTER 7}")
                Send("{F8}")
                Send("{ENTER 9}")
                Send("Y")
            Next
            Exit
        Case $msg = $Button_8
            GUISetState(@SW_HIDE, $Gui2)
        Case Else
        ;;;
    EndSelect
WEnd

Share this post


Link to post
Share on other sites

That is it!! Thank you guys for your help!!

Share this post


Link to post
Share on other sites

I think I spoke to soon for some reason after sending the sring from the text file it adds an extra Enter key, any ideas?

Send($aFile[$i])

Share this post


Link to post
Share on other sites

I think I spoke to soon for some reason after sending the sring from the text file it adds an extra Enter key, any ideas?

Send($aFile[$i])
Which version are you using for AutoIt3 and _FileReadToArray() ?

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I think I spoke to soon for some reason after sending the sring from the text file it adds an extra Enter key, any ideas?

Send($aFile[$i])
I can't duplicate the problem, but the only idea I have is that your text file may have some invisible line feeds or something.

Try replacing the code you posted with this:

Send(StringStripCR($aFile[$i]))

If that doesn't work try this:

Send(StringReplace($aFile[$i], @LF, ""))

Share this post


Link to post
Share on other sites

I can't duplicate the problem, but the only idea I have is that your text file may have some invisible line feeds or something.

Try replacing the code you posted with this:

Send(StringStripCR($aFile[$i]))

If that doesn't work try this:

Send(StringReplace($aFile[$i], @LF, ""))
Thanks, i will try that tomorrow.

Share this post


Link to post
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
Sign in to follow this  
Followers 0