Jump to content
Atoxis

Working ImageSearch - (Moved)

Recommended Posts

Atoxis

Howdy, I've gone through a lot of au3 forums, and I once had a working Imagesearch script that I got from here.  However, and i'm just totally not sure how but my imagesearch scripts aren't working anymore.
I'm not new to au3 but i'm not the most experienced with it's syntax/commands.

Anyways, I've looked over the big threads involving imagesearch.

Does anyone have a working Imagesearch x64 for win10 that is currently working as of the date with the post.

Dll's and what not is fine, just when I tell the script to run, I want to be able to find the image on the screen!
Can't find a working copy so if anyone has one please send it my way lol.

I've taken all the imagesearch downloads and what not and have played with them but I can't get any of them working on my end, despite others saying they're working.
Thanks.

Share this post


Link to post
Share on other sites
Earthshine

under display settings, make sure your Scale and Layout is set to  100% and not more.


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
JLogan3o13

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
Atoxis
On ‎6‎/‎27‎/‎2018 at 12:54 PM, Earthshine said:

under display settings, make sure your Scale and Layout is set to  100% and not more.

I'm fine on that front.  Just waiting for others to reply with working code.  If anyone is experienced enough I can dump the folder that I have that used to be my old working image search.

 

Share this post


Link to post
Share on other sites
robertocm

OpenCV match feature could be an alternative to search for an image inside another image

See also this example of image compare:

 

 

 

Share this post


Link to post
Share on other sites
careca

Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
autocart
Posted (edited)

Hi Atoxis,

I kind of "wrapped" the ImageSearch command from ... *cough* ... cannot say it out loud in here ... (*whispering*) AutoHotKey ... to an AutoIt function.

Of course a separate dll must be downloaded from here: https://hotkeyit.github.io/v2/
Either one of the dll packages (v1 or v2) should do the trick. Just don't use the help file of v1. It's confusing and misleading. Even the author says on that page that it is outdated. Don't know why it is still packaged with the v1 zip package. So make sure to at least download v2 for the help file. And, if you want it, v1 for the possibly more stable version? If you should be using the 32-bit v1 version after all, make sure to be using the "w" version, not the "a".

I am not an expert with dll calls. So the code underneath is the result of trial and error based on reading the help files rather than of always exactly knowing what must be coded. I also did not do much error catching in the code - or none at all - but the code is not so complicated nor long. It also might not be the fastest ImageSearch-code out there, but hey, the code works for me (on Win 8.1 x64 and with both 32-bit and 64-bit AutoIt) and I think it is fairly simple to implement. But I am willing to work on improving the code upon feedback. (The additional plus of this code is that you can practically wrap any ahk command or fuction to AutoIt by copying and slightly adapting the code. Not that there would be much need for that but who knows, maybe tomorrow one of us stumbles upon another case like ImageSearch.)

Hope it helps either you, Atoxis, or someone else in the future.
Regards, S.
 

$searchAreaX1 = xxxxx ;//upper left X value of search area
$searchAreaY1 = yyyyy ;//upper left Y value of search area
$searchAreaX2 = xxxxxx ;//lower right X value of search area
$searchAreaY2 = yyyyyy ;//lower right Y value of search area
$OptionsAndImageFile = "..." ;//e.g. "*20 *TransBlack (relative) path to image.png", see https://www.autohotkey.com/docs/commands/ImageSearch.htm
;~ $ImageSearchCoordMode = "..." ;//Specify whether all coordinates are relative to "Screen|Window|Client". Can be skipped. Default is "Window" (meaning the one active while the ImageSearch function runs). see also https://www.autohotkey.com/docs/commands/CoordMode.htm

WinActivate(".......", "") ;//if coordinates are relative to window, it makes sense to activate the desired window before performing the search
WinWaitActive("[LAST]")

$imageFoundAt = ImageSearch_ahk_wrapped($searchAreaX1, $searchAreaY1, $searchAreaX2, $searchAreaY2, $OptionsAndImageFile)
If $imageFoundAt[0] Then
    MsgBox(0, "ImageSearch results", "Image found at the coordinates: X " & $imageFoundAt[0] & ", Y " & $imageFoundAt[1])
Else
    MsgBox(0, "ImageSearch results", "Image not found.")
EndIf


;// VVV BEGINNING OF "WRAPPER"-FUNCTION: VVV
Func ImageSearch_ahk_wrapped($searchAreaX1, $searchAreaY1, $searchAreaX2, $searchAreaY2, $OptionsAndImageFile, $ImageSearchCoordMode = "Window")

;// >>> IN THE NEXT 4 LINES OF CODE CHOOSE THE DLL OF YOUR CHOICE SO THAT IT FITS THE BIT-VERSION OF YOUR DESIRED AUTOIT.EXE BY COMMENTING THE OTHER LINES OUT. THIS WAY THE CODE CAN BE REUSED/REVISITED AND QUICKLY ADAPTED.
;// >>> IN THE NEXT 6 LINES OF CODE ADAPT THE PATHS/STRINGS TO YOUR LOCAL CIRCUMSTANCES.
;~  $path_to_AutoHotkey_dll = ".\ahkdll-v1-release-master\Win32w\AutoHotkey.dll"
;~  $path_to_AutoHotkey_dll = ".\ahkdll-v1-release-master\x64w\AutoHotkey.dll"
;~  $path_to_AutoHotkey_dll = ".\ahkdll-v2-release-master\Win32w\AutoHotkey.dll"
    $path_to_AutoHotkey_dll = ".\ahkdll-v2-release-master\x64w\AutoHotkey.dll"
    
    $part_of_path_identifying_version1 = "ahkdll-v1-release-master"
    $part_of_path_identifying_version2 = "ahkdll-v2-release-master"

    $hDll = DllOpen($path_to_AutoHotkey_dll)

    DllCall($hDll, "UINT_PTR:cdecl", "ahkdll", "wstr", "", "wstr", "", "wstr", "")
    If StringInStr($path_to_AutoHotkey_dll, $part_of_path_identifying_version1) Then
        DllCall($hDll, "BOOLEAN:cdecl", "ahkExec", "wstr", "CoordMode Pixel, " & $ImageSearchCoordMode)
        DllCall($hDll, "BOOLEAN:cdecl", "ahkExec", "wstr", "ImageSearch foundX, foundY, " & $searchAreaX1 & ", " & $searchAreaY1 & ", " & $searchAreaX2 & ", " & $searchAreaY2 & ", " & $OptionsAndImageFile)
    ElseIf StringInStr($path_to_AutoHotkey_dll, $part_of_path_identifying_version2) Then
        DllCall($hDll, "BOOLEAN:cdecl", "ahkExec", "wstr", "CoordMode ""Pixel"", """ & $ImageSearchCoordMode & """")
        DllCall($hDll, "BOOLEAN:cdecl", "ahkExec", "wstr", "ImageSearch foundX, foundY, " & $searchAreaX1 & ", " & $searchAreaY1 & ", " & $searchAreaX2 & ", " & $searchAreaY2 & ", """ & $OptionsAndImageFile & """")
    EndIf
    $foundX = DllCall($hDll, "wstr:cdecl", "ahkgetvar", "wstr", "foundX", "UInt", 0)
    $foundY = DllCall($hDll, "wstr:cdecl", "ahkgetvar", "wstr", "foundY", "UInt", 0)
    Local $returnArray[2]
    $returnArray[0] = $foundX[0]
    $returnArray[1] = $foundY[0]

    DllClose($hDll)

    Return $returnArray
EndFunc

 

 

Edited by autocart
  • Like 1

Share this post


Link to post
Share on other sites
Uten

Make sure you test with screen scale set to 100% Then test with different scale. I have struggled with some code comparing images. Turned out capturing code got offset when screen scale was not 100%. I gave up on ImageSearch.dll 3 months ago. Could be the same problem.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • SolemnStrike
      By SolemnStrike
      Hey, 
      I know the title sounds weird, but i couldn't find better words for it...
      I finally managed to have a working image search (yes yes i know image search is evil :p).
      I noticed that even if the script is compiled, the images have to be in my script folder.
      But i don't want that the images i'm searching for on the screen can be viewed, edited etc by every user.
      Is there a way to... uhm... put them in a file like .rar, but one that can't be easily opened? 🤔
       
      Edit: Now that i think of .rar, maybe using a .rar which is protected by a password... Can autoit search, open, extract, use and delete that? (I guess so, I didn't search for this yet, going to google that asap)
    • VIP
      By VIP
      Use MouseClick()  mybe must/need:
      #RequireAdmin  
      DLL incuded on script!
      ; #INDEX# ================================================================================================= ; Title .........: ImageSearch ; AutoIt Version : 3.x ; Language ......: English ; Description ...: Check image Appears or Not and Return the position of an image on the desktop ; Author(s) .....: Dao Van Trong - TRONG.LIVE ; ================================================================================================= ; #CURRENT# ================================================================================================= ; _ImageSearch ; _ImageSearch_Area ; _ImageSearch_Wait ; _ImageSearch_WaitArea ; ================================================================================================= ;=============================================================================== ; ; Author:...........: AutoIT VietNam : Dao Van Trong - TRONG.LIVE ; Description:......: Check image Appears or Not ; Find and return the position of an image on the desktop ; Syntax:........... _ImageSearch_Area, _ImageSearch ; Parameter(s):..... $_ImagePath: The image to locate on the desktop ; May be a list of image by delimited by "|" ; i.e: $_ImagePath = "image1.bmp|image2.bmp|image3.bmp" ; $P_x1 $P_y1: Position of 1st point ; $P_x2 $P_y2: Position of 2nd point - Default is last botton right of desktop ; $_Tolerance: 0 for no tolerance (0-255). Needed when colors of image differ from desktop. e.g GIF ; $_CenterPos: boolen. True will return $array[1] x $array[2] is center of image found. ; False will return top-left position ; Return Value(s):.. Return an array has 3 item ; On Success: $array[0] 1 ; On Failure: $array[0] 0 ; DLL not found or other error: $array[0] -1 ; $array[1] x $array[2]: position of image what found on desktop ; ; Note:............. Use _ImageSearch to search the entire desktop ; _ImageSearch_Area to specify a desktop region to search ; $_ImagePath with more item need more time appear on screen before function can detect. ; Decrease sleep time in the loop to detect faster. But less performance. I.e CPULoad increased ; ;===============================================================================  
    • Nick3399
      By Nick3399
      I have loaded FastFind into my code and it takes a snapshot and creates a BMP file from it. 
      My issue is now I want to imagesearch from that BMP file (or snapshot memory) and look for a specific image from that image and get the coordinates from that. 
      I have looked at all the documentation but I cannot find anything to assist me.
       
      Does anyone have any idea?
    • nooneclose
      By nooneclose
      My program has to first search for names in Column D that do not match up with column C. I got that search to work using arrays. It was slow and I could not figure out how to delete them so I just manually put coded the names that do not belong. I found their cell location but I do not know how to store that location and delete it.
      This is what I have so far.
      Local $NameToDelete1[6]  = _Excel_RangeFind($OpenWorkbook, "Smith, Bill") _ArrayDisplay($NameToDelete1, "Excel UDF: _Excel_RangeFind Example 1", "", 0, "|", "Sheet|Name|Cell|Value|Formula|Comment") _Excel_RangeDelete($OpenWorkbook.ActiveSheet, $NameToDelete1[2], $xlShiftUp)  
      Please help, I wanted to have this program done yesterday but I did not see this problem until yesterday. 
    • Xandy
      By Xandy
      Special thanks: AdmiralAlkex, Melba23, MrCrearoR, Dragon Warrior 3, SDL
      MapIt is a tile world editor.  MapIt was built around the concept of reversing Dragon Warrior map images.  MapIt can take image input and produce a tile and world array.  
      Changing and replacing tile / world data is easy.  B/c tile world editor.

      CTRL+R in image above to signal replace tile action and I use "G" to Get the tile under mouse.
      A full list of hotkeys can be assigned in the: Help Menu\Hotkeys
       
      MapParser is a C++ project that scans images for unique tiles. 
      MapIt can be downloaded without MapParser. MapParser can be toggled off in the Scan_Image dialog. Without MapParser, MapIt will use the Scan_Tiles() function written in AutoIt ; which is 100 * slower Idk. If MapParser.exe will not run for you:      Installing Visual C++ Redistributable for Visual Studio 2015 should fix it: https://www.microsoft.com/en-us/download/details.aspx?id=48145   
      You can start with example world and tiles.
      Example world was made following these steps:
      Started with a tile map image of DragonWarrior3 town of: Reeve From MapIt World Menu \ New \ Scan_Image dialog, I set the area to exclude the key legend to the far right of image. After scanning the map image to world and tile array.  I removed a few of the map artifacts.  More work could be done on this world; removing unwanted tiles, but it is fine for now. I saved my world to disk.  This creates folder: Worldname: Containing folder of Tiles and a Worldname.txt. Using The Gimp, I edited some tiles to have a transparent color: Stairs, Trees, Desk Tables, Chest-of-drawers, Chairs, Signs, Doors, Beds. I changed the world layers to 2: World Menu \ Properties. F9 Finds all selected tile on current layer and changes to a new selected tile on new layer. I used F9 to change all Trees on layer: 0 to Trees on layer: 1. Then I used F9 to change all Trees on layer: 0 to Grass on layer: 0  
      In this video you can see how I used the Tile Menu \ Replace From Disk option to remap tile images to my custom tiles.  Conveniently my tiles already have a transparent pixel.
      See video for how that was done:
      To use the example world:
      First unzip the world save file: http://songersoft.com/programming/mapit/worlds/Reeve_Swapped.zip From the World Menu: choose \Load Navigate to the Reeve_Swapped.txt located in the extracted zip. Or you can scan any image.
      The map images I used are here: http://www.realmofdarkness.net/dq/games/nes/dw3/maps/world
      For download, videos, and example of created world file data; please visit the MapIt webpage: http://songersoft.com/programming/mapit/mapit_about.phtml
×