|
You last visited: Today at 18:17
Advertisement
_imageSearchArea Help
Discussion on _imageSearchArea Help within the AutoIt forum part of the Coders Den category.
04/01/2014, 20:46
|
#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).
|
|
|
04/01/2014, 22:19
|
#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.
|
|
|
04/02/2014, 02:02
|
#3
|
elite*gold: 27
Join Date: Sep 2009
Posts: 5,609
Received Thanks: 1,596
|
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
|
|
|
04/02/2014, 03:03
|
#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 ?
|
|
|
04/02/2014, 03:29
|
#5
|
elite*gold: 27
Join Date: Sep 2009
Posts: 5,609
Received Thanks: 1,596
|
Quote:
Originally Posted by turtlebeach
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
|
|
|
04/02/2014, 05:08
|
#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
|
|
|
04/02/2014, 16:21
|
#7
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
Recursion error missle launched - Impact in 2000 calls.
Quote:
Originally Posted by Paraly
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
|
|
|
|
04/04/2014, 17:33
|
#8
|
elite*gold: 0
Join Date: Jan 2013
Posts: 426
Received Thanks: 129
|
Quote:
Originally Posted by Paraly
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.
|
|
|
04/04/2014, 19:04
|
#9
|
elite*gold: 27
Join Date: Sep 2009
Posts: 5,609
Received Thanks: 1,596
|
Quote:
Originally Posted by FacePalmMan
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
|
|
|
04/04/2014, 22:43
|
#10
|
elite*gold: 0
Join Date: Jan 2013
Posts: 426
Received Thanks: 129
|
Quote:
Originally Posted by Paraly
***.. 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".
|
|
|
04/06/2014, 21:01
|
#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 ----------------------------------------------------------
|
|
|
Similar Threads
|
_ImageSearchArea Hilfe !!!
10/22/2010 - AutoIt - 4 Replies
Hallo alle zusammen ,
wie der Titel schon sagt ich brauche hilfe bei
_ImageSearchArea...
Ich blicke im moment garnicht durch deswegen würde ich etwas um Hilfe bitten.
Ihr könnt mir einfach nur erklären was wo hin muss etc etc etc
ich verstehe im moment den ganzen aufbau der funktion
|
All times are GMT +1. The time now is 18:17.
|
|