Jump to content

Image Search


PanStefan
 Share

Recommended Posts

Hello,

last time my topic was closed, so I decide to do something diffrent.

I want my script to find the photograph and moved the mouse incessantly into places which I want, all the way to the moment of finding other photograph which would finish the loop.

At this moment I have only this, but it isn't work as I want, so can you help me with that?

#RequireAdmin
#include <ImageSearch.au3>
Global $y, $x
$stop = _ImageSearch(@ScriptDir & "\dll.bmp", 1, $x, $y, 255)
HotKeySet("{p}", "checkForImage")

While 1
   Sleep(10)
WEnd

Func checkForImage()
   Do
 Sleep(10)
      $search = _ImageSearch(@ScriptDir & "\checkImage.bmp", 1, $x, $y, 255)
      If $search = 1 Then
         ContinueLoop
      Else
         MouseMove(0, 0)
         Sleep(1000)
         MouseMove(69, 69)
         Return $search
      EndIf
   Until _ImageSearch(@ScriptDir & "\dll.bmp", 1, $x, $y, 255)
EndFunc

 

Link to comment
Share on other sites

I guess you didn't read. :o

"I want my script to find the photograph and moved the mouse incessantly into places which I want, all the way to the moment of finding other photograph which would finish the loop."

I will say, "places which I want" is not somewhere we know. Also, not sure if I understand "all the way to the moment of finding other photograph which would finish the loop". Any chance you can be more descriptive?

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Don't be mad, guys, I'm from Poland and I am making linguistic mistakes :o

I'll try ofc. :D

I would like to he finds the image and move mouse to points (0, 0 ; 69, 69) until he find another image.

 

We are definitely not mad :) just explaining that's all.

Completely understand language barrier. For one, the return statement in the

Do...Until

loop will take it out of the function all together. Also, you continue the loop when _ImageSearch returns a 1, which means it is successful. You need to change the conditional to

If $search = 0 Then

That should get you started. Also, set $x and $y to 0 before you use them.

Even then, I don't know if using the

Do...Until

loop is your best bet. Your trying to find out if the image is found on the desktop and when you find it you should go to the next one, not stop the loop and run _ImageSearch().

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

I will write an example. Are the only two images you are trying to _imageSearch() dll.bmp & checkImage.bmp?

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Then why put this line in

_ImageSearch(@ScriptDir & "\dll.bmp", 1, $x, $y, 255)

?

Here is an example. Give this a try..

#RequireAdmin
#include <ImageSearch.au3>
Global $y = 0, $x = 0
HotKeySet("{p}", "checkForImage")

While 1
    Sleep(10)
WEnd


Func checkForImage()
    $search = _ImageSearch(@ScriptDir & "\checkImage.bmp", 1, $x, $y, 255)
    If $search <> 0 Then
        Sleep(250)
        MouseMove(69, 69)
    Else
        MsgBox(0, "error", "Did not find anything")
    EndIf
EndFunc   ;==>checkForImage

I'm hoping one of the gurus will chime in, as my knowledge of _ImageSearch() is small.

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Mouse is going to that point even if that image isn't find.

 

 

Then why put this line in

_ImageSearch(@ScriptDir & "dll.bmp", 1, $x, $y, 255)

?

 

Cuz I want to stop finding and moving mouse to point image named checkImage.bmp when image dll.bmp will be find

Edited by Pan69Stefan
Link to comment
Share on other sites

change

If $search <> 0 Then

to

If $search = 1 Then

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Is checkImage.bmp in the same directory as your script?

Put

MsgBox(0, "", $search) ; put this after $search = _ImageSearch()...

Post what the MsgBox shows for $search.

We have the conditional right, that 1 = success.

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Yup.

Msg says 1.

But it's still one question I want to ask.

ImageSearch is searching Image ONLY on desktop? What if I'll cover that image? Will mouse go to point anyway?

Yes, if the image is being covered your script will return the value of "0" aka not found. If you have multiple monitors then it will only search your main / primary. 

Link to comment
Share on other sites

parameters of _ImageSearch():

($findImage,$resultPosition,ByRef $x, ByRef $y,$tolerance, $HBMP=0)
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...