Jump to content

putting names from a list


Recommended Posts

hi

i have a list of names in a text file.

the list looks like this:

Smith

Anderson

Clark

Wright

Mitchell

I have to enter all these names in another file.

Here is the process which i want to automate.

Press the Tab button 3 times, then pick the name from list and press enter.

After this next name needs to be added by the same process mentioned above.

What i know is how to use loop and press the button automatically.

but i dont know how 'll i pick names from list and then write them using the Send command.

I need help with this.

Link to comment
Share on other sites

This code will send selected text to the clipboard, and set $var= to clipboard

#include <misc.au3>
$var= 0
$done= 0
While $done= 0;tester loop
    if _IsPressed("1b") Then;when ESC down
        $var= getselection()
        ConsoleWrite($var)
    endif
wend

func getselection()
    send("^c");force user to store selection in clipboard
    return clipget();retrieve selection from clipboard
endfunc

edit: opps from file, my bad

Edited by songersoft
Link to comment
Share on other sites

Thank you but sorry i was forgot to mention that i have to put these names on a web page.

mistakenly i used "file" instead of "page".

Tab button selects the field and then i have to send the name.

Link to comment
Share on other sites

No, i dont want to use any UDF.

i only have basic info about programming and i am very new to AutoIt.

Help me correcting this:

For $x = $Name_1 to $Name_x

Send("{TAB}")

Sleep(30)

Send("{TAB}")

Sleep(30)

Send("{TAB}")

Sleep(30)

Send($Name)

Sleep(30)

Send("{Enter}")

Next

Are u understanding what i want to do?

using UDF 'll be complicated for me. so, i want to use this simple way.

i 'll learn the other methods later.

Link to comment
Share on other sites

Where are we getting the data from again? It is data in a file? or data in an application window? both what?

and we output to a file, that may be used for html or something?

I don't know who you are anymore! lol

Edited by songersoft
Link to comment
Share on other sites

Data is in a text file and i have to put it online on a web page.

Text file have names in it.

like this

Smith

Anderson

Clark

Wright

Mitchell

and i have to put these names one by one on the page.

the procedure is

press Tab button for 3 times and then Send the name

then hit enter and the same process goes again but with the new name, next name.

that it.

i know this is an invalid script but i need something like this:

For $x = $Name_1 to $Name_x

Send("{TAB}")

Sleep(30)

Send("{TAB}")

Sleep(30)

Send("{TAB}")

Sleep(30)

Send($Name)

Sleep(30)

Send("{Enter}")

Next; another name next time

Link to comment
Share on other sites

hi C2A,

Welcome to the forums :D !!!

Using UDFs are just as easy as using built in functions :) Just add #include <TheUDFScriptName.au3> at the top of your script and you're ready to go ;)

Using UDF's is the simple way, trying to do it all with sends is like trying to code in binary!!

Clarify some things please, so we can better help you.

What is the exact format of the file? Please give a small snippet like:

abc
def
john
mary

What web page are you trying to automate? Please give its URL, its source or a relevant snippet of its source.

Also, paste your code between AutoIt tags like [autoit]this[/autoit], it improves readability ;)

Good luck :D

-smartee

EDIT:fixed tag ex

Edited by smartee
Link to comment
Share on other sites

will load data file

when F6 is pressed it will send formated data output

;change $PATH_TO_DATA_FILE to the path of your data file
#include <misc.au3>

$PATH_TO_DATA_FILE= @ScriptDir&"\namelist.txt"
$namesmax= filecountlines($PATH_TO_DATA_FILE)
dim $names[$namesmax]
$file= FileOpen($PATH_TO_DATA_FILE);will open file at path for reading
for $i= 0 to $namesmax-1
    $names[$i]= FileReadLine($file)
next
FileClose($file)
while _IsPressed("75")= False ;F6 trigger key presses
wend
for $i= 0 to $namesmax-1
    Send("{TAB}")
    Sleep(30)
    Send("{TAB}")
    Sleep(30)
    Send("{TAB}")
    Sleep(30)
    Send($names[$i])
    Sleep(30)
    Send("{Enter}")
next

func filecountlines($path)
    $count= 0
    $file= FileOpen($path, 0)
    while @error= 0
        FileReadLine($file)
        if @error<> 0 then exitloop
        $count= $count+1
    wend
    FileClose($file)
    return $count
EndFunc
Edited by songersoft
Link to comment
Share on other sites

hi songersoft

this is really a very good script, you saved my hours of work!

Thank you so much.

@smartee

thanks for the welcome and suggestions, i will try to learn about udf.

thanks all

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