Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 22:48

  • Please register to post and access all features, it's quick, easy and FREE!

 

_imageSearchArea Help

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Mar 2012
Posts: 380
Received Thanks: 25
_imageSearchArea Help

Hello again all. I've found the autoIt Help file is amazing at answering questions, however I have not been able to find any documentation there for _ImageSearchArea. My google results have been just as unsuccessful so I'm hoping someone can help me understand how it works by providing a couple of concrete examples.

So, would someone be able to show me a couple of examples, such as

1) If my desktop is 1024 x 768 and I want to search only the top half of the desktop area for an image called blue_btn.png, what would that look like.

2) If my desktop is 1024 x 768 and I want to search only the left half of the desktop area for an image called blue_btn.png, what would that look like.

3), lastly, if my desktop is 1024 x 768, and I want to constrain the search to a box that is centered and is 800 wide by 400 tall (for the same image as above).



turtlebeach is offline  
Old   #2
 
elite*gold: 95
Join Date: May 2011
Posts: 982
Received Thanks: 189
in the imagesearch.au3 are explanations for the function.
just enter the coordinates of the area you want to search.


butter123 is offline  
Old   #3
 
elite*gold: 497
Join Date: Sep 2009
Posts: 3,630
Received Thanks: 966
Just call the function which you need.

Code:
Func _Top_half()
	$X = 0
	$Y = 0
	$bResult = _ImageSearchArea(@ScriptDir & "\blue_btn.png",1,0,0,@DesktopWidth,@DesktopHeight * 0.5,$X, $Y, 0)
	If $bResult = 1 Then
		MouseClick("LEFT",$X, $Y)
	Else
		_Top_half()
	EndIf
EndFunc


Func _Left_half()
	$X = 0
	$Y = 0
	$bResult = _ImageSearchArea(@ScriptDir & "\blue_btn.png",1,0,0,@DesktopWidth * 0.5,@DesktopHeight,$X, $Y, 0)
	If $bResult = 1 Then
		MouseClick("LEFT",$X, $Y)
	Else
		_Left_half()
	EndIf
EndFunc


Func _Centered()
	$X = 0
	$Y = 0
	$centerX = @DesktopWidth * 0.5
	$centerY = @DesktopHeight * 0.5
	$bResult = _ImageSearchArea(@ScriptDir & "\blue_btn.png",1,$centerX -400, $centerY -200, $centerX +400,$centerY +200,$X, $Y, 0)
	If $bResult = 1 Then
		MouseClick("LEFT",$X, $Y)
	Else
		_Centered()
	EndIf
EndFunc
Paraly is offline  
Thanks
1 User
Old   #4
 
elite*gold: 0
Join Date: Mar 2012
Posts: 380
Received Thanks: 25
that helps, is @DesktopWidth an automagically stored variable or is this a real number, ie would I need to put "1024" in wherever you have @DesktopWidth ?


turtlebeach is offline  
Old   #5
 
elite*gold: 497
Join Date: Sep 2009
Posts: 3,630
Received Thanks: 966
Quote:
Originally Posted by turtlebeach View Post
that helps, is @DesktopWidth an automagically stored variable or is this a real number, ie would I need to put "1024" in wherever you have @DesktopWidth ?
@DesktopWidht and @DesktopHeight are macros which contains automatically your current desktop resolution
Paraly is offline  
Thanks
1 User
Old   #6
 
elite*gold: 0
Join Date: Mar 2012
Posts: 380
Received Thanks: 25
Got it, thanks, that helped a ton. This is the best explanation of _ImageSearchArea on the net. My script is so much faster now and I'm only partially done with it
turtlebeach is offline  
Old   #7
 
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 812
Recursion error missle launched - Impact in 2000 calls.
Quote:
Originally Posted by Paraly View Post
Just call the function which you need.

Code:
Func _Top_half()
	$X = 0
	$Y = 0
	$bResult = _ImageSearchArea(@ScriptDir & "\blue_btn.png",1,0,0,@DesktopWidth,@DesktopHeight * 0.5,$X, $Y, 0)
	If $bResult = 1 Then
		MouseClick("LEFT",$X, $Y)
	Else
		_Top_half()
	EndIf
EndFunc


Func _Left_half()
	$X = 0
	$Y = 0
	$bResult = _ImageSearchArea(@ScriptDir & "\blue_btn.png",1,0,0,@DesktopWidth * 0.5,@DesktopHeight,$X, $Y, 0)
	If $bResult = 1 Then
		MouseClick("LEFT",$X, $Y)
	Else
		_Left_half()
	EndIf
EndFunc


Func _Centered()
	$X = 0
	$Y = 0
	$centerX = @DesktopWidth * 0.5
	$centerY = @DesktopHeight * 0.5
	$bResult = _ImageSearchArea(@ScriptDir & "\blue_btn.png",1,$centerX -400, $centerY -200, $centerX +400,$centerY +200,$X, $Y, 0)
	If $bResult = 1 Then
		MouseClick("LEFT",$X, $Y)
	Else
		_Centered()
	EndIf
EndFunc
alpines is offline  
Old   #8
 
elite*gold: 0
Join Date: Jan 2013
Posts: 419
Received Thanks: 128
Quote:
Originally Posted by Paraly View Post
Just call the function which you need.

Code:
Func _Top_half()
	$X = 0
	$Y = 0
	$bResult = _ImageSearchArea(@ScriptDir & "\blue_btn.png",1,0,0,@DesktopWidth,@DesktopHeight * 0.5,$X, $Y, 0)
	If $bResult = 1 Then
		MouseClick("LEFT",$X, $Y)
	Else
		_Top_half()
	EndIf
EndFunc


Func _Left_half()
	$X = 0
	$Y = 0
	$bResult = _ImageSearchArea(@ScriptDir & "\blue_btn.png",1,0,0,@DesktopWidth * 0.5,@DesktopHeight,$X, $Y, 0)
	If $bResult = 1 Then
		MouseClick("LEFT",$X, $Y)
	Else
		_Left_half()
	EndIf
EndFunc


Func _Centered()
	$X = 0
	$Y = 0
	$centerX = @DesktopWidth * 0.5
	$centerY = @DesktopHeight * 0.5
	$bResult = _ImageSearchArea(@ScriptDir & "\blue_btn.png",1,$centerX -400, $centerY -200, $centerX +400,$centerY +200,$X, $Y, 0)
	If $bResult = 1 Then
		MouseClick("LEFT",$X, $Y)
	Else
		_Centered()
	EndIf
EndFunc
Just at looking at it i can see that every single function would produce an stack overflow error.
calling the function over and over again will only fill the stack until it its full.
and after taking a closer look at it i see that you put the value 0 in the variables x and y, and never change it. that means when it finds the image, it moves the mouse to position 0,0 on the screen.
FacePalmMan is offline  
Old   #9
 
elite*gold: 497
Join Date: Sep 2009
Posts: 3,630
Received Thanks: 966
Quote:
Originally Posted by FacePalmMan View Post
Just at looking at it i can see that every single function would produce an stack overflow error.
calling the function over and over again will only fill the stack until it its full.
and after taking a closer look at it i see that you put the value 0 in the variables x and y, and never change it. that means when it finds the image, it moves the mouse to position 0,0 on the screen.
god.. this was just a explaination how _imagesearcharea works, what arguments are needed, he understand it so gtfo

Here is the code for people who only got the ability to copy paste without using their brain
Code:
#include <ImageSearch.au3>
Global $found = False, $X, $Y

;Search for the Pic at the Top half until its found;
Do
$found = _Top_half()
 sleep(25)
Until $found = True
$found = False

;Search for the Pic at the Left half until its found;
Do
$found = _Left_half()
 sleep(25)
Until $found = True
$found = False

;Search for the Pic at the Center until its found;
Do
$found = _Centered()
 sleep(25)
Until $found = True
$found = False
Exit



Func _Top_half()
	$bResult = _ImageSearchArea(@ScriptDir & "\blue_btn.png",1,0,0,@DesktopWidth,@DesktopHeight * 0.5,$X, $Y, 0)
	If $bResult = 1 Then
		MouseClick("LEFT",$X, $Y)
		Return True
	Else
		Return False
	EndIf
EndFunc


Func _Left_half()
	$bResult = _ImageSearchArea(@ScriptDir & "\blue_btn.png",1,0,0,@DesktopWidth * 0.5,@DesktopHeight,$X, $Y, 0)
	If $bResult = 1 Then
		MouseClick("LEFT",$X, $Y)
		Return True
	Else
		Return False
	EndIf
EndFunc


Func _Centered()
	$centerX = @DesktopWidth * 0.5
	$centerY = @DesktopHeight * 0.5
	$bResult = _ImageSearchArea(@ScriptDir & "\blue_btn.png",1,$centerX -400, $centerY -200, $centerX +400,$centerY +200,$X, $Y, 0)
	If $bResult = 1 Then
		MouseClick("LEFT",$X, $Y)
		Return True
	Else
		Return False
	EndIf
EndFunc
Paraly is offline  
Thanks
1 User
Old   #10
 
elite*gold: 0
Join Date: Jan 2013
Posts: 419
Received Thanks: 128
Quote:
Originally Posted by Paraly View Post
***.. this was just a explaination how _imagesearcharea works, what arguments are needed, he understand it so gtfo
jeese. i only pointed out a mistake you did (one that i until some weeks ago didnt even know about that it exists). im sorry but thats no reason to say "gtfo".
FacePalmMan is offline  
Old   #11
 
elite*gold: 0
Join Date: Mar 2012
Posts: 380
Received Thanks: 25
Well I don't know about all that jive trying to use a function to find it, seems to overcomplicate the matter. I just used the method to locate the center and then went from there, ie:

Code:
;Press accept function ----------------------------------------------------------
Func pressAccept()
    Local $result = _ImageSearchArea("pics/login/accept_btn.png", 1, $centerX -150, $centerY -70, $centerX +150,$centerY +70,$x, $y, $tol)
    If ($result == 1) Then
        MouseClick("left", $x, $y, 1)
    EndIf
EndFunc  
;Press accept function ----------------------------------------------------------


turtlebeach is offline  
Reply



« Previous Thread | Next Thread »

Similar Threads
_ImageSearchArea Hilfe !!!
Hallo alle zusammen , wie der Titel schon sagt ich brauche hilfe bei _ImageSearchArea... Ich blicke im moment garnicht durch deswegen würde ich...
4 Replies - AutoIt



All times are GMT +1. The time now is 22:48.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2017 elitepvpers All Rights Reserved.