Help with Autoit v3 Image Search

06/22/2014 13:46 BucShotz#1
I play Saga of Ryzom, an old MMo that's still awesome, but that's besides the point.

Have been working on a script that would allow me to change weapons using f5-f12 (4weapons, 4 magic amplifiers) and decided o use image search. i downloaded the dll and au3 files for it and have placed them everywhere ive read they needed to be, hoping somebody can help!

Since i can't post pictures yet -_- i'll explain how it works. you have to click on ur right hand to open a menu with all weapons in ur inventory(hence the first mouse commands) then this is where i need image search to work.


Here's the first step of the code.
--------------

#RequireAdmin

#include <ImageSearch.au3>

HotKeySet("{f5}", "sworddagger")

$X = 0
$Y = 0

Func sworddagger()
MouseMove(1155, 121, 2)
MouseClick("left", 1155, 121, 1, 2)
sleep(300)
$Search = _ImageSearch(@scriptdir&"\OP1hsword.bmp", 1, $X, $Y, 0)
If $Search = 1 Then
MouseMove($X, $Y, 2)
MouseClick("left",$X, $Y, 1, 2)
EndIf
EndFunc

while 1
sleep(100)
WEnd


I'm not getting any errors, the script just stops after its initial click to open the inventory menu. I've also tried putting both the dll and au3 file in the folder where i have the images and using #include "imagesearch.au3" and nothing. also have dropped all bmp and png files to the Include folder and nothing, im all out of ideas. Someone please help, and thank you!
06/23/2014 15:37 berkay2578#2
Why not use PixelSearch? ImageSearch seems unnecessary for me.

[Only registered and activated users can see links. Click Here To Register...]
Code:
PixelSearch ( left, top, right, bottom, color [, shade-variation = 0 [, step = 1 [, hwnd]]] )
Here's an example:
Code:
; Find a pure red pixel in the range of Left 0 to Left 20 & Top 0 to Top 300
Local $aCoord = PixelSearch(0, 0, 20, 300, 0xFF0000)
If Not @error Then
    MsgBox(0, "", "X and Y are: " & $aCoord[0] & "," & $aCoord[1])
EndIf

; Find a pure red pixel or a red pixel within 10 shades variations of pure red
$aCoord = PixelSearch(0, 0, 20, 300, 0xFF0000, 10)
If Not @error Then
    MsgBox(0, "", "X and Y are: " & $aCoord[0] & "," & $aCoord[1])
EndIf
06/26/2014 06:12 flumio#3
You need to be in Windowmode.
07/11/2014 06:38 VitorCornelius#4
Quote:
Originally Posted by BucShotz View Post
I play Saga of Ryzom, an old MMo that's still awesome, but that's besides the point.

Have been working on a script that would allow me to change weapons using f5-f12 (4weapons, 4 magic amplifiers) and decided o use image search. i downloaded the dll and au3 files for it and have placed them everywhere ive read they needed to be, hoping somebody can help!

Since i can't post pictures yet -_- i'll explain how it works. you have to click on ur right hand to open a menu with all weapons in ur inventory(hence the first mouse commands) then this is where i need image search to work.


Here's the first step of the code.
--------------

#RequireAdmin

#include <ImageSearch.au3>

HotKeySet("{f5}", "sworddagger")

$X = 0
$Y = 0

Func sworddagger()
MouseMove(1155, 121, 2)
MouseClick("left", 1155, 121, 1, 2)
sleep(300)
$Search = _ImageSearch(@scriptdir&"\OP1hsword.bmp", 1, $X, $Y, 0)
If $Search = 1 Then
MouseMove($X, $Y, 2)
MouseClick("left",$X, $Y, 1, 2)
EndIf
EndFunc

while 1
sleep(100)
WEnd


I'm not getting any errors, the script just stops after its initial click to open the inventory menu. I've also tried putting both the dll and au3 file in the folder where i have the images and using #include "imagesearch.au3" and nothing. also have dropped all bmp and png files to the Include folder and nothing, im all out of ideas. Someone please help, and thank you!
Hy all,

First of all, why u use mouse move order, then mouse click? Mouse click will be enough, since it will click on the correct coordinate, doesent matter on the mouse location before click. Other thing, i do not think so it will ever work like that. You should use pixelchecksum order instead of try to match a BMB pic with ING pic.

Other advice, if you do not know anything about what you are doing, you should learn or stop doing programcodeing. Cause copy paste will not work at all. ;)

You should print the methode on your screen, what your script do, then you will know what is the problem. For that the easyest orders:
MsgBox
Tooltip

Your script is stopped, cause BMP not match with your screen stuff.

Quote:
@scriptdir&"\OP1hsword.bmp
Guess what is this?

P.S.: Copy Paste "cheaters" :handsdown:

//to berkay2578 - PixelSearch will search a pixel on the coordinate, he need area scan, not pixel...
07/11/2014 14:00 berkay2578#5
Quote:
//to berkay2578 - PixelSearch will search a pixel on the coordinate, he need area scan, not pixel...
Not necessarily... he can find a special color for each item. It will be faster and it will work.
07/13/2014 06:05 BucShotz#6
got it working with pixelsearch. yes im new to this, figured out mouse click works fine alone. thanks all :)
09/17/2015 21:51 what_is_the_word#7
I am having trouble getting my script to interact or recognize bluestacks. Are your coords desktop coords or window (hwnd) coords?
09/17/2015 22:00 Moneypulation#8
Quote:
Originally Posted by what_is_the_word View Post
I am having trouble getting my script to interact or recognize bluestacks. Are your coords desktop coords or window (hwnd) coords?

If you are using the normal Pixel- and ImageSearch functions, they will return absolute (desktop) coordinates