Jump to content

Recommended Posts

Posted

I dont speak english. Forgive me for any error in text.

I put the dll to work in 32 and 64 bits, but the dll returns wrong coordinates on Windows 10.  In some areas the image is not even found.

Ex: The image is in coord: 586,168 and the dll returns 443,56. On changes image position the precision varies.
Someone know a fix?

Thanks for your attention, greetings.

Posted

Post your code, there may be something wrong about the way you're using it.

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

Posted
15 hours ago, careca said:

Post your code, there may be something wrong about the way you're using it.

Thank you for you attention.

I find a solution for the problem in this topic.

Below the working script code with modifications for solve the problem. The @OSVersion don't returns WIN_10 in Windows 10, returns 9600. But at last the script is finding the image on screen with right coordinates. :)

#include <ImageSearch2015.au3>
AutoItSetOption("MouseCoordMode", 1)
#AutoIt3Wrapper_Res_HiDpi=Y
HotKeySet("p", "checkForImage")
HotKeySet("o", "showCoords")

If @OSVersion="WIN_10" Then
    DllCall("Shcore.dll","long","PROCESS_DPI_AWARENESS",1)
Else
    DllCall("User32.dll","bool","SetProcessDPIAware")
EndIf

Global $x = 0, $y = 0
ConsoleWrite(@OSBuild & @CR)
ConsoleWrite(@DesktopWidth & @CR & @DesktopHeight & @CR)

Func checkForImage()
    Local $search = _ImageSearch("tst.bmp", 1, $x, $y, 0)
    If $search = 1 Then
        ConsoleWrite($x & @CR & $y & @CR)
        MouseMove($x, $y, 0)
    EndIf
EndFunc   ;==>checkForImage

Func showCoords()
    $mousepos = MouseGetPos()
    ToolTip($mousepos[0] & "," & $mousepos[1])
    ConsoleWrite($mousepos[0] & @CR & $mousepos[1] & @CR)
EndFunc   ;==>showCoords

While 1
    Sleep(200)
WEnd

 

Posted

Glad it's solved. :)

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

  • 1 month later...
Posted

Win10 x64 Anniversary

Was working with this today, got the old original files working (Once I found the .dll files need to be in the same directory as my script, not the Include folder)

Tried the newer ImageSearch2015 version to see whats new/better and for some reason that one does not work for me at all.  No errors, spins a few times the cursor to let me know its thinking and just doesn't do anything.

 

Tried to move around the .dll files and like I had to do for the old version, no difference in effect. 

 

Anybody know exactly what is supposed to be different/better with the 2015 version (I guess it auto senses OS architecture so you do not have to manually install the proper .dll?) and what the issue may be for this system (I guess the Win10 anniversary is so new that the code was not written to work with it)

 

T

Posted
On 12/13/2016 at 9:07 AM, gillall said:

Thank you for you attention.

I find a solution for the problem in this topic.

Below the working script code with modifications for solve the problem. The @OSVersion don't returns WIN_10 in Windows 10, returns 9600. But at last the script is finding the image on screen with right coordinates. :)

#include <ImageSearch2015.au3>
AutoItSetOption("MouseCoordMode", 1)
#AutoIt3Wrapper_Res_HiDpi=Y
HotKeySet("p", "checkForImage")
HotKeySet("o", "showCoords")

If @OSVersion="WIN_10" Then
    DllCall("Shcore.dll","long","PROCESS_DPI_AWARENESS",1)
Else
    DllCall("User32.dll","bool","SetProcessDPIAware")
EndIf

Global $x = 0, $y = 0
ConsoleWrite(@OSBuild & @CR)
ConsoleWrite(@DesktopWidth & @CR & @DesktopHeight & @CR)

Func checkForImage()
    Local $search = _ImageSearch("tst.bmp", 1, $x, $y, 0)
    If $search = 1 Then
        ConsoleWrite($x & @CR & $y & @CR)
        MouseMove($x, $y, 0)
    EndIf
EndFunc   ;==>checkForImage

Func showCoords()
    $mousepos = MouseGetPos()
    ToolTip($mousepos[0] & "," & $mousepos[1])
    ConsoleWrite($mousepos[0] & @CR & $mousepos[1] & @CR)
EndFunc   ;==>showCoords

While 1
    Sleep(200)
WEnd

 

Hey I have the same problem on my new windows 10 surfacebook its a super high res display. I cant see to get my imagesearch to work, & I tried your code do you have any ideas on how to fix this?

Posted (edited)

So, exact same code, and the image with the correct name in script dir?

Did you try to debug? What does

@OSVersion

retrieve on your end? What is your autoit version?

How does this work for you?

#include <ImageSearch.au3>
Local $HBMP = 0
Local $x1 = 0, $y1 = 0
Local $right = @DesktopWidth
Local $bottom = @DesktopHeight
Local $findImage = @ScriptDir&'\Capture.PNG'
While 1
    $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage,"ptr",$HBMP)
    If $result[0]<>0 Then
        $array = StringSplit($result[0],"|")
        ConsoleWrite('XPos - '& $array[2] &' - YPos - '& $array[3] &' - XSize - '&$array[4]&' - YSize - '&$array[5]&@CRLF)
    EndIf
    Sleep(100)
WEnd

 

Edited by careca
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

Posted

Hi my script dont work 

#include <ImageSearch.au3>
#include <GDIPlus.au3>
$fileA = "C:\Users\benne\OneDrive\skrivbord\ImageSearch 32bit\gg.bmp"

_GDIPlus_Startup()

$hImageA = _GDIPlus_ImageLoadFromFile($fileA) ;this is the firefox icon use something else if you don't have it.
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)

$x = 0
$y = 0

$result = _ImageSearch($hBitmapA, 1, $x, $y, 20) ;Zero will search against your active screen
If $result > 0 Then
MouseMove($x, $y)
MsgBox (0, "Result", $Result)
EndIf
MsgBox (0, "Result", $Result)
_GDIPlus_ImageDispose($hImageA)
_GDIPlus_Shutdown()


>Exit code: 3221225477    Time: 1.492

whats wrong?

Posted
9 hours ago, careca said:

So, exact same code, and the image with the correct name in script dir?

Did you try to debug? What does

@OSVersion

retrieve on your end? What is your autoit version?

How does this work for you?

#include <ImageSearch.au3>
Local $HBMP = 0
Local $x1 = 0, $y1 = 0
Local $right = @DesktopWidth
Local $bottom = @DesktopHeight
Local $findImage = @ScriptDir&'\Capture.PNG'
While 1
    $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage,"ptr",$HBMP)
    If $result[0]<>0 Then
        $array = StringSplit($result[0],"|")
        ConsoleWrite('XPos - '& $array[2] &' - YPos - '& $array[3] &' - XSize - '&$array[4]&' - YSize - '&$array[5]&@CRLF)
    EndIf
    Sleep(100)
WEnd

im not 100% sure about this but bmp is the only format that works.

Posted

In fact, it's a png that comes in the zip as example... did you try it?

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

  • 3 weeks later...
Posted (edited)

So i tried imagesearch and it worked just fine.

I need it to press on the confirmation button in a game.

-snip-

Edited by Jos
  • Developers
Posted

@reber03,

Welcome to the AutoIt forum. :)

Unfortunately you appear to have missed the Forum rules on your way in. (there is also a link link in my signature) 
Please read them now particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. :naughty:

See you soon with a legitimate question I hope. :)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Opps, sorry for that mistake.

It's still possible to ask if there is a way to let the script detect different kind of colors and if someone can help with it. :)

  • 3 weeks later...
Posted
On 8/8/2015 at 0:01 PM, guestscripter said:

I just got it to work!

I was having much trouble, reading all the threads and posts related to ImageSearch, and I'd like to help others now.

Now got it to work as a x64 and also as a x32 script using both DLLs accordingly (on a Windows 8.1 x64 PC)

One of the steps I took in debugging was putting this into (the top of) my script:

$sOSArch = @OSArch ;Check if running on x64 or x32 Windows ;@OSArch Returns one of the following: "X86", "IA64", "X64" - this is the architecture type of the currently running operating system.
ConsoleWrite("$sOSArch=" & $sOSArch & @CR)
$sAutoItX64 = @AutoItX64 ;Check if using x64 AutoIt ;@AutoItX64 Returns 1 if the script is running under the native x64 version of AutoIt.
ConsoleWrite("$sAutoItX64=" & $sAutoItX64 & @CR)

In any case you want to be consistent about 32bit or 64bit usage, and use the right DLL etc.

What also really helped was putting in lots of debugging and error handling to zoom in on whatever specific part isn't working and why.

Credits to Centrally (very helpful usage explanation and re-uploading the files) and kangkeng for making this possible in AutoIt, as well Miguel7 from the AutoHotKey forum who also posted some helpful advice.

I've attached a zipped folder containing all of the needed Dlls and my customised Library, which also contains an example and some debugging: ImageSearch2015.zip

55c5a345e8d04.png

Take a look inside ImageSearch2015.au3 here if you like:

Hidden Content

Edit: also uploaded "ImageSearch15.au3", a version of "my" ImageSearch Library without the built-in Example and Debugging
(will require the Dlls in the .zip file though): ImageSearch15.au3

Hidden Content

I hope this helps somebody! Let me know any feedback/issues.

Hi,

Thanks for sharing the above info.

I m trying this same image search bt the script is properly working on large images, but for small images (e.g. searching a word (as an image) on screen) its not working.

Please suggest. Waiting for ur reply.

Posted

It should work anyway. The example i posted was tested with a small image and worked, maybe the word you are searching has a bit of zoom or something?

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

  • 1 month later...
Posted

Hello everybody, i'm going to use this library because it seems to do what i'm looking for. Thanks for the upload, older thread haven't got downloadable archives.

I have only few questions:

  1. Is there a built in implementation of PixelCoordMode  to avoid to write an interface for relative coordinates?
  2. Is there a way to implement non-rectangular images? [Or is there a way to implement different $tolerance for each pixel, for example using alpha channel?]
  3. Do you have some software to suggest to build images and read coordinates?

Thanks

 

  • 2 weeks later...
Posted

Is the transparency working for anyone?

I'm using the Imagesearch2015 of  guestscripter .

 

;                   $transparency - TRANSBLACK, TRANSWHITE or hex value (e.g. 0xffffff) of
;                                  the color to be used as transparency; can be omitted if
;                                  not needed

The imagesearch without transparency works perfect. But using the transparency like instructed above is just strange. Example:

_ImageSearch("icon.bmp", 0, $x, $y, 0, 0xffffff) ; This will always return True with $x = 0, $y = 0
; icon.bmp is a green + sign with white background.
; It also doesn't matter if there is white in the image or not or if the copy of the image is displayed. It will always return True,0,0
; If I perform the search on a limited area with _ImageSearchArea it will return True and x, y the top, left corner coordinates.

; when icon.bmp is a green + sign with BLACK background,
; using 0x000000 will always return False (unless you could find the image without transparency because its the exact same)

; Using TRANSBLACK / TRANSWHITE will also always return false

So either I don't understand something or something doesn't work.

Since this is ported from AutoHotkey, I decided to try it out the original and that works with the same images.

If someone with more knowledge could tell how to troubleshoot this. That would be great.

  • 1 month later...
Posted
On 5/6/2017 at 8:55 AM, bootybay said:

Is the transparency working for anyone?

I'm using the Imagesearch2015 of  guestscripter .

 

;                   $transparency - TRANSBLACK, TRANSWHITE or hex value (e.g. 0xffffff) of
;                                  the color to be used as transparency; can be omitted if
;                                  not needed

The imagesearch without transparency works perfect. But using the transparency like instructed above is just strange. Example:

_ImageSearch("icon.bmp", 0, $x, $y, 0, 0xffffff) ; This will always return True with $x = 0, $y = 0
; icon.bmp is a green + sign with white background.
; It also doesn't matter if there is white in the image or not or if the copy of the image is displayed. It will always return True,0,0
; If I perform the search on a limited area with _ImageSearchArea it will return True and x, y the top, left corner coordinates.

; when icon.bmp is a green + sign with BLACK background,
; using 0x000000 will always return False (unless you could find the image without transparency because its the exact same)

; Using TRANSBLACK / TRANSWHITE will also always return false

So either I don't understand something or something doesn't work.

Since this is ported from AutoHotkey, I decided to try it out the original and that works with the same images.

If someone with more knowledge could tell how to troubleshoot this. That would be great.

I'm facing the same problem right now. It's been 22 days since you bumped into the problem, have you solved it?

I hope its not, but i think its broken. ._.

Posted

Try a 32bit color and it'll work.

;for a white background
;working 
_ImageSearch("icon.bmp", 0, $x, $y, 0, 0xffffff00) 
;or
_ImageSearch("icon.bmp", 0, $x, $y, 0, 0xffffffff) 
;or
_ImageSearch("icon.bmp", 0, $x, $y, 0, 0xffffffab)
;failing:
_ImageSearch("icon.bmp", 0, $x, $y, 0, 0xffffff)

 

 

Then there's still a bug in the code, you cannot use black as its color value is zero, and only non-zero is accepted as transparent:

If $transparency <> 0 Then $findImage = "*" & $transparency & " " & $findImage

I think you'd have to change at least these two lines:

Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance = 0, $transparency = 'not used');Credits to Sven for the Transparency addition
If IsNumber($transparency) Then $findImage = "*" & $transparency & " " & $findImage

Don't blame me if this code change doesn't work as intended, but you cannot test against any number as 0xffffffff is equal -1 and so I added a string instead. I didn't try that code nor did I check any other code lines that might break.

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
×
×
  • Create New...