Jump to content
Sign in to follow this  
Prateek

ImageSearch Library - Error while trying to search an image - (Moved)

Recommended Posts

Hi,

I am New to AutoIT, trying to accomplish a simple task where an image is required to be searched on a web page.

My Code - 

$rectHWND = WinGetHandle("[ACTIVE]")
$rectPos = WinGetPos($rectHWND) ;
$found = _ImageSearchArea("example.bmp", 1, $rectPos[0], $rectPos[1], $rectPos[2], $rectPos[3], $x, $y, 100)
msgbox(0,'','the line ' & ' is ' & $found)

If $found = 1 Then
    MouseMove($x,$y, 10)
EndIf

Capture.JPG

Share this post


Link to post
Share on other sites

Hi,

I have kept ImageSearch.au3 in "C:\Program Files (x86)\AutoIt3\Include"

And have kept ImageSearchDLL.dll in "C:\Windows\System32"

Also my code and example.bmp are in same folder.

My script is just 

$rectHWND = WinGetHandle("[ACTIVE]")
$rectPos = WinGetPos($rectHWND) ;
$found = _ImageSearchArea("example.bmp", 1, $rectPos[0], $rectPos[1], $rectPos[2], $rectPos[3], $x, $y, 100)

If $found = 1 Then
    MouseMove($x,$y, 10)
EndIf

 

Now where shall i put DllCall 

 

 

Share this post


Link to post
Share on other sites

Thanks, somehow it got deleted by only .....

I added it back there - 

If IsString($findImage) Then
    $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage,"ptr",$HBMP)
Else
    $result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"ptr",$findImage,"ptr",$HBMP)
EndIf

 

Now i am not getting any output - I just changed my code a bit - Kindly look into it - 

Func checkForImage()
Local $search = _ImageSearch('example.bmp', 0, $x, $y, 0)

If $search = 1 Then
MouseMove($x, $y, 10)
EndIf
EndFunc

 

Regards,

Share this post


Link to post
Share on other sites

This is just an internal web portal where reports are generated and are stored. Now there is this one excel icon coming on the top right of that website. There is no name or text , just an icon , looks like excel icon...I am attaching it as well. Now since there is no name, nothing, just this image and on clicking it report gets downloaded onto the system, so i am trying to automate this task...all other steps have been accomplished but i am not able to click this image....

 

My complete Code

#include <ImageSearch.au3>

WinActivate("Web Portal - IE Explorer - Citrix Platform")
WinWaitActive("Web Portal - IE Explorer - Citrix Platform")
HotKeySet("p", "checkForImage")

global $y = 0, $x = 0

Func checkForImage()
Local $search = _ImageSearch('example.bmp', 0, $x, $y, 0)

If $search = 1 Then
MouseMove($x, $y, 10)
EndIf
EndFunc

 

example.bmp

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


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Hi Melba,

Can you please help me here? Why is this not working?

#include <ImageSearch.au3>

WinActivate("Web Portal - IE Explorer - Citrix Platform")
WinWaitActive("Web Portal - IE Explorer - Citrix Platform")
HotKeySet("p", "checkForImage")

global $y = 0, $x = 0

Func checkForImage()
Local $search = _ImageSearch('example.bmp', 0, $x, $y, 0)

If $search = 1 Then
MouseMove($x, $y, 10)
EndIf
EndFunc

Share this post


Link to post
Share on other sites

1. Download ImageSearch LIB from here: 

 

2. Use this code

#include "_ImageSearch.au3"
#include "_ImageSearch_Debug.au3"

HotKeySet("{Esc}", "_Exit")
Func _Exit()
    Exit 0
EndFunc   ;==>_Exit

Global $_Image_1 = @ScriptDir & "\example.bmp"

;first, use this function to create a file bmp, maybe a desktop icon for example')
_ImageSearch_Create_BMP($_Image_1)

While 1
    Local $rectHWND = WinGetHandle("[ACTIVE]")
    Local $rectPos = WinGetPos($rectHWND)
    If @error Then ContinueLoop
    Local $found = _ImageSearch_Area($_Image_1, $rectPos[0], $rectPos[1], $rectPos[2], $rectPos[3], 100, 1)
    If $found[0] = 1 Then
        MsgBox(0, 'Success', 'Image found:' & " X=" & $found[1] & " Y=" & $found[2] & @CRLF & $_Image_1)
    Else
        ConsoleWrite('Image not found. Searching..' & @CRLF)
    EndIf
    Sleep(200)
WEnd

Goodlucky


Regards,
 

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.

×
×
  • Create New...