Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

FindClick() 2nd Edition


  • Please log in to reply
66 replies to this topic
hunts02
  • Members
  • 5 posts
  • Last active: Sep 03 2013 12:27 AM
  • Joined: 20 Aug 2013

Hello,

 

I have tried your script and was wondering whenever I use the test mode, it finds multiple instance of the image fine but  when it does this... should the mouse pointer also move with the location of the highlighted box? It does not move whenever I test the script. It just detects all the instances of the image and the log says it clicked it but it does not. I am using latest version of autohotkey_l 



berban
  • Members
  • 202 posts
  • Last active: Apr 12 2019 01:08 AM
  • Joined: 30 Dec 2009

Hello,
 
I have tried your script and was wondering whenever I use the test mode, it finds multiple instance of the image fine but  when it does this... should the mouse pointer also move with the location of the highlighted box? It does not move whenever I test the script. It just detects all the instances of the image and the log says it clicked it but it does not. I am using latest version of autohotkey_l


Hey hunts02

Just to be clear, it does all the clicking first, then shows the debugger GUI after the script has wrapped up. When you are reviewing the script's actions, it does not do any clicking then, it only reports WHERE it clicked from before.

Does that help?

Find me on the new AutoHotkey forums and send me a message if you have a question about any of the scrips I've posted to this forum!


hunts02
  • Members
  • 5 posts
  • Last active: Sep 03 2013 12:27 AM
  • Joined: 20 Aug 2013

Hey hunts02

Just to be clear, it does all the clicking first, then shows the debugger GUI after the script has wrapped up. When you are reviewing the script's actions, it does not do any clicking then, it only reports WHERE it clicked from before.

Does that help?

Ah I see. Should I see the mouse cursor move or its sending click commands without actually moving the mouse cursor? If it does not move the actual cursor to the position of the image, how can I make the cursor move to the image and click it? Also the image im targetting is slightly moving up and down like bouncing. Its not fast and not wide enough so I think it should click the middle area somewhat but still it does not. Thanks for the reply btw.



hunts02
  • Members
  • 5 posts
  • Last active: Sep 03 2013 12:27 AM
  • Joined: 20 Aug 2013

Hello,

 

I managed to make it work (it was too fast and no "stay option" so I did not see. It does track the image that I want though but it does not left click the mouse button when i run my script.

 

FindClick("C:\Program Files\AutoHotkey\Graphics\NewFile.png", "e sleep300 mp")

 

i am trying to use this on bluestack but I can't seem to make it click or maybe it was too fast? I have tried it with different sendmode but it seems to be not working for some reason.

 

Edit:

 

Weird, when I added the random speed function, It worked for me.

 

loop {

FindClick("C:\Program Files\AutoHotkey\Graphics\NewFile.png", "FuncClickWithRandomSpeed e o10 center1 stay1")

ClickWithRandomSpeed(x, y)
{
    LowerBound = 2
    UpperBound = 10
    Random, Speed, LowerBound, UpperBound
    SendMode, Event ; Sendmode must be "Event" or else its instantaneous
    SetMouseDelay, 10 ; MouseDelay must not be 0 or else its instantaneous
    MouseMove, x, y, Speed
    Click
    Return
}
sleep 1000

}
Esc::ExitApp


Edited by hunts02, 23 August 2013 - 03:52 PM.


safmy
  • Members
  • 7 posts
  • Last active: Jul 08 2015 03:52 PM
  • Joined: 03 Feb 2013

Hi Berban,

 

I tried your findclick back when it was v1. I've put this into practice in many useful ways. Just want to say thank you for the function, absolute gem in my books.

 

A suggestion I have for a 5th parameter would be to add  the ability to run normal autohotkey functions like "send", "msgbox" or "mousemove". What I have to do to just hover the mouse over is to add an extra line at the end to mousemove to the coordinate output as "n0 stay1" does not achieve this.

 

Again thanks for this awesome function.

 

 

Best regards,

Syed

 

edit: Just realised how much more complicated that would make it. Which means the function is perfect.



Armagedoom
  • Members
  • 20 posts
  • Last active: Feb 18 2018 08:54 AM
  • Joined: 25 Dec 2012

I wanted to thank you for this library, its amazing, and saved me a lot of work.

I had to edit it in order to get the full position of the snapshot, and I think that should be a default.

Sometimes the user needs the full frame coordinates, not just the center or the corner.

I changed this:

 

line 671 from:
    
%Func%(FoundX, FoundY)
 
To:
    
%Func%(FoundX, FoundY,ImageW,ImageH)
 
This way it returns both W and H when a function is used,although I suspect you would probably do this in a better way hehe.
 
Regards,thanks again!


Siry777
  • Members
  • 1 posts
  • Last active: Apr 06 2014 11:13 AM
  • Joined: 02 Apr 2014

delete



Jammo2k5
  • Members
  • 4 posts
  • Last active: Apr 14 2014 03:31 PM
  • Joined: 05 Apr 2014

Thanks for this library it is amazing. I have used it for many things.

 

2 Questions however, Is there a way to pass extra arguments to the function? and is there a way to use varibales for the names of the images it is searching for?

 

I have tried many things to get this to work but i am at a loss. Thanks.



berban
  • Members
  • 202 posts
  • Last active: Apr 12 2019 01:08 AM
  • Joined: 30 Dec 2009
Hey Jammo2k5, I'm not exactly sure what you mean. I guess you mean something different than this?
var = C:\image.png
FindClick(var)

Find me on the new AutoHotkey forums and send me a message if you have a question about any of the scrips I've posted to this forum!


Jammo2k5
  • Members
  • 4 posts
  • Last active: Apr 14 2014 03:31 PM
  • Joined: 05 Apr 2014

Hey Jammo2k5, I'm not exactly sure what you mean. I guess you mean something different than this?

var = C:\image.png
FindClick(var)

When adding arguments to the function e.g.

 

FindClick("cure.png","!a w300 a%moux%,%mouy%,100,100 funccureplant")

 

it wont accent the variable in the function.

 

and when i try it with your suggestion i cant get it to work.

 

I am trying to get it to find the image at the mouse position with variables coming into the function the findclick is contained in through arguments.



Jammo2k5
  • Members
  • 4 posts
  • Last active: Apr 14 2014 03:31 PM
  • Joined: 05 Apr 2014

Hey Jammo2k5, I'm not exactly sure what you mean. I guess you mean something different than this?

var = C:\image.png
FindClick(var)

When adding arguments to the function e.g.

 

FindClick("cure.png","!a w300 a%moux%,%mouy%,100,100 funccureplant")

 

it wont accent the variable in the function.

 

and when i try it with your suggestion i cant get it to work.

 

I am trying to get it to find the image at the mouse position with variables coming into the function the findclick is contained in through arguments.

 

EDIT: I figured it out it was just me being simple. Thanks.

 

I used

 

curevar = !a w500 a%moux%,%mouy%,150,100 funcclick1

FindClick("cure.png",curevar)



Jammo2k5
  • Members
  • 4 posts
  • Last active: Apr 14 2014 03:31 PM
  • Joined: 05 Apr 2014

So i have been looking through the function and it seems it would be simple to add extra arguments to the func command.

 

e.g.

funcNameOfFunc,addedArgument0,addedArgument1

Line 670 reads

Else If (Func <> "")
%Func%(FoundX, FoundY)

If it were to say read

Else If (Func <> "")
%Func%(FoundX, FoundY,%addedArgs%)

And there was some code to take everything after the 1st comma of "funcnameoffunc,addedArgument0,addedArgument1" and assign %addedArgs% to that value.

I have been using intermediary functions to assign extra arguments to functions but it seems cluttered and just long winded.

 

Would this be possible?



berban
  • Members
  • 202 posts
  • Last active: Apr 12 2019 01:08 AM
  • Joined: 30 Dec 2009
Hey Jammo2k5

Unfortunately I would recommend continuing to do it the way you've been doing it, with an intermediary function. The function callout feature is supposed to be a pretty niche feature and the only times I've ever used it was when I needed to create a specific function for a specific purpose. I've never needed to use the same function with it several times.

Two more thoughts about your code:

1) This FindClick("cure.png","!a w300 a%moux%,%mouy%,100,100 funccureplant") can be done with "expression notation" in AutoHotkey: FindClick("cure.png","!a w300 a" moux "," mouy ",100,100 funccureplant")

2) There is actually a built-in feature of FindClick to search around the mouse: FindClick("cure.png", "aM150") ; searches in a square region 150 pixels around the mouse. M = mouse.

Find me on the new AutoHotkey forums and send me a message if you have a question about any of the scrips I've posted to this forum!


jdriele
  • Members
  • 10 posts
  • Last active: Feb 20 2015 12:09 PM
  • Joined: 26 Oct 2012

FindClick is marvellous.

 

I use it to create an automation tool for SAP.

Screenshot Builder is fantasctic in order to add new image to the script image gallery, but resolution is "ugly" or do something strange

 

Here a sample :

http://hpics.li/60b4b61  -> from snagit

http://hpics.li/75b13ed  -> from Screenshot Builder

 

Please help ^^



berban
  • Members
  • 202 posts
  • Last active: Apr 12 2019 01:08 AM
  • Joined: 30 Dec 2009

Here a sample :
http://hpics.li/60b4b61  -> from snagit
http://hpics.li/75b13ed  -> from Screenshot Builder

Please help ^^


Huh! I have never seen anything like this.

In a few (very rare) cases the screenshot builder will not recognize a window, but in this case it will show black or the contents of the window behind that window. Usually this happens if the window employs transparency. If this is the case it also means that ImageSearch won't work for that particular graphical element.

But in this case... where FindClick can clearly see the element, but doesn't display correctly... I don't know!

Do you think there is a possibility that there's a transparent window on top of the other window which is creating the distortion? Note that if this is the case, then the FindClick image will work for ImageSearch, and the other image will not.

Find me on the new AutoHotkey forums and send me a message if you have a question about any of the scrips I've posted to this forum!