Jump to content
Sign in to follow this  
dirkdork

Search for a phrase > Click 15 pixels above the phrase

Recommended Posts

dirkdork

I need help writing a very simple script. I want it to:

1. Search a FireFox3 based web-page for a certain phrase (from a list of 200 phrases), the first one found from the list would be used.

2. Move the mouse to that phrase, then up 15 pixels

3. Then Mouseclick "Left", on the image that is above the phrase.

If I can be specific in anyway, then please tell me!

Thanks a ton guys!

Share this post


Link to post
Share on other sites
UnknownWarrior

Umm, this should work.

$test = WinGetText("FireFox3", "YOUR TEXT GOES HERE")

If $text = 1 Then
    MouseClick("left", $text[0]+15, $test[1]+15)
EndIf

That was a random shot in the dark, it might have a few errors, post back on what it does.

Edited by UnknownWarrior

Share this post


Link to post
Share on other sites
dirkdork

This looks great but...

Error:

If $text = 1 Then
If ^ ERROR

Error: Variable used without being declared.

Also, how would I include more then one phrase to search for?

Ex: phrase 1, phrase 2, phrase 3... etc..

Edited by dirkdork

Share this post


Link to post
Share on other sites
UnknownWarrior

$text = WinGetText("FireFox3", "YOUR TEXT GOES HERE")

If $text = 1 Then
    MouseClick("left", $text[0]+15, $test[1]+15)
EndIf

Woops, small error: (I had $test= Wingettext, not teXt)

Multiple phrases um.. try this:

$text = WinGetText("FireFox3", "YOUR TEXT GOES HERE")
$text1 = WinGetText("FireFox3", "YOUR TEXT GOES HERE")
$text2 = WinGetText("FireFox3", "YOUR TEXT GOES HERE")

If $text = 1 Then
    MouseClick("left", $text[0]+15, $test[1]+15)
    Sleep(1000) <-- so the bot isn't going everywhere at once... Reduce time if needed
EndIf
If $text1 = 1 Then
    MouseClick("left", $text[0]+15, $test[1]+15)
    Sleep(1000) <-- so the bot isn't going everywhere at once... Reduce time if needed
EndIf
If $text2 = 1 Then
    MouseClick("left", $text[0]+15, $test[1]+15)
    Sleep(1000) <-- so the bot isn't going everywhere at once... Reduce time if needed
EndIf

I think you could do something with If... Elseif... Else... EndIf, but that should work just as well.

EDIT: Umm this: $text[0]+15, $test[1]+15) Might ahve to be reverted to this: $text[0], $test[1]+15) Cause the first array is the x coord and the 2nd is the y... And you want it to go up 15 coords so it should only be +15 on the 2nd one.... Try my first script, if it don't work, try this then.

Edited by UnknownWarrior

Share this post


Link to post
Share on other sites
dirkdork

No Errors! But, the picture was not clicked. I am double clicking the script to run, from the desktop, perhaps this effects where the script searches at?

How can I run this script by clicking a certain button?

Share this post


Link to post
Share on other sites
dirkdork

To show you an example of what the code would do. It would be used at http://www.yahoo.com/.

$text = WinGetText("Barack Obama beats John McCain")

If $text = 1 Then
    MouseClick("left", $text[0], $test[1]+40)
    Sleep(1000)
EndIf

So the script would find the text... Barack Obama beats John McCain... then click on the image above.

I didn't want to use a political example, it was just the first website I could find.

Edited by dirkdork

Share this post


Link to post
Share on other sites
UnknownWarrior

Gtg to bed now, hope this works:

HotKeySet("{F5}", "Pause")

$text=WinGetText("FireFox3", " YOUR TEXT")  ;--- MAKE SURE THIS IS THE EXACT TITLE AND EXACT TEXT YOUR LOOKING FOR.


Pause()
If $text = 1 Then
     WinWaitActive("FireFox3", "$text");--- waits for firefox to be opened and waits for that text to be present in firefox... If you do not want it to wait to see if the text is there, just take out "$text" to have: WinWaitActive("FireFox3")
     MouseClick("left", text[0], text[1]+15)
     Sleep(2000)
EndIf





Func Pause()                
    $Paused = Not $Paused
    While Not $Paused
              
              Sleep(200)
    WEnd
EndFunc

Not sure if the Pause thing will work or not but basically its saying you press F5 and the bot will stop/start. Like I said I'm very tired and I don't know if this is all right cause I can't really concentrate atm lol.

Share this post


Link to post
Share on other sites
dirkdork

I really appreciate your help, I'll try and make it work. Thanks!

If I have any problems I'll reply here again with the problem.

Night!

Share this post


Link to post
Share on other sites
UnknownWarrior

If you want, leave me a message and I'll be on at 4 p.m. Central timezone after school. Peace.

Share this post


Link to post
Share on other sites
dirkdork

It just plain doesn't work. :mellow:

I think we may just have to start over.

Share this post


Link to post
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
Sign in to follow this  

×