Jump to content

Insert random line into specific field


 Share

Recommended Posts

Hey all,

 

Could someone please help n00b with this? I was searching everywhere, but couldn't find a proper solution.

I'm trying to read random line from text file and insert it into specific field (popup contact form, textarea).

While reading func works, as well as inserting, I cannot put those two together, it always throws error parsing variable.

Here's my messed code so far:

1. Reading random line

$sFile = "myfile.txt"
$lines = _FileCountLines($sFile)
$sFile = FileOpen($sFile)
$line = FileReadLine($sFile, Random(1, $lines, 1))

;send line into textarea
Send($line) ; 1st try
;ClipPut($line) ; 2nd try
;send("+{insert}") ; 2nd try
FileClose($sFile)

2. Inserting

Local $data2 = _IEGetObjByName ($oIE, "message[body]")
_IEFormElementSetValue($data2, $line) ;replaced text with $line, added the whole thing before fileClose, but no luck :(

Help, pls:)

Link to comment
Share on other sites

Based on your "Inserting" segment it looks like you want to put the text into an Internet Explorer field. If that's the case you have more work to do staring with including the IE UDFs (IE.AU3) and creating an IE object (_IECreate). The first 2 entries in the help file for IE Management are helpful in getting your head around the topic.

Link to comment
Share on other sites

  • Developers
On 2/20/2019 at 4:33 AM, bostjan35 said:

I'm trying to read random line from text file and insert it into specific field (popup contact form, textarea).

What is the purpose for wanting to do this at all?

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

@Dwalfware, Maybe there was a reason for me asking that question....   and maybe it would have been wise to hold off posting your answer and wait for the OP to answer my question first?    

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

9 hours ago, Jos said:

@Dwalfware, Maybe there was a reason for me asking that question....   and maybe it would have been wise to hold off posting your answer and wait for the OP to answer my question first?    

Jos

OK Chief, I see now what IT could be ;)

Bit too fast on my side, sorry went from first post to answer without checking the other posts. We learn.

Edited by Dwalfware
Link to comment
Share on other sites

  • Developers
2 hours ago, bostjan35 said:

Hi, sorry for late reply.

No special reason, just learning autoit.

But I figured it out already, so thanks anyway.

 

Take care:)

Yea right ....  

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