Sign in to follow this  
Followers 0
Rustle

Need general help with script

7 posts in this topic

Well I have recently decided to go back to AutoIT to write a script to perform a series of clicks to do this form for me over and over. The problem is that I have to fill out an alphanumerical sequence that pops up every few times... I am able to tell the mouse where and when to click. I will also be able to tell it how to read the sequence and enter it. The issue is how in the world do I put it together? Since the sequence is always in red writing I have tried to tell it to search in the area it will appear every time the script loops, but with my lack of knowledge of AutoIT I am unsure how to use the PixelSearch function at all and how to position it so it doesn't come up with errors.. Any help would be appreciated ^^

This is all I could figure out...

$answer = MsgBox(4, "AutoIT Script", "This script will fill out a form including all alphanumeric sequences.  Run?")

If $answer = 7 Then
    MsgBox(0,"AutoIT Script", "Ok then, bye!")
    Exit
EndIf

If Not $answer = 7 Then 
    _StartCapatcha ()
EndIf

Func StartCapatcha ()
Sleep (2500)
MouseMove (570, 300)
Sleep (700)
MouseClick ("Left")
Sleep (200)
MouseClick ("Left")
Sleep (1000)
MouseMove (450, 270)
Sleep (500)
MouseClick ("Left")
PixelSearch (230,150,320,150,0xFC5A5A)
If @error Then 
_Continue ()
EndIf
If Not @error Then 
MsgBox (0,"AutoIT Script","Found Capatcha")
EndIf
EndFunc

Func Continue ()
Sleep (100)
MouseMove (410, 400)
Sleep (100)
MouseClick ("Left")
Sleep (400)
Send ("2000000")
MouseMove (520, 350)
Sleep (100)
MouseClick ("Left")
Sleep (100)
MouseMove (460, 260)
Sleep (100)
MouseClick ("Left")
Sleep (500)
MouseClick ("Left")
Sleep (400)
MouseClick ("Left")
_StartCapatcha ()
EndFunc

Share this post


Link to post
Share on other sites



... 
If Not $answer = 7 Then 
 _StartCapatcha () 
EndIf
 ...

Do a forum search on "captcha" to see what usually happens with this kind of requests ...

Share this post


Link to post
Share on other sites

... 
If Not $answer = 7 Then 
 _StartCapatcha () 
EndIf
 ...

Do a forum search on "captcha" to see what usually happens with this kind of requests ...

Thanks, though the search didn't prove that useful. Could you possibly help me with the pixelsearch function? I want to make it so if it finds the colour i have put in (The red writing of the capatcha) then it goes to a separate function which tells it how to read it. I can tell it how to read it and all that, its just the switch to a different function that has me utterly clueless. So if it does find it, a separate function solves it, but if it isn't found, it switches to func _Continue () because its only every 5 or 6 loops the capatcha comes up.

Thanks for everything and I honestly didn't think that this post would get any attention. ^^

Share this post


Link to post
Share on other sites

Pixel Search is pretty easy to use...

If you are trying to use it to read captcha text you may be confused on what it actually does.

PixelSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ColorID [, Variation, Fast|RGB]

Taken from auto it help file...

PixelSearch, Px, Py, 200, 200, 300, 300, 0x9d6346, 3, Fast
if ErrorLevel
    MsgBox, That color was not found in the specified region.
else
    MsgBox, A color within 3 shades of variation was found at X%Px% Y%Py%.

This will get the first pixel it finds with color ID of 0x9d6346 and up to 3 shades of a variation from it in the area starting at 200x 200y and then go to 300x 300y.

200x 200y - 300x 300y means it is searching an area of 100x100.

It will return the X Y coords of the first pixel that matches in the vars $Px $Py (in this example)

Now if you want to use it for possibly what it sounds like I can't help you.

But that's how/what pixel search works/is.

I use a simple script that tells me the color at my mouse pointer in a tooltip constantly and then I use a hotkey to terminate the script which then pops up a msgbox with x/y/pixel color.

You may consider using something like that to find the right color/coords.

Good luck

Share this post


Link to post
Share on other sites

Thanks a ton man. By the way, on a a last note, how do I make it so if i press a button it terminates the script? I was hoping to make it either the enter key, or F5.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Argh. Sorry, the code you provided did not work well for me. It doesn't understand what you mean by "ErrorLevel" and when you say you don't think this is the right tool for what I need, the reason I think it is useful is because when the window pops up and ask you to put in the capatcha, the text you must input is just in plain red with no font or font size changes. So I want the pixelsearch to look in the area it always it if it pops up and if the red text is found, it goes to a different function that solves it, then goes back to the loops function.

This is what I have got from looking around the internet and by inputting what you have shown me:

I have also tried to make it come up with a MsgBox if it does find a capatcha just for now. I have not yet written the Solving function.

MsgBox(0, "AutoIT", "This script will use a macro to fill in the form")
 Start()

Func Start()
Sleep (2500)
MouseMove (570, 300)
Sleep (700)
MouseClick ("Left")
Sleep (200)
MouseClick ("Left")
Sleep (1000)
MouseMove (450, 270)
Sleep (500)
MouseClick ("Left")
Sleep (100)
PixelSearch ( 230, 120, 320, 150, 0xF0000, 3)
if ErrorLevel
    Continue()
else
    MsgBox (0, "AutoIT", "Capatcha Found")
EndFunc

Func Continue()
MouseMove (410, 400)
Sleep (100)
MouseClick ("Left")
Sleep (400)
Send ("2000000")
MouseMove (520, 350)
Sleep (100)
MouseClick ("Left")
Sleep (100)
MouseMove (460, 270)
Sleep (100)
MouseClick ("Left")
Sleep (500)
MouseClick ("Left")
Sleep (400)
MouseClick ("Left")
Loop()
EndFunc

Func Loop()
Sleep (200)
MouseMove (400, 415)
MouseClick ("Left")
PixelSearch ( 230, 120, 320, 150, 0xF0000, 3)
if ErrorLevel
    Continue()
else
    MsgBox (0, "AutoIT", "Capatcha Found")
Sleep (500)
MouseClick ("Left")
Sleep (100)
MouseMove (410, 400)
Sleep (100)
MouseClick ("Left")
Sleep (400)
Send ("2000000")
MouseMove (520, 350)
Sleep (100)
MouseClick ("Left")
Sleep (100)
MouseMove (460, 270)
Sleep (100)
MouseClick ("Left")
Sleep (500)
MouseClick ("Left")
Sleep (400)
MouseClick ("Left")
EndFunc
Edited by Rustle

Share this post


Link to post
Share on other sites

Thanks a ton man. By the way, on a a last note, how do I make it so if i press a button it terminates the script? I was hoping to make it either the enter key, or F5.

Not a topic for these forums.

*click*


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0