Jump to content
Sign in to follow this  
Atoxis

Working ImageSearch - (Moved)

Recommended Posts

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

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


"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
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

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

Spoiler

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.

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

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

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By nacerbaaziz
      goodmorning; autoit team
      please their are any youtube search way working?
      because i was using the get source and split it to get the result but know it does not working any way.
      is the youtube disabled that? and is their any other simple way to do that?
      i tested all examples found in this post but also it don't work
      https://www.autoitscript.com/forum/topic/123945-youtube-search/
      and here is the example that i use to and it don't work any more
      local $hSearchOpenHNDL, $hSearchConnect, $sSearchGet local $a_UrlsArray[1][5] local $b_ButtonsDisabled = false, $b_SearchBTNFocus = false, $b_SearchListFocus, $h_SearchFocusHND local $Return = "0" local $s_OpenStringY = "/feed/trending" local $ChannelUrl = "", $channelName = "" if Not ($a_YoutubeSearchArray[0][0] = 0) then GUICtrlSetData($searchInp, $s_youtubeSearchLastSearch) $s_OpenStringY = "/results?search_query=" & StringReplace(GUICtrlRead($searchInp), " ", "+") $a_UrlsArray = $a_YoutubeSearchArray for $i = 1 to $a_UrlsArray[0][0] _GUICtrlListBox_AddString($SearchList, $a_UrlsArray[$i][0] & $a_UrlsArray[$i][2] & $a_UrlsArray[$i][3]) next _GUICtrlListBox_SetCurSel($SearchList, $I_youtubeSearchLastIndex-1) GUICtrlSetState($SearchList, $GUI_focus) else if Ping("youtube.com", 1000) > 1 then $hSearchOpenHNDL = _WinHttpOpen('') if not (@Error) then $hSearchConnect = _WinHttpConnect($hSearchOpenHNDL, "youtube.com") if Not (@Error) then $sSearchGet = _WinHttpSimpleRequest($hSearchConnect, "get", $s_OpenStringY) if not (@Error) then local $a_strings = _StringBetween($sSearchGet, '<a href="/watch', "<ul") local $title = "" local $url = "" local $length = "" local $result = "" GUICtrlSetData($SearchList, "") ReDim $a_UrlsArray[1][5] for $i = 0 to UBound($a_strings)-1 $url = _StringBetween($a_strings[$i], "?", '"') if @error then ContinueLoop $url = "https://www.youtube.com/watch?" & $url[0] $title = _StringBetween($a_strings[$i], 'dir="', '</a>') if @error then ContinueLoop $title = $title[0] $title = StringRegExpReplace($title, '(.*\"\>)', "") if StringRegExp($a_strings[$i], '[0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}', 0) = 1 then $length = StringRegExp($a_strings[$i], '[0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}', 2) elseIf StringRegExp($a_strings[$i], '[0-9]{1,2}\:[0-9]{1,2}', 0) = 1 then $length = StringRegExp($a_strings[$i], '[0-9]{1,2}\:[0-9]{1,2}', 2) else $length = "" endIf if IsArray($length) then $length = ": (" & $length[0] & ")" else $length = "" endIf $ChannelUrl = stringRegexpReplace($a_strings[$i], '(^.*?<a.*?\"(\/user|\/channel))+', "$2") $channelName = stringRegexpReplace($ChannelUrl, '(.*?\".*?>)(.*</a>)+', "$2") $ChannelUrl = stringRegexpReplace($ChannelUrl, '(\".*)+', "") $channelName = stringRegexpReplace($channelName, '(</a>.*)+', "") $result &= $title & @crlf & $url & @crlf ReDim $a_UrlsArray[UBound($a_UrlsArray)+1][5] $a_UrlsArray[UBound($a_UrlsArray)-1][0] = $title $a_UrlsArray[UBound($a_UrlsArray)-1][1] = $url $a_UrlsArray[UBound($a_UrlsArray)-1][2] = $length if not ($channelName = "") then $a_UrlsArray[UBound($a_UrlsArray)-1][3] = ", (" & $channelName & ")" if not ($channelUrl = "") then $a_UrlsArray[UBound($a_UrlsArray)-1][4] = "https://www.youtube.com" & $channelUrl $a_UrlsArray[0][0] = UBound($a_UrlsArray)-1 _GUICtrlListBox_AddString($SearchList, $a_UrlsArray[UBound($a_UrlsArray)-1][0] & $length & $a_UrlsArray[UBound($a_UrlsArray)-1][3]) next endIf endIf endIf endIf endIf  
      i hope any one can help me
      thanks in advance
    • By coronatuss
      Hello everyone,
      Im developing an script to check the size of all .jpg stored in windows folder.
      The problem is that it doesn´t work properly with rotated images. 
      With _GDIPlus_ImageGetWidth() and _GDIPlus_ImageGetHeight()  I get the Width and Height of images as if they had not been rotated, and I need to know how they are rotated (orientation and grades).
      Any help is welcome! If more info is needed, please tell. 😁
    • By nacerbaaziz
      hello autoit team
      please i've a question for you.
      am creating a audio player
      and in this audio player i want to show the current trac info
      such as the total time and the position ... etc
      i know i can show it as label
      but the screen reader for the blind read the text every change
      because it have a screen scan
      what i want is to show this informations but such image or icon
      i mean i need to create
      GUICtrlCreatepic or GUICtrlCreateicon ....
      or some thing as that
      and show this informations as image on it
      i think that i can do that with the 
      _GDIPlus functions
      but i couldn't find the currect way to do it
      i tried the _GDIPlus_GraphicsDrawString
      but i couldn't know how it work
      what i need is a small example that create a GUI
      and add a multy line text to it as graphic or image.
      so i need a simple way because it will changed every sec
      i hope any one can help me to do that
      global $GUI = GUICreate("text", 400, 400) global $label = GUICtrlCreateLabel(GetText(), 10, 10, 380, 380) GUISetState() do sleep(100) until GUIGetMSG() = -3 exit func GetText() return StringFormat("file name is test.mp3 \r\n total time is 00:30:00 \r\n position is 00:05:50") endFunc  
    • By zuladabef
      All my scripts were working fine and now I am getting this error.  How do I resolve it?  Which folder(s) do the DLLs need to be in?
      ! Dll not found or Call Dll error !  
    • By therks
      So I don't have any code cooked up yet as this is still in the theoretical stage. Just looking for some advice.
      My current idea is to resize the image to 1x1 pixel, probably using _GDIPlus_ImageResize, and read the color of the resulting pixel to obtain an admittedly very general sense of brightness. Does anyone think this could work?
      We have a CCTV system running at home using some home made cameras (raspberry pi) and we're trying to automate toggling settings for day/night time. We started with an AutoIt script that checked sunrise and sundown times for our location (calculations pulled from here) and toggled the settings based on that. Unfortunately our weather varies wildly, so it can get light/dark far outside normal sunrise/sundown times. Now we're hoping to periodically grab a still from the camera and toggle the light mode based on that.
×
×
  • Create New...