imagesearch
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
imagesearch [2018/05/10 14:40] – thekojukinator | imagesearch [2018/05/10 15:09] (current) – thekojukinator | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
===== Overview ===== | ===== Overview ===== | ||
- | I came across | + | I needed |
- | I found a solution in [[https:// | + | I found a solution in [[https:// |
- | I took the //UDF// library and made the following improvements to it: | + | I took the **UDF** library and made the following improvements to it: |
- | * Updated relevant functions to return an array of //[x,y]// coordinates on success, and //False// on failure. Original search functions returned | + | * Updated relevant functions to return an array of '' |
* Updated relevant functions with an extra parameter for a window handle, making it possible to limit the search area to the boundaries of a specified window. | * Updated relevant functions with an extra parameter for a window handle, making it possible to limit the search area to the boundaries of a specified window. | ||
- | * Added the ability to handle multi-monitor desktops by re-defining desktop boundaries in to new // | + | * Added the ability to handle multi-monitor desktops by re-defining desktop boundaries in to new global |
- | ===== Syntax | + | ===== Example |
- | + | ||
- | The best intro to the syntax is in my example code... | + | |
<code autoit> | <code autoit> | ||
- | ; includes | + | ; Include the ImageSearch library |
- | # | + | # |
- | + | ||
- | ; Ref: https:// | + | |
- | ; Enforce pre-declaration of variables, helps develop good coding habits | + | |
- | AutoItSetOption("MustDeclareVars", | + | |
- | ; Set the mouse coordinate mode to screen absolute | + | |
- | ; 0 = relative to active window | + | |
- | ; 1 = absolute screen | + | |
- | ; 2 = relative to client area of active window | + | |
- | AutoItSetOption(" | + | |
; This will be the target image file to search for | ; This will be the target image file to search for | ||
- | Local $target = ".\ImageSearch_target.png" | + | Local $target = "DemoTarget.png" |
; Declare an init a variable to hold the search result | ; Declare an init a variable to hold the search result | ||
- | Local $result = 0 | + | Local $result = False |
- | + | ||
- | ; EXAMPLE 1 | + | |
- | ; Find the image in a specified area, and move the mouse to its location | + | |
- | $result = _ImageSearchArea($target, | + | |
- | If IsArray($result) Then MouseMove($result[0], | + | |
- | + | ||
- | ; EXAMPLE 2 | + | |
; Find the image across the entire desktop | ; Find the image across the entire desktop | ||
$result = _ImageSearch($target, | $result = _ImageSearch($target, | ||
+ | ; If found, move the mouse to it | ||
If IsArray($result) Then MouseMove($result[0], | If IsArray($result) Then MouseMove($result[0], | ||
- | |||
- | ; The above examples accomplish the same goal, in fact _ImageSearch actually | ||
- | ; calls _ImageSearchArea with predetermined parameters | ||
</ | </ | ||
- | |||
- | More in-depth function documentation is included in the comments of // | ||
===== Download ===== | ===== Download ===== |
imagesearch.1525977608.txt.gz · Last modified: 2018/05/10 14:40 by thekojukinator