Jump to content

problem reading and writing text from a list


Peentje
 Share

Recommended Posts

Ok I'm still quite new at this but I'm trying to get the hang of it step by step.

While creating a little script I encountered a problem I don't really know how to handle, and I keep getting lost trying to figure it out from the help file.

Ok, here goes, I'll first try to explain the problem as clear as possible and then give a simplified version of the script with only the problem area:

I got a loop with 4 pieces of text on which I do some other operations which I left out here. I have a list which I have to put in the script somewhere and the variable, here text"x" for example, should read from that list and be put in the send command. When repeating the loop it should go on reading the list and putting the correct text in and when the list is over it should restart at the beginning.

for $__n1_ = 0 to 0 step 0

Send ( 'text1' )

Send ( 'text2' )

Send ( 'text3' )

Send ( 'text4' )

next

In this case the next time the loop is run it should read text5-6-7-8 in the text and place it in the send command.

The list it should read from could be like this:

text1

text2

...

text8

text9

text10

After having filled in text10 in this case, it should restart filling in text1.

I don't really know how to handle it, please help me with a decent solution, also in what form i should integrate the list if possible...

I hope I'm not asking too n00bish questions ;)

Greetz,

Peentje

Link to comment
Share on other sites

ok you tried to explain... but there is not enough info here to help you

i cant understand where you are reading the text from... what variables you may have used (so we can possibly hook-up with them)

i suggest showing your code

if you don't want to do that... you can pay someone you trust

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Ok here's just about the whole thing, well only the part that matters, makes it easier to understand:

It's actually about 4 IE screens, the first mouseclick in each block is to switch between them, the second one to highlight a field where something should be typed, that "something" is the variable you see in the Send command. I have a list of things in a txt-file, I would like the variable to read from that text file and try filling in each thing, when it has run the whole list it should start reading again from the beginning of the list.

I hope it's a little more clear now. Only I have no idea how to do it, and if I should integrate the list for the variable in the script itself somehow, or leave it in a seperate txt file where the script should fetch the new text for the variable, what the list should look like etc, that's where I'm stuck... Crossing fingers ;)

HotKeySet("{UP}", "MyExit")

HotKeySet("{PAUSE}", "_Pause"); PAUSE

HotKeySet("+{PAUSE}", "_UnPause"); SHIFT + PAUSE

for $__n1_ = 1 to 1 step 1

MouseClick( "left", 450, 750, 1, 3 )

MouseClick( "left", 350, 460, 1, 3 )

AutoItSetOption ( "SendKeyDelay", 1 )

Send ( 'variable' )

AutoItSetOption ( "SendKeyDelay", 40 )

Send ( '{ENTER}' )

MouseClick( "left", 570, 750, 1, 3 )

MouseClick( "left", 350, 460, 1, 3 )

AutoItSetOption ( "SendKeyDelay", 1 )

Send ( 'variable' )

AutoItSetOption ( "SendKeyDelay", 40 )

Send ( '{ENTER}' )

MouseClick( "left", 670, 750, 1, 3 )

MouseClick( "left", 350, 460, 1, 3 )

AutoItSetOption ( "SendKeyDelay", 1 )

Send ( 'variable' )

AutoItSetOption ( "SendKeyDelay", 40 )

Send ( '{ENTER}' )

MouseClick( "left", 800, 750, 1, 3 )

MouseClick( "left", 350, 460, 1, 3 )

AutoItSetOption ( "SendKeyDelay", 1 )

Send ( 'variable' )

AutoItSetOption ( "SendKeyDelay", 40 )

Send ( '{ENTER}' )

next

Func _Pause()

Global $pauSet= 1

While $pauSet

WEnd

EndFunc

Func _UnPause()

Global $pauSet= 0

EndFunc

Func MyExit()

Exit

EndFunc

Link to comment
Share on other sites

If you want to add something on a IE page, (browser) I assume you are trying to fill up form. If this is true then you should just pass in the variable into the next page instead Why make life

For example you can either browse through and search for your post

or

http://www.autoitscript.com/forum/index.php?showtopic=16333

simply enter the variable needed and in this case that would be 16333 afterall, all page is using get or post method. I hope this help.

Link to comment
Share on other sites

Try this:

; Tells the program to begin reading your .ini file at line 1:
    Global $Line = 1

; Sends the first block of data:
    $block1 = ReadData ()
        If $block1 = "0" Then
            ReadData()
        EndIf
    MouseClick( "left", 450, 750, 1, 3 )
    MouseClick( "left", 350, 460, 1, 3 )
    Send ($block1, 1)
    Send ( '{ENTER}' )

; Sends the second block of data:
    $block2 = ReadData ()
        If $block2 = "0" Then
            ReadData()
        EndIf
    MouseClick( "left", 570, 750, 1, 3 )
    MouseClick( "left", 350, 460, 1, 3 )
    Send ($block2, 1)
    Send ( '{ENTER}' )

; Sends the third block of data:
    $block3 = ReadData ()
        If $block3 = "0" Then
            ReadData()
        EndIf
    MouseClick( "left", 670, 750, 1, 3 )
    MouseClick( "left", 350, 460, 1, 3 )
    Send ($block3, 1)
    Send ( '{ENTER}' )

; Sends the fourth block of data:
    $block4 = ReadData ()
        If $block4 = "0" Then
            ReadData()
        EndIf
    MouseClick( "left", 670, 750, 1, 3 )
    MouseClick( "left", 350, 460, 1, 3 )
    Send ($block4, 1)
    Send ( '{ENTER}' )


; The function to read the data in your .ini file.  This should begin at line 1, then increment itself to 
; read the next line for the next block of data.  If it gets to the end of the file, it will reset to line 1:
    Func ReadData ()
        $file = FileOpen ("Your_ini_file.ini", 0)
        $data = FileReadLine ($file, $Line)
            If @error Then
                $Line = 1
                Return 0
            Else
                $Line = ($Line + 1)
            EndIf
    FileClose ($file)
    Return $data
    EndFunc

I didn't test it, and I'm not exactly sure if this is what you're trying to do, but if it helps you, then more power to ya.

Also, I don't see why you need to keep resetting the keydelay option. You may not need that in your script.

-DRX
Link to comment
Share on other sites

Woohoo! Thx DoctorX, works like a charm!

This was exactly what I was looking for ;)

There is one more thing I should need to add, but I have no idea if it is even possible...

The script is meant to search for stuff, and if there is a result, a link will appear always at the same place:

MouseClick( "left", 620, 420, 1, 3 )

Well it's not really a link, it's a small arrow and when clicking it, it enlarges a window on the page itself, so it doesn't open a new window or redirects you to another page.

As it is now I have to sit in front of the pc, checking if an arrow appears.

Is there a possibility to attach a sound file to a certain command that when clicking on the link (the arrow that enlarges the screen) the sound is played? It always appears at the same coordinates...

Like this I don't have to sit in front of the pc, I can just wait for the sound.

I know there is an option in win2k itself to play a sound when "navigation" starts, maybe that could work by enabling it right before that click and disabling it right after the click? I don't really know, maybe there's a solution way more simple than that. Hope somebody can help me out on this one...

Greetz,

Peentje

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