Jump to content

Recommended Posts

Posted

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

Posted

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.

  • Developers
Posted
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.
  :)

  • Developers
Posted

@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.
  :)

Posted (edited)
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
  • Developers
Posted
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.
  :)

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
×
×
  • Create New...