FindClick() - ImageSearch, Clicking, & More [Newest Version]

Post your working scripts, libraries and tools
User avatar
rommmcek
Posts: 1106
Joined: 15 Aug 2014, 15:18

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

18 May 2020, 03:38

@reverberation : Did you try to use FindText. I'm using it successfully with Google Maps where sampling is much more obvious, visible by the naked eye!
Edit: It's working even with non DPI aware apps not having "High DPI scaling override" checked in the Compatibility tab of the Property dialog. (recognizable by the blur appearance).
reverberation
Posts: 306
Joined: 13 Dec 2015, 20:48

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

20 May 2020, 21:10

I just tried using FindText but to no avail. Have posted for help in the other thread!
burque505
Posts: 1377
Joined: 22 Jan 2017, 19:37

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

21 May 2020, 09:03

@reverberation, I am able to click on the reminder button and display the calendar dropdown as shown. I am on Win7 64-bit SP1, 125% scaling. The Reminder button is always shown per customization.

Code: Select all

; Run Title Search Evernote using Ctrl+Win+3
#Include FindClick.ahk
CoordMode, Mouse
^#3::
IfWinExist ahk_class ENMainFrame
	WinActivate
else
	Run C:\Program Files (x86)\Evernote\Evernote.exe
	Sleep 1000
SendInput {f9}
SendInput ^!f
Sleep 100
SendInput {tab}{home} ;scroll to top of notes
Sleep 1000

FindClick("reminder.png")

sleep 50

FindClick("change_date.png")

Esc::ExitApp
Images:
reminder.png
reminder.png (602 Bytes) Viewed 410 times
change_date.PNG
change_date.PNG (554 Bytes) Viewed 410 times
With your high-resolution screen perhaps this won't help per se, but along with the advice of others above maybe it can be of some use.
Regards,
burque505
reverberation
Posts: 306
Joined: 13 Dec 2015, 20:48

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

22 Sep 2020, 22:41

Hi guys,

How do I make FindClick() work reliably with small icons (maybe taking up only 1% of entire screen)?

See example here. It only activates 20% of the time when I use FindClick:

https://i.imgur.com/ckx7o1q.png
User avatar
rommmcek
Posts: 1106
Joined: 15 Aug 2014, 15:18

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

27 Sep 2020, 14:12

Why don't you start simple?
I downloaded your icon and saved it as reverbIco.png. Opened the file with Paint and ran the script:

Code: Select all

;URLDownloadToFile, https://i.imgur.com/ckx7o1q.png, reverbIco.png
;Return
#Include <Gdip_All>
imagefile:= "reverbIco.png" ; https://autohotkey.com/board/topic/55305-read-the-image-size-solved/

GDIPToken := Gdip_Startup()                                     
pBM := Gdip_CreateBitmapFromFile( imagefile )                 
W:= Gdip_GetImageWidth( pBM )
H:= Gdip_GetImageHeight( pBM )   
Gdip_DisposeImage( pBM )                                          
Gdip_Shutdown( GDIPToken )                                        
;MsgBox, width=%W%  height=%H%
;ExitApp
CoordMode, Pixel, Screen
WinActivate reverbIco
WinWaitActive reverbIco
Send {F11}
sleep 500
ImageSearch x, y, 0, 0, A_ScreenWidth, A_ScreenHeight, % imageFile
MouseMove x+w//2, y+h//2
and it works perfectly (both Ahk script and icon file are in the same folder)!
Edit: Hit the image in the center and at full screen (pic must be opened in Paint before running the script).
Last edited by rommmcek on 28 Sep 2020, 06:40, edited 2 times in total.
JenJen
Posts: 4
Joined: 21 Sep 2018, 16:50

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

27 Sep 2020, 16:38

Howcome returning X & Y coordinates from a successful image search places X coordinate in horizontal center, and Y coordinate vertical start (top)?

How would one go about getting the exact center of an image, instead of the X centered, and the Y top?

Another thing I can't wrap my head around either; I can do a windowed mode search for image comparison - and it finds it no problem. I put on fullscreen, it stops working. Even if I search the entire screen to make sure it's not coordinate/area search issue.

I don't know how to fix that.

Ty

Edit:
After quitting on it twice, and going back to it - I ended up fixing the fullscreen thing. I'm not sure why, it makes no sense and isn't logical - but the PNG with transparent background I was using worked on 'windowed mode' but not fullscreen. I tried (for science..) changing transparent to pure black - and it magically worked in fullscreen.

I feel like a lot of these image detect things are more trial and error than logic.
User avatar
rommmcek
Posts: 1106
Joined: 15 Aug 2014, 15:18

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

28 Sep 2020, 06:56

JenJen wrote:
27 Sep 2020, 16:38
How would one go about getting the exact center of an image, instead of the X centered, and the Y top?
For that you need pic's dimensions. Try script above (edited).
JenJen wrote:
27 Sep 2020, 16:38
I feel like a lot of these image detect things are more trial and error than logic.
I couldn't reproduce your issue (see above link). Such things are often user's coding bugs or even OS bugs/limitations. For latter AutoHotkey can't do much about it.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: leehere10, Pulover, SirSocks, tidbit and 22 guests