|
You last visited: Today at 19:40
Advertisement
Need help bg imagesearch autoit
Discussion on Need help bg imagesearch autoit within the AutoIt forum part of the Coders Den category.
03/28/2018, 22:55
|
#1
|
elite*gold: 0
Join Date: Feb 2014
Posts: 132
Received Thanks: 31
|
Need help bg imagesearch autoit
MY FUNC
#include <WinAPISysWin.au3>
Func _imagesearchbg($hwnd, $findimage, $resultposition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance, $hbmp = 0)
If $tolerance > 0 Then $findimage = "*" & $tolerance & " " & $findimage
If IsString($findimage) Then
$result = DllCall("bg.dll", "str", "ImageSearch", "hwnd", $hwnd, "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findimage)
Else
$result = DllCall("bg.dll", "str", "ImageSearch", "hwnd", $hwnd, "int", $x1, "int", $y1, "int", $right, "int", $bottom, "ptr", $findimage)
EndIf
If $result[0] = "0" Then Return 0
$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
$hwnd = WinGetHandle("Yeni Sekme - Google Chrome")
Global $x,$y
If _imagesearchbg($hwnd,"ara.png",0,0,0,_WinAPI_GetWi ndowWidth($hwnd),_WinAPI_GetWindowHeight($hwnd),$x ,$y,25) = 1 Then
MsgBox(0,$x,$y)
EndIf
But ı try and ı have a error "Subscript used on on-accessible variable"?
|
|
|
05/28/2018, 12:54
|
#2
|
elite*gold: 0
Join Date: Jan 2006
Posts: 163
Received Thanks: 15
|
are you using windows 10?
|
|
|
09/10/2018, 19:46
|
#3
|
elite*gold: 0
Join Date: Nov 2009
Posts: 105
Received Thanks: 8
|
Quote:
Originally Posted by lenclstr746
MY FUNC
#include <WinAPISysWin.au3>
Func _imagesearchbg($hwnd, $findimage, $resultposition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance, $hbmp = 0)
If $tolerance > 0 Then $findimage = "*" & $tolerance & " " & $findimage
If IsString($findimage) Then
$result = DllCall("bg.dll", "str", "ImageSearch", "hwnd", $hwnd, "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findimage)
Else
$result = DllCall("bg.dll", "str", "ImageSearch", "hwnd", $hwnd, "int", $x1, "int", $y1, "int", $right, "int", $bottom, "ptr", $findimage)
EndIf
If $result[0] = "0" Then Return 0
$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
$hwnd = WinGetHandle("Yeni Sekme - Google Chrome")
Global $x,$y
If _imagesearchbg($hwnd,"ara.png",0,0,0,_WinAPI_GetWi ndowWidth($hwnd),_WinAPI_GetWindowHeight($hwnd),$x ,$y,25) = 1 Then
MsgBox(0,$x,$y)
EndIf
But ı try and ı have a error "Subscript used on on-accessible variable"?
|
First of all, you have to import the imagesearchbg function, what u are useing in your script, or the "<WinAPISysWin.au3>" is that file?
_imagesearchbg($hwnd, $findimage, $resultposition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance, $hbmp = 0) Looks same as _ImageSearchArea function. But we do not know how the DLL work what you are useing. You should open the imagesearch function file what you are useing and then you will have the require help info for it if the owner provided it there.
You code is little bit chaotic. I can not test it, since i do not have the require files, but:
If _imagesearchbg($hwnd, "ara.png", 0, 0, 0, _WinAPI_GetWindowWidth($hwnd), _WinAPI_GetWindowHeight($hwnd), $x, $y, 25) = 1 Then
EndIf
MsgBox(0, $x, $y)
$x and $y variable have no value if the image is not found. you have to place the msgbox row between if / endif in your script like this:
If _imagesearchbg($hwnd, "ara.png", 0, 0, 0, _WinAPI_GetWindowWidth($hwnd), _WinAPI_GetWindowHeight($hwnd), $x, $y, 25) = 1 Then
MsgBox(0, $x, $y)
EndIf
msgbox title will be your X coordinate and the message on it will be the Y coord. If your imagesearch function work the same way as the _imagesearch.au3 then the X/Y coord what you found will be the image top left corner coordinate where it got found.
Other thing:
you are searching from 0,0 coordinate what is top left corner of your screen to the window size. It will work if the window is on the 0,0 coordinate. If you move the window then it will give you fals result. If the window is full screen, then you do not need to get the window size (WinGetClientSize also work). You can just use your screen size, or there is a function where you can grab your screen size (@DesktopHeight / @DesktopWidth).
BTW did you just copy + paste you code from several places, or you wrote it by yourself?
|
|
|
 |
Similar Threads
|
[Help] [AutoIT] Imagesearch stack overflow
08/26/2015 - AutoIt - 6 Replies
Hey everyone I'm playing around with auto it and I'm new. I haven't realy searched a lot for my problem but I wrote a skripts that is running. Its finding images clicking on them and everythin that I want but its running like 20-30 minutes or less or more and its stops, the scripts just exit and in the script I get this error:
"C:\Program Files (x86)\AutoIt3\Include\ImageSearch.au3" (34) : ==> Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.:
Func...
|
[GUIDE] AutoIt ImageSearch
10/18/2009 - Metin2 Guides & Templates - 14 Replies
Ein sehr praktischer Befehl in AutoHotkey: ImageSearch. (http://www.autohotkey.com/docs/commands/ImageSear ch.htm)
Was macht der Befehl?- er sucht den ganzen Bildschrim nach einem Vorgegebenen Bild ab. Vielleicht auch Nützlich für den Angelbot, weil die Leute nicht mehr Pixel suchen müsen, sondern nuch noch Screens machen müssen!
Diesen Befehl gibt es auch für AutoIt!
_________________________________________________ ___________________________
. Kopiere die ImageSearchDLL.dll in...
|
autoit pixelsearch bzw imagesearch
02/04/2009 - General Coding - 0 Replies
hi leute,
ich hab mir nen bot mit autoit programmiert. Es ist n Browsergame, das auf Flash basiert. Ich habe Imagesearch benutzt und alles funkzt prima.
Das Problem:
Der Pc ist immer besetzt, wenn ich botte...
Also meine Frage: Gibts da ne alternative zu ImageSearch, die auch in minimierten Fenstern funktioniert?
|
All times are GMT +1. The time now is 19:40.
|
|