Jump to content
Sign in to follow this  
zutto

imagesearch help

Recommended Posts

zutto

yeah, i need sme help.. my script is clicking Top left of my screen and i have no idea why :<

#include <ImageSearch.au3>
;
Opt("WinWaitDelay",100)
Opt("MouseClickDelay", 100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)

#include <INet.au3>
#include <ImageSearch.au3>

$x1=0
$y1=0

sleep("5000")
$result = _ImageSearch("rway.bmp",0,$x1,$y1,0)
if $result=1 Then
mouseclick( "left", "227", "244", "30", "100" )
mouseclick( "left", "210", "235", "30", "100" )
mouseclick( "left", "226", "259", "30", "100" )
mouseclick( "left", "235", "241", "30", "100" )
;227, 244
;210, 235
;226, 259
;235, 241

Else
$result = _ImageSearch("resummon.bmp",1,$x1,$y1,0)
    MouseMove($x1,$y1,3)
    mouseclick("left")
EndIf

any hepl ;|?

EDIT: i tried, when i am not using imagesearch'es it clicks where it should.. but i have no idea why its not clicking where it should when imagesearch on.. ;<

Edited by zutto

Share this post


Link to post
Share on other sites
SmOke_N

you declare $x1 and $y1 as zero.

The reason it clicks in top left corner (x = 0, y = 0), is because you are in your "Else" statement where x and y are only zero.

Else
    MsgBox(64, "info", "X Position to click: " & $x1 & @CRLF & "Y Position to click: " & $y1)
    $result = _ImageSearch("resummon.bmp",1,$x1,$y1,0)
    MouseMove($x1,$y1,3)
    mouseclick("left")
EndIf

Put that message box there to see for yourself.

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.

Share this post


Link to post
Share on other sites
zutto

you declare $x1 and $y1 as zero.

The reason it clicks in top left corner (x = 0, y = 0), is because you are in your "Else" statement where x and y are only zero.

Else
    MsgBox(64, "info", "X Position to click: " & $x1 & @CRLF & "Y Position to click: " & $y1)
    $result = _ImageSearch("resummon.bmp",1,$x1,$y1,0)
    MouseMove($x1,$y1,3)
    mouseclick("left")
EndIf

Put that message box there to see for yourself.

point your attention to bolded area:

bolded area is the what its doing, and there is stated coords so.. it should not be clicking at 0,0..

$result = _ImageSearch("rway.bmp",0,$x1,$y1,0)

if $result=1 Then

mouseclick( "left", "227", "244", "30", "100" )

mouseclick( "left", "210", "235", "30", "100" )

mouseclick( "left", "226", "259", "30", "100" )

mouseclick( "left", "235", "241", "30", "100" )

;227, 244

;210, 235

;226, 259

;235, 241

Else

$result = _ImageSearch("resummon.bmp",1,$x1,$y1,0)

MouseMove($x1,$y1,3)

mouseclick("left")

EndIf

Share this post


Link to post
Share on other sites
SmOke_N

point your attention to bolded area:

bolded area is the what its doing, and there is stated coords so.. it should not be clicking at 0,0..

$result = _ImageSearch("rway.bmp",0,$x1,$y1,0)

if $result=1 Then

mouseclick( "left", "227", "244", "30", "100" )

mouseclick( "left", "210", "235", "30", "100" )

mouseclick( "left", "226", "259", "30", "100" )

mouseclick( "left", "235", "241", "30", "100" )

;227, 244

;210, 235

;226, 259

;235, 241

Else

$result = _ImageSearch("resummon.bmp",1,$x1,$y1,0)

MouseMove($x1,$y1,3)

mouseclick("left")

EndIf

I told you what it was doing from what we can see... obviously we can't test it.

If you put the Msgbox where I told you to, you'd see for yourself.


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.

Share this post


Link to post
Share on other sites
zutto

I told you what it was doing from what we can see... obviously we can't test it.

If you put the Msgbox where I told you to, you'd see for yourself.

did it.. but how i can change it then O,o it used to work..

EDIT: how can i get it to work then. since it gives error if no

$x1=0

$y1=0

at the start of script..

Edited by zutto

Share this post


Link to post
Share on other sites
zutto

Bring

up

my

post

EDIT:

sorry for bumping...

figured out howto solve that ;P

just made few new

&x2=**

&y2=** etc

sorry for bumping, feel free to delete this thread :)

Edited by zutto

Share this post


Link to post
Share on other sites
SmOke_N

Bring

up

my

post

Please don't bump your post more than once every 24 hours. No matter how important it is to you, there are others on the forum that would like assistance as well, and when you bump, you lower their posts.

To answer your question... you have to find the position... ImageSearch is not a standard UDF, and I'm not entirely (or at all) familiar with it or what it returns.

Bottom line, x and y have to equal something in order for it to click that spot you want, how it equals something is entirely up to you and the functions you use.


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.

Share this post


Link to post
Share on other sites
zutto

Please don't bump your post more than once every 24 hours. No matter how important it is to you, there are others on the forum that would like assistance as well, and when you bump, you lower their posts.

To answer your question... you have to find the position... ImageSearch is not a standard UDF, and I'm not entirely (or at all) familiar with it or what it returns.

Bottom line, x and y have to equal something in order for it to click that spot you want, how it equals something is entirely up to you and the functions you use.

sorry for it.. figured way to do it btw :)

just made few new

&x2=**

&y2=** etc

sorry for bumping, feel free to delete this thread :)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.