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
scythez0r
  • Members
  • 11 posts
  • Last active:
  • Joined: 09 Mar 2013

Right click can be done using the "k" option (for what "keystroke" to send when the image is found)

FindClick("image", "k{RButton}")

Since right click is the default option, you need only put k.

FindClick("image", "k")

In terms of mouse speed, do you mean that you want the mouse to travel at a certain speed to and from the image? If that's the case I actually had never considered needing that but it could be added to the script easily enough.

 

Oh my bad, didn't read the documentation well enough - blame it on my over tiredness tongue.png.

 

And yes that's exactly what I mean - basically like the speed parameter of MouseMove. Working on a small bot/macro for an online game atm and its generally safer if the mouse moves a little slower at a random speed to a position rather than instantly appearing and clicking at x,y from the whole screen away.

 

But anyway, excellent work man!



penguin114
  • Members
  • 8 posts
  • Last active: Aug 10 2013 11:00 AM
  • Joined: 12 Jan 2013

By crashes do you mean it shows the above error? If so then running the code from pastebin.com should put code in your clipboard and I'd like you to paste that here if you could.

 

If you don't mean the error dialog shown above, then what error are you talking about?

 

98:Add, Button, gFindClickClose xp y+10 w hp,&Help

 

that is what i got when i tried add option..



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

 

Working on a small bot/macro for an online game atm and its generally safer if the mouse moves a little slower at a random speed to a position rather than instantly appearing and clicking at x,y from the whole screen away.

 

 

I was going to add this to the function but it turned out to be far more complicated and annoying than I had predicted. So I added an alternate way to work around the issue. That is by using the "Func" option. What happens with this is instead of clicking, when an image is found FindClick will call the given function and pass it the x and y coordinates of the found image. See the documentation for more info.

 

Here's an example that could do what you want:

FindClick("image", "FuncClickWithRandomSpeed e")

;--------------------------------- Function included in your script ---------------------------------

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
}

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!


Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

brilliant! thanks for the addition.



Grendahl
  • Members
  • 416 posts
  • Last active: Jul 07 2014 08:01 PM
  • Joined: 10 Aug 2009
scythez0r

You might also want to search the forums for the mousemove_ellipse function. (people don't usually move their mice in straight lines)


Always have your scripts when you need them with Dropbox.
Sign up for free! http://db.tt/9Hrieqj

dzbanek
  • Members
  • 2 posts
  • Last active: Jan 02 2014 09:51 AM
  • Joined: 29 Apr 2013

So I dled script. Edited it and added one line to the top of it. FindClick("Images\Inventory.png")

It does work. 

However the script doesn't end. I can still see it next to my watch on taskbar.

What am I doing wrong?



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

So I dled script. Edited it and added one line to the top of it. FindClick("Images\Inventory.png")

It does work. 

However the script doesn't end. I can still see it next to my watch on taskbar.

What am I doing wrong?

 

Yeah I know about this, I think what is up is that AutoHotkey does NOT autoclose a script with GUI elements in it. And this function has gui elements in it - even though you did not use them in this case. (Someone correct me if that's not what is going on.)

 

Anyway, you're just going to have to manually put an ExitApp in your script.


FindClick("Images\Inventory.png")
ExitApp

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!


dzbanek
  • Members
  • 2 posts
  • Last active: Jan 02 2014 09:51 AM
  • Joined: 29 Apr 2013

I see, ty.



Scratch
  • Members
  • 108 posts
  • Last active: Mar 16 2014 08:02 PM
  • Joined: 22 Jan 2009

i really love this script, however I find that imagesearch in general can be unsatisfying slow if you want to track dozens of objects in near realtime (like in a game) even if you use small 10 * 10 snippets. I remember one of my scripts tracking the stack of a cardgame,, i used very small snippets but still it took anywhere between 1-4 seconds for a match, now imagine a fast arcade game or a first person shooter, thats way too much time.

What I wish we had was some kind of semi-parallel distributed computing solution that would broadly look something like this:

* Use VLC (example) as a streaming server, VLC has numerous commandline options that allow it to snoop for instance 20 custom sized/positioned rectangles of say 10*10 from your local screen/window,

* Have vlc combine them into a single rectangle stream of 200 * 100 and have vlc unicast it in realtime over you lan.

 

* you can have like 5 or more client computers with vlc that all receive the same stream in a client window.

* Have these computers do their findclick stuff on their own part of the matrix , for 20 object spread over 5 computers this works out as 4 objects to process per pc,
one pc will only search the top of the matrix, others the middle and finally one searching the bottom of the matrix,

* have the statistics/ results written in one INI file that is shared over the network and that can be accessed by your main autohotkey script on your local pc.

- an additional advantage of VLC is that you can use different transcoders, so that for instance you can remove shades of colour from your stream, or even transcode to monochrome, so that you can "dumb down" objects that have shade variation and make them process faster.

- at some point you would want to write an automatic load balancer/dispatcher to quickly assign an optimised load for extra computers you might add or remove. - now that you have offloaded the imagesearch from you main pc to other pc's you can also offload some of the objecthandling by have for instance have the dispatch pc pre-proces the statistics in the ini file, like you could have it look for succesfull/failed imagesearches in the matrix to uncover group patterns, like if objectx1y1 and objectx5y6 = 1 AND objectx1y1 = 0 OR etc....

Then the dispatcher would merely set some goto label semaphore flags in the shared INI file so that you local main script just has to read the goto labels and swiftly proceed its programflow without further processing



MasterFocus
  • Moderators
  • 4323 posts
  • Last active: Jan 28 2016 01:38 AM
  • Joined: 08 Apr 2009

...I find that imagesearch in general can be unsatisfying slow...

 

You may be interested in Gdip_ImageSearch() - http://www.autohotke...e-4#entry577911


-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio Fran├ža -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.


MaxTech
  • Members
  • 5 posts
  • Last active: May 11 2013 07:55 PM
  • Joined: 04 May 2013

hi i was wondering if the downloads will be available again, those cubby links are down

looks like FindClick is exactly what i need for the project im working on!

 



berban
  • Members
  • 202 posts
  • Last active: Apr 12 2019 01:08 AM
  • Joined: 30 Dec 2009
Sorry about that, my cubby has been acting up lately so I reinstalled it which of course means all my links are gone. I fixed the findclick links so you should be able to access it again. I also fixed the bug that many people had mentioned when you clicked "Add option..." - this should work as expected now.

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!


HockeyZ39
  • Members
  • 14 posts
  • Last active: Oct 25 2013 04:01 AM
  • Joined: 15 Dec 2012

First off, GREAT function. I had been using something I threw together a while back and this is a million times better. 

 

I am wondering if holding a click down for a specified amount of time can be done? I have read the keystroke option documentation but saw no specific reference to keydown time. 

 

TIA

 

EDIT: Specifically what I am trying to do is wait for an image to appear, when it does click and hold in the image center until another image appears. 

 

EDIT2: My apologies, I am blind and overlooked the function option. :)



foldr
  • Members
  • 1 posts
  • Last active: Jun 10 2013 03:45 AM
  • Joined: 10 Jun 2013

Registered just to thank you.

This function is awesome.



dimm0k
  • Members
  • 19 posts
  • Last active: Nov 26 2016 04:41 PM
  • Joined: 03 Apr 2013

Spoke with you briefly on freenode and wanted to offer some feedback on this little gem to make it a little more intuitive as you said.  Maybe some tooltips when you hover over the options by making the window for this gem maybe off limits to the scan of the pointer?  Nevertheless this thing is priceless!