elitepvpers

elitepvpers (https://www.elitepvpers.com/forum/)
-   AutoIt (https://www.elitepvpers.com/forum/autoit/)
-   -   [AutoIT] ImageSearch failing on me? Halp pls (https://www.elitepvpers.com/forum/autoit/3388428-autoit-imagesearch-failing-me-halp-pls.html)

Gundogan 08/19/2014 19:02

[AutoIT] ImageSearch failing on me? Halp pls
 
Hey guys :)

So i recently wanted to start playing around with autoit and ImageSearch,
Heres the code:

Code:

#include <ImageSearch.au3>

HotKeySet("{F8}", "checkForImage")

global $y = 0, $x = 0

Func checkForImage()
  Local $search = _ImageSearch("checkImage.bmp", 0, $x, $y, 0)
          If $search = 1 Then
          MouseClick($x, $y, 10)
  EndIf
EndFunc

while 1
  sleep(200)
WEnd

When it fails i get this message: >"E:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\Christian\Dropbox\My Autoclicker\AcceptScript\SearchSomething.au3"
"E:\Program Files (x86)\AutoIt3\Include\ImageSearch.au3" (40) : ==> Subscript used on non-accessible variable.:
if $result[0]="0" then return 0
if $result^ ERROR
>Exit code: 1 Time: 2.425


Either i did something wrong in the code, or my autoit and installing of imagesearch is fk'd :)

Moneypulation 08/20/2014 08:02

Did you have the ImageSearch.dll in the same folder as your script?

alpines 08/20/2014 12:16

Actually its name is ImageSearchDLL.dll not ImageSearch.dll. Look it up in the UDF, normally it contains dll before dll.

Gundogan 08/20/2014 13:04

I do have the file ImagesearchDLL.dll in my folder, what else can it be?

KDeluxe 08/20/2014 23:21

The ImageSearch.au3 contains an error.
Code:

;===============================================================================
;
; Description:      Find the position of an image on the desktop
; Syntax:          _ImageSearchArea, _ImageSearch
; Parameter(s):
;                  $findImage - the image to locate on the desktop
;                  $tolerance - 0 for no tolerance (0-255). Needed when colors of
;                                image differ from desktop. e.g GIF
;                  $resultPosition - Set where the returned x,y location of the image is.
;                                    1 for centre of image, 0 for top left of image
;                  $x $y - Return the x and y location of the image
;
; Return Value(s):  On Success - Returns 1
;                  On Failure - Returns 0
;
; Note: Use _ImageSearch to search the entire desktop, _ImageSearchArea to specify
;      a desktop region to search
;
;===============================================================================
Func _ImageSearch($findImage, $resultPosition, ByRef $x, ByRef $y, $tolerance)
    Return _ImageSearchArea($findImage, $resultPosition, 0, 0, @DesktopWidth, @DesktopHeight, $x, $y, $tolerance)
EndFunc

Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance)
    If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
    $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)

    ; If error exit
    If @error Or $result[0] = "0" Then Return 0

    ; Otherwise get the x,y location of the match and the size of the image to
    ; compute the centre of search
    $array = StringSplit($result[0], "|")

    $x = Int(Number($array[2]))
    $y = Int(Number($array[3]))
    If $resultPosition == 1 Then
        $x = $x + Int(Number($array[4]) / 2)
        $y = $y + Int(Number($array[5]) / 2)
    EndIf
   
    Return 1
EndFunc


flumio 08/21/2014 05:48

Every week ... one person ... ask about this problem ... please use the search funktion. It is NOT funny, every week to type the same shit.

nofuture 08/21/2014 14:22

There are 3 possible mistakes:

1) One of your files doesn´t exist (in the expected folder)
Check, that your files
  • ImageSearch.au3
  • ImageSearchDLL.dll
  • Your Script-File (SearchSomething.au3)
  • Your Image-File (checkImage.bmp)
are in the same folder and for typing errors - additionally check line 42 in your ImageSearch.au3 - the ImageSearchDLL.dll could be changed to an other folder.

2) Access Denied
Possibly the Script-File have no read-access to your files.

3) Your Script runs in x64 mode
Try to run your script in x86-mode.

Goliard2k6 12/01/2018 02:39

#RequireAdmin ; <= Nicht vergessen
#include <ImageSearch.au3>

HotKeySet("{F1}", "Start")
HotKeySet("{F2}", "Pause")
HotKeySet("{F3}", "Stop")

$x1=0
$y1=0

Func Start()
While 1
;Täglicher Einloogbonus
$result = _ImageSearch("99.bmp", 1, $x1, $y1, 60)
If $result = 1 Then
$result = _ImageSearch("98.bmp", 1, $x1, $y1, 60) ;<=er klickt immer auf das Bild
If $result = 1 Then
MouseClick("left", $x1, $y1, 1)
Sleep(1000)
EndIf
EndIf ;suche nach 2 Bildern Gleichzeitig

$result = _ImageSearch("Questsabholen.bmp",0,$x1,$y1,60)
if $result=1 Then
MouseClick("left",$x1,$y1,1)
Sleep(1000)
EndIf

$AS = PixelSearch(807, 137,807, 137,0xFFF0C4,20);Quest ;suche nach farben
If not @error Then
$AS = PixelSearch(811, 162,811, 162,0xFFECC0,20);Quest
If not @error Then
$AS = PixelSearch(1187, 375,1187, 375,0xF8EF94,20);Abholen
If not @error Then
$AS = PixelSearch(1187, 375,1187, 375,0xF8EF94,20);Abholen
If not @error Then
MouseClick("left",1187, 375,1)
sleep(1000)
EndIf
EndIf
EndIf
EndIf

WEnd


While 1
Sleep(100)
WEnd

Func Pause()
sleep(36000000)
EndFunc

Func Stop()
Exit
EndFunc ;==>Stop

Viel Spaß damit!:handsdown::handsdown:


; ("99.bmp", 1, $x1, $y1, 60) 1 heist oben links vom Bild klickt er und 0 ist die klickt er in die Mitte


All times are GMT +1. The time now is 16:29.

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.