Jump to content

Doesn't send right


McGod
 Share

Recommended Posts

This script doesnt want to display the $line command in send funticion

My Script :P

Any suggestions\fixes or why it isnt working?

Edited by Chip
Link to comment
Share on other sites

Change Send ( "$line" ) to Send ( $line )


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Change Send ( "$line" ) to Send ( $line )

It works now but it only uses first line?

any way of it going threw the list?

Link to comment
Share on other sites

It works now but it only uses first line?

any way of it going threw the list?

The way you are using FileReadLine it will only read the first line. See the example in the help file for the proper way to read every line.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

MouseClick("left", 303, 650, 1)

;Create Character

While 1

MouseClick("left", 579, 418, 1)

;Selects Char

$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

; Read in lines of text until the EOF is reached

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

Send ( "$line" )

;Characters Name

MouseClick("left", 881, 711, 1)

;Hits OK

MouseClick("left", 598, 478, 1)

;Hits Retry

for every line?

Link to comment
Share on other sites

i tried adding

MouseClick("left", 579, 418, 1)

;Selects Char

$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

; Read in lines of text until the EOF is reached

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

Send ( $line )

;Characters Name

MouseClick("left", 881, 711, 1)

;Hits OK

MouseClick("left", 598, 478, 1)

;Hits Retry

again but

$line = FileReadLine(2)

It gave error

any easier way of reading text from file and sending it?

Link to comment
Share on other sites

Replace this

; Read in lines of text until the EOF is reached

    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop

Send ( "$line" )

with this

; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop

Send ( "$line" )
Wend


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

  • Moderators

I gave the udf to look at:

#include <file.au3>
Local $FilePath = FileOpenDialog('Find File To Send Text', @ScriptDir, 'All Files (*.*)')
Local $nArray = ''
_FileReadToArray($FilePath, $nArray)

SendStrings($nArray)

Func SendStrings(ByRef $nArray)
    For $i = 1 To UBound($nArray) - 1
        Send($nArray[$i])
    Next
EndFunc

Edit: BigDod beat me, but now you have 2 different ways.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

#include <file.au3>
Local $FilePath = FileOpenDialog('Find File To Send Text', @ScriptDir, 'All Files (*.*)')
Local $nArray = ''
_FileReadToArray($FilePath, $nArray)

SendStrings($nArray)

Func SendStrings(ByRef $nArray)
    For $i = 1 To UBound($nArray) - 1
        Send($nArray[$i])
    Next
EndFunc

I dont get where you put this or where you put the file.au3

Link to comment
Share on other sites

  • Moderators

I probably (I know I did, over complicate it for you, but I really don't understand what your trying to do, if your trying to repeat that time and time again or whatever

#include <file.au3>
Opt('MouseCoordMode', 0); check Opt('MouseCoordMode') in the help file to see what you need to set 0 to.
Local $FilePath = FileOpenDialog('Find File To Send Text', @ScriptDir, 'All Files (*.*)')
Local $nArray = ''
_FileReadToArray($FilePath, $nArray)
MouseClick("left", 579, 418, 1, 1)
SendStrings($nArray)

Func SendStrings(ByRef $nArray)
    For $i = 1 To UBound($nArray) - 1
        If $i = 1 Then
            Send($nArray[$i])
            MouseClick("left", 881, 711, 1)
            MouseClick("left", 598, 478, 1)
        ElseIf $i = 2 Then
            MouseClick("left", 579, 418, 1, 1)
            Send($nArray[$i])
            MouseClick("left", 881, 711, 1)
            MouseClick("left", 598, 478, 1)
        Else
            ExitLoop
        EndIf       
    Next
EndFunc
If your doing it more than twice just copy the ElseIf and put in another one with 3, 4, 5 etc... A while loop would be better probably for you, but to be honest, I'm to tired to re-write it.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Have you tried my suggestion?


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

The idea i want it to try is to like

It tries a name,if the name exists it hits ok and then repeats with a new name.

When i tried ur suggestion it put all 3 lines into the box and tried

and Smoke_N i dont know what i need in file.au3

So pretty much it repeats a process with a new name that comes from a text file

Link to comment
Share on other sites

Well i want to be able to do like more then 50 names is there any way other then the copy n paste method to do it?

Link to comment
Share on other sites

The too ways already given should go as many as are in the text file. If you haven't tried it yet, it should work. If it doesn't, post updated code and we'll try to help.

Btw, why are you trying different character names for D2?

Namebot

New Code is pretty big

trys 30 names

Edited by Chip
Link to comment
Share on other sites

I think you're just a bit confused. All you should need is:

Func SendStrings(ByRef $nArray)
    For $i = 1 To UBound($nArray) - 1
        If $i = 1 Then
            Send($nArray[$i])
            MouseClick("left", 1005, 845, 1);OK
            MouseClick("left", 715, 609, 1);Retry
        Else
            MouseClick("left", 720, 551, 1, 1);Selects Char
            Send($nArray[$i])
            MouseClick("left", 1005, 845, 1);OK
            MouseClick("left", 715, 609, 1);Retry
    EndIf       
    Next
EndFunc

I left the If Then in there because I noticed that if it $i=1 then it doesn't do the initial click. Seeing as how that selects the character, probably want you really want the function to be:

Func SendStrings(ByRef $nArray)
    For $i = 1 To UBound($nArray) - 1
            MouseClick("left", 720, 551, 1, 1);Selects Char
            Send($nArray[$i])
            MouseClick("left", 1005, 845, 1);OK
            MouseClick("left", 715, 609, 1);Retry
    Next
EndFunc
Link to comment
Share on other sites

*Does Happy Dance*

Worked Perfectly

Thanks

Link to comment
Share on other sites

  • Moderators

Thanks Oxin8, I got caught up in the superbowl and guest, thanks for helping him out with my post :lmao:.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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