Sign in to follow this  
Followers 0
Squared

Help with FileReadLine and a list.

6 posts in this topic

What I want this script to do is to insert a line of text from a file on my desktop into the URL of a website every time the script loops. The catch is that I want to send the next line in the file every time it loops. So basically the text file looks like this:

"a

b

c

d

e..."

And I would like the URL to be "about:blanka" when it first runs, then after looping to be "about:blankb", etc... I've got this script going as an example, which is almost exactly how my script looks except that I changed the URL to about:blank. I don't understand why it isn't working. Any advice on a better way to do this, or on why my script is not functioning, would be greatly appreciated!

*note: I included the Pause function in case anyone wanted to actually run the script so they could easily stop the stupid loop it gets into by pressing F4.

#include <IE.au3>
Global $Paused
HotKeySet("{F4}", "TogglePause")
Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
EndFunc

$line=1
$file=FileOpen("alpha.txt",0)
$input=FileReadLine($file, $line) 

$oIE=_IECreate("about:blank")
WinWaitActive("Blank")
WinSetState("Blank", "", @SW_MAXIMIZE)

Func ID()
_IENavigate($oIE, "about:blank"&$input)
_IELoadWait($oIE)
EndFunc

While $line < 27
    $line=$line+1
    Call("ID")
    WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

hmm, i asked a similar question, but what i wanted is to copy/paste a random line from a txt file

here is the code some1 told me and its working perfectly

maybe you can understand it and chage it the way u want lol cause i am a compelte noob at autoit

$notepad2 = WinGetText("noms.txt - Notepad")
        $lines2 = StringSplit($notepad2,@crlf,1)
        $randomline2 = Random(1, $lines2[0], 1)
        Clipput($lines2[$randomline2])
        MouseClick("left", 696 , 387,1,5)
        Send(Clipget())
Edited by anyways

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

hmm, i asked a similar question, but what i wanted is to copy/paste a random line from a txt file

here is the code some1 told me and its working perfectly

maybe you can understand it and chage it the way u want lol cause i am a compelte noob at autoit

$notepad2 = WinGetText("noms.txt - Notepad")
        $lines2 = StringSplit($notepad2,@crlf,1)
        $randomline2 = Random(1, $lines2[0], 1)
        Clipput($lines2[$randomline2])
        MouseClick("left", 696 , 387,1,5)
        Send(Clipget())

Hmmm that's interesting. I'm not sure how I would get that to read only the next line every loop, because I'm a pretty big AutoIt "noob" myself. I have only been using it for about a month, and have only written about 15 functional scripts. I am getting better and better results, faster, however, which is good.

I also don't completely understand what is happening in the second line of script there... so I need to go check out the helpfile to see what that's about!

Edit* Also, I would be really interested in knowing why this script doesn't work as is. If anyone is knowledgeable enough to point this out to me, I would be incredibly greatful.

Edited by Squared

Share this post


Link to post
Share on other sites

What I want this script to do is to insert a line of text from a file on my desktop into the URL of a website every time the script loops. The catch is that I want to send the next line in the file every time it loops. So basically the text file looks like this:

"a

b

c

d

e..."

Welcome,

Like this perhaps

#include <IE.au3>
Global $Paused
HotKeySet("{F4}", "TogglePause")

$oIE = _IECreate("about:blank")
WinWaitActive("Blank")
WinSetState("Blank", "", @SW_MAXIMIZE)

$file = FileOpen("alpha.txt", 0)
If $file <> -1 Then
    While 1
        $input = FileReadLine($file)
        If @error Then ExitLoop
        ID()
        Sleep(1000)
    WEnd
    FileClose($file)
EndIf

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
EndFunc   ;==>TogglePause

Func ID()
    _IENavigate($oIE, "about:blank" & $input)
    _IELoadWait($oIE)
EndFunc   ;==>ID

text file

a
b
c
d
e

:whistle:

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

my guess is that you need to change the third line, i think you have to change taht random() function to something else

or if i had time, i would do soemthing noob like this:

$notepad2 = WinGetText("noms.txt - Notepad")
        $lines2 = StringSplit($notepad2,@crlf,1)
        $randomline2 = 1
        Clipput($lines2[$randomline2])
        MouseClick("left", 696 , 387,1,5)
        Send(Clipget())

$notepad2 = WinGetText("noms.txt - Notepad")
        $lines2 = StringSplit($notepad2,@crlf,1)
        $randomline2 = 2
        Clipput($lines2[$randomline2])
        MouseClick("left", 696 , 387,1,5)
        Send(Clipget())

$notepad2 = WinGetText("noms.txt - Notepad")
        $lines2 = StringSplit($notepad2,@crlf,1)
        $randomline2 = 3
        Clipput($lines2[$randomline2])
        MouseClick("left", 696 , 387,1,5)
        Send(Clipget())

$notepad2 = WinGetText("noms.txt - Notepad")
        $lines2 = StringSplit($notepad2,@crlf,1)
        $randomline2 = 4
        Clipput($lines2[$randomline2])
        MouseClick("left", 696 , 387,1,5)
        Send(Clipget())

$notepad2 = WinGetText("noms.txt - Notepad")
        $lines2 = StringSplit($notepad2,@crlf,1)
        $randomline2 = 5
        Clipput($lines2[$randomline2])
        MouseClick("left", 696 , 387,1,5)
        Send(Clipget())

$notepad2 = WinGetText("noms.txt - Notepad")
        $lines2 = StringSplit($notepad2,@crlf,1)
        $randomline2 = 6
        Clipput($lines2[$randomline2])
        MouseClick("left", 696 , 387,1,5)
        Send(Clipget())

$notepad2 = WinGetText("noms.txt - Notepad")
        $lines2 = StringSplit($notepad2,@crlf,1)
        $randomline2 = 7
        Clipput($lines2[$randomline2])
        MouseClick("left", 696 , 387,1,5)
        Send(Clipget())

$notepad2 = WinGetText("noms.txt - Notepad")
        $lines2 = StringSplit($notepad2,@crlf,1)
        $randomline2 = 8
        Clipput($lines2[$randomline2])
        MouseClick("left", 696 , 387,1,5)
        Send(Clipget())

and so on

but thats pretty noob lol, wait until a mod answer your script, i thought by maybe giving you a quick hint you would actually find your answer yourself

edit: youd also need to chaneg number after $notepad $line each time you copy/paste the function

Edited by anyways

Share this post


Link to post
Share on other sites

Welcome,

Like this perhaps

#include <IE.au3>
Global $Paused
HotKeySet("{F4}", "TogglePause")

$oIE = _IECreate("about:blank")
WinWaitActive("Blank")
WinSetState("Blank", "", @SW_MAXIMIZE)

$file = FileOpen("alpha.txt", 0)
If $file <> -1 Then
    While 1
        $input = FileReadLine($file)
        If @error Then ExitLoop
        ID()
        Sleep(1000)
    WEnd
    FileClose($file)
EndIf

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
EndFunc   ;==>TogglePause

Func ID()
    _IENavigate($oIE, "about:blank" & $input)
    _IELoadWait($oIE)
EndFunc   ;==>ID

text file

a
b
c
d
e

:whistle:

You rock, thanks so much.

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