@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).
FindClick() - ImageSearch, Clicking, & More [Newest Version]
-
- Posts: 314
- Joined: 13 Dec 2015, 20:48
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
I just tried using FindText but to no avail. Have posted for help in the other thread!
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
@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.
Images:
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
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
Regards,
burque505
-
- Posts: 314
- Joined: 13 Dec 2015, 20:48
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
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
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
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
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: 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).
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
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.
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
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.
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.
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
For that you need pic's dimensions. Try script above (edited).
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.
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
I'm trying to run a FindClick to find all on the screen, and then calling a function that calls another FindClick based on the first one to check a smaller region but the 2nd one seems to be causing the first one to stop.
If i remove the 2nd FindClick, i find say 9 on the screen and it clicks each, but if if i use the 2nd FindClick, it stops after the first.
I searched and haven't found anything, so am sorry if this is a known issue.
Any suggestions would be appreciated, thanx.
Jeff
If i remove the 2nd FindClick, i find say 9 on the screen and it clicks each, but if if i use the 2nd FindClick, it stops after the first.
I searched and haven't found anything, so am sorry if this is a known issue.
Code: Select all
FindClick("5star.png", "r a250,0,-300, e o90 y+15 funcupgrade dx ")
upgrade(x,y){
Result := FindClick("plus.png", "am27 n0 o30 dx")
if %Result%
return
Click %x%,%y%
CoordMode Mouse,Window
sleep 500
Click 930,266
sleep, 500
click 823,301
sleep 19000
}
return
Jeff
-
- Posts: 60
- Joined: 12 Sep 2019, 21:15
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
I downloaded the script but can't seem to figure out how to get the screenshot creator to popup. I've used a similar function to this called Findtext and that works fine. Not too sure what I'm doing wrong here and the documentation doesn't mention how to get the screenshot creator to popup either.
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
Had forgotten about this.... But as a followup, creating a 2nd copy of the library and replacing all occurences of FindClick with FindClick2 and calling them individually works fine. So seems to be issue with variables state squashing each other.
Chaos, i've never used the creator, always just took a screenshot or a clip of screen and used that.
Chaos, i've never used the creator, always just took a screenshot or a clip of screen and used that.
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
@chaoscreater - The section of the documentation called "Image Creator" describes how to call up the Image Creator GUI:
So you just need to have a script that includes the FindClick() function, and call the function with no parameters:Explicitly calling the image creator
If FindClick is called with a blank image file, then the GUI will appear with the default settings.
FindClick() ; Summon the image creator GUI
Code: Select all
#Include FindClick.ahk ; add the path to the file
FindClick() ; Summon the image creator GUI
- milkygirl90
- Posts: 565
- Joined: 10 Nov 2020, 21:22
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
Hi there,
I have 2 issues:
1. If screen resolution is different on every desktop and I want to make it cross-compatible, how will you suggest doing so? I only have 2 resolutions for now - 2560x1440 & 1920x1080. Trying to avoid creating 2 separate screenshots for imagesearch.
2. I have a translucent overlay auto-activated at night with different intensity levels and this affects the imagesearch. Is there any way for Findclick to work without disabling my script?
I have 2 issues:
1. If screen resolution is different on every desktop and I want to make it cross-compatible, how will you suggest doing so? I only have 2 resolutions for now - 2560x1440 & 1920x1080. Trying to avoid creating 2 separate screenshots for imagesearch.
2. I have a translucent overlay auto-activated at night with different intensity levels and this affects the imagesearch. Is there any way for Findclick to work without disabling my script?
Code: Select all
#NoEnv
#NoTrayIcon
Gui,+ToolWindow
#SingleInstance, Force
SetBatchLines, -1
FormatTime, CurrentHour,, h
FormatTime, CurrentAMPM,, tt ; Get the relevant time set
FormatTime, CurrentMinute,, m
If (CurrentHour >= 1 && CurrentHour <= 7 && CurrentAMPM == "AM") ; If the time is 1 AM - 7 AM [MORNING]
{
Intensity := 90 ; Dim intensity 90
}
Else If (CurrentHour >= 7 && CurrentHour <=11 && CurrentAMPM == "PM") ; If the time is 7 PM - 11 PM [Evening]
{
Intensity := 50
}
else
Intensity := 0 ; Set intesity to nothing if the time frame is anything different
Gui, 1: Default
Gui, Color, 0x000000 ; Color to black
Gui, +LastFound +AlwaysOnTop -Caption +E0x20 ; Click through GUI always on top.
WinSet, Transparent, %Intensity% ; Set intensity first based on the time of dday
Gui, Show, x0 y0 w%A_ScreenWidth% h%A_ScreenHeight% ; Cover entire screen
return
EnDisCusLum: ; Turn on off custom brightness
Gui, 1: Default
If (OnOffToggle = 1)
Gui, Show
else
Gui, Hide
return
AutoHideCheck: ; Turn on or off the autohide for GUI 2
Gui, 2: Submit, Nohide
If (AutoHideCheck = 1) ; Checked
GUI_AutoHide("U", 2, 1000)
else
GUI_AutoHide("U", 2, 1000, 5, 0)
return
AdjustLum:
Gui, 1: Default
Gui, +LastFound
WinSet, Transparent, %Intensity%
return
~LButton & WheelUp:: ; Turn up the brightness by dimming the GUI
If Intensity = 0 ; Return if intensity is nothing
return
Intensity-=10
Gui, +LastFound
WinSet, Transparent, %Intensity%
return
~LButton & WheelDown:: ; Turn down the brightness by making the GUI more visible
If Intensity > 200 ; Return if intensity is greater than 200, since we don't want the screen to go black
return
Intensity+=10
Gui, +LastFound
WinSet, Transparent, %Intensity%
return
#Esc:: ; Shut down window
ExitApp
GUI_AutoHide(Hide_Direction, Gui_Num_To_Hide_Clone=1, Delay_Before_Hide=3000, Number_Of_Offset_Pixels=5, Enabled_Disabled_Flag=1) ; Autohide the GUI function
{
global ; Assume global
Gui_Num_To_Hide := Gui_Num_To_Hide_Clone
Gui, %Gui_Num_To_Hide%: +LastFound ; Set GUI settings so we can obtain it's settings and give it an alwaysontop attribute to make the user be able to unhide it
; ** OBTAIN AND SET VARIABLES **
StringUpper, Hide_Direction, Hide_Direction ; Capitalize it just in case the user didn't for the label
If ( Enabled_Disabled_Flag = 0 )
{
%Gui_Num_To_Hide%_Enabled_Disabled_Flag := 0
WinMove, % %Gui_Num_To_Hide%_Gui_Title,, % %Gui_Num_To_Hide%_GUIX, % %Gui_Num_To_Hide%_GUIY
return
}
WinGetPos, %Gui_Num_To_Hide%_GUIX, %Gui_Num_To_Hide%_GUIY, %Gui_Num_To_Hide%_GUIW, %Gui_Num_To_Hide%_GUIH, A
WinGetTitle, %Gui_Num_To_Hide%_Gui_Title, A
%Gui_Num_To_Hide%_TimeLapse := A_TickCount ; Set the specified variables with respect to which GUI the settings go to
%Gui_Num_To_Hide%_Enabled_Disabled_Flag := Enabled_Disabled_Flag
%Gui_Num_To_Hide%_Number_Of_Offset_Pixels := Number_Of_Offset_Pixels
%Gui_Num_To_Hide%_Delay_Before_Hide := Delay_Before_Hide
%Gui_Num_To_Hide%_Hide_Direction := Hide_Direction
;MsgBox % %Gui_Num_To_Hide%_Gui_Title
; ** Place message for GUI **
OnMessage(0x200,"WM_MOUSEMOVE") ; Message to send when the mouse is over the GUI
SetTimer, HideGUI%Hide_Direction%, 500 ; Set timer to hide the GUI in whatever direction you chose
return
; ** HideGUI Settings **
HideGUIU:
;~ ;MsgBox % "If (" A_TickCount - %Gui_Num_To_Hide%_TimeLapse " < " %Gui_Num_To_Hide%_Delay_Before_Hide ") "
If (%Gui_Num_To_Hide%_Enabled_Disabled_Flag != 1)
return
If (A_TickCount - %Gui_Num_To_Hide%_TimeLapse < %Gui_Num_To_Hide%_Delay_Before_Hide) ; If the mouse was over the GUI within the last 3 seconds, don't hide it
return
WinGetPos, GUIX, GUIY,,, % %Gui_Num_To_Hide%_Gui_Title ; Get the position of the GUI
Loop
{
; MsgBox % "If (" %Gui_Num_To_Hide%_GUIY+%Gui_Num_To_Hide%_GUIH " > " %Gui_Num_To_Hide%_Number_Of_Offset_Pixels ")"
If (GUIY + %Gui_Num_To_Hide%_GUIH > %Gui_Num_To_Hide%_Number_Of_Offset_Pixels) ; If the GUI is not hidden hide it then break
{
;~ ;MsgBox % "WinMove," %Gui_Num_To_Hide%_Gui_Title ",, " GUIX ", " GUIY-(A_Index)
WinMove, % %Gui_Num_To_Hide%_Gui_Title,, %GUIX%, % GUIY-(A_Index)
WinGetPos, GUIX, GUIY,,, % %Gui_Num_To_Hide%_Gui_Title
;MsgBox % "WinGetPos, " GUIX ", " GUIY ",,, " %Gui_Num_To_Hide%_Gui_Title
}
else
break
}
If ((GUIY + %Gui_Num_To_Hide%_GUIH) < (%Gui_Num_To_Hide%_Number_Of_Offset_Pixels-1)) ; Failsafe if the GUI moves too far
{
WinMove, % %Gui_Num_To_Hide%_Gui_Title,, %GUIX%, % (-%Gui_Num_To_Hide%_GUIH+%Gui_Num_To_Hide%_Number_Of_Offset_Pixels)
}
SetTimer, HideGUIU, OFF
return
HideGUID:
;~ ;MsgBox % "If (" A_TickCount - %Gui_Num_To_Hide%_TimeLapse " < " %Gui_Num_To_Hide%_Delay_Before_Hide ") "
If (%Gui_Num_To_Hide%_Enabled_Disabled_Flag != 1)
return
If (A_TickCount - %Gui_Num_To_Hide%_TimeLapse < %Gui_Num_To_Hide%_Delay_Before_Hide) ; If the mouse was over the GUI within the last 3 seconds, don't hide it
return
WinGetPos, GUIX, GUIY,,, % %Gui_Num_To_Hide%_Gui_Title ; Get the position of the GUI
Loop
{
; MsgBox % "If (" %Gui_Num_To_Hide%_GUIY+%Gui_Num_To_Hide%_GUIH " > " %Gui_Num_To_Hide%_Number_Of_Offset_Pixels ")"
If (GUIY < A_ScreenHeight-%Gui_Num_To_Hide%_Number_Of_Offset_Pixels) ; If the GUI is not hidden hide it then break
{
;~ ;MsgBox % "WinMove," %Gui_Num_To_Hide%_Gui_Title ",, " GUIX ", " GUIY-(A_Index)
WinMove, % %Gui_Num_To_Hide%_Gui_Title,, %GUIX%, % GUIY+(A_Index)
WinGetPos, GUIX, GUIY,,, % %Gui_Num_To_Hide%_Gui_Title
;MsgBox % "WinGetPos, " GUIX ", " GUIY ",,, " %Gui_Num_To_Hide%_Gui_Title
}
else
break
}
If (GUIY > A_ScreenHeight-(%Gui_Num_To_Hide%_Number_Of_Offset_Pixels-1)) ; Failsafe if the GUI moves too far
{
WinMove, % %Gui_Num_To_Hide%_Gui_Title,, %GUIX%, % (A_ScreenHeight - %Gui_Num_To_Hide%_Number_Of_Offset_Pixels)
}
SetTimer, HideGUID, OFF
return
HideGUIR:
If (%Gui_Num_To_Hide%_Enabled_Disabled_Flag != 1)
return
;~ ;MsgBox % "If (" A_TickCount - %Gui_Num_To_Hide%_TimeLapse " < " %Gui_Num_To_Hide%_Delay_Before_Hide ") "
If (A_TickCount - %Gui_Num_To_Hide%_TimeLapse < %Gui_Num_To_Hide%_Delay_Before_Hide) ; If the mouse was over the GUI within the last 3 seconds, don't hide it
return
WinGetPos, GUIX, GUIY,,, % %Gui_Num_To_Hide%_Gui_Title ; Get the position of the GUI
Loop
{
; MsgBox % "If (" %Gui_Num_To_Hide%_GUIY+%Gui_Num_To_Hide%_GUIH " > " %Gui_Num_To_Hide%_Number_Of_Offset_Pixels ")"
If (GUIX < A_ScreenWidth-%Gui_Num_To_Hide%_Number_Of_Offset_Pixels) ; If the GUI is not hidden hide it then break
{
;~ ;MsgBox % "WinMove," %Gui_Num_To_Hide%_Gui_Title ",, " GUIX ", " GUIY-(A_Index)
WinMove, % %Gui_Num_To_Hide%_Gui_Title,, % GUIX+A_Index, %GUIY%
WinGetPos, GUIX, GUIY,,, % %Gui_Num_To_Hide%_Gui_Title
;MsgBox % "WinGetPos, " GUIX ", " GUIY ",,, " %Gui_Num_To_Hide%_Gui_Title
}
else
break
}
If (GUIX > A_ScreenWidth-%Gui_Num_To_Hide%_Number_Of_Offset_Pixels) ; Failsafe if the GUI moves too far
{
WinMove, % %Gui_Num_To_Hide%_Gui_Title,, % A_ScreenWidth-%Gui_Num_To_Hide%_Number_Of_Offset_Pixels, %GUIY%
}
SetTimer, HideGUIR, OFF
return
HideGUIL:
;~ ;MsgBox % "If (" A_TickCount - %Gui_Num_To_Hide%_TimeLapse " < " %Gui_Num_To_Hide%_Delay_Before_Hide ") "
If (%Gui_Num_To_Hide%_Enabled_Disabled_Flag != 1)
return
If (A_TickCount - %Gui_Num_To_Hide%_TimeLapse < %Gui_Num_To_Hide%_Delay_Before_Hide) ; If the mouse was over the GUI within the last 3 seconds, don't hide it
return
WinGetPos, GUIX, GUIY,,, % %Gui_Num_To_Hide%_Gui_Title ; Get the position of the GUI
Loop
{
; MsgBox % "If (" %Gui_Num_To_Hide%_GUIY+%Gui_Num_To_Hide%_GUIH " > " %Gui_Num_To_Hide%_Number_Of_Offset_Pixels ")"
If (GUIX+%Gui_Num_To_Hide%_GUIW > %Gui_Num_To_Hide%_Number_Of_Offset_Pixels) ; If the GUI is not hidden hide it then break
{
;~ ;MsgBox % "WinMove," %Gui_Num_To_Hide%_Gui_Title ",, " GUIX ", " GUIY-(A_Index)
WinMove, % %Gui_Num_To_Hide%_Gui_Title,, % GUIX-A_Index, %GUIY%
WinGetPos, GUIX, GUIY,,, % %Gui_Num_To_Hide%_Gui_Title
;MsgBox % "WinGetPos, " GUIX ", " GUIY ",,, " %Gui_Num_To_Hide%_Gui_Title
}
else
break
}
If (GUIX+%Gui_Num_To_Hide%_GUIW < %Gui_Num_To_Hide%_Number_Of_Offset_Pixels) ; Failsafe if the GUI moves too far
{
WinMove, % %Gui_Num_To_Hide%_Gui_Title,, % -%Gui_Num_To_Hide%_GUIW+%Gui_Num_To_Hide%_Number_Of_Offset_Pixels, %GUIY%
}
SetTimer, HideGUIL, OFF
return
}
WM_MOUSEMOVE(wParam,lParam) ; Action to take if the mouse moves over the GUI
{
If (%A_Gui%_Enabled_Disabled_Flag = 1)
{
RestartGUIActivate:
LabelDir := %A_Gui%_Hide_Direction
SetTimer, HideGUI%LabelDir%, Off ; Turn off the label while the mouse is over the GUI
WinGetPos, GUIX, GUIY,,, % %A_Gui%_Gui_Title ; Get the position of the GUI if your cursor is over it.
; DO ACTION BASED ON WHAT DIRECTION THE GUI IS SET TO
If (%A_Gui%_Hide_Direction == "U")
{
Loop
{
If (GUIY+%A_Gui%_GUIH < %A_Gui%_GUIH) ; If the GUI is hidden, show it then break
{
WinMove, % %A_Gui%_Gui_Title,, %GUIX%, % GUIY+(A_Index)
WinGetPos, GUIX, GUIY,,, % %A_Gui%_Gui_Title
}
else
break
}
}
Else If (%A_Gui%_Hide_Direction == "D")
{
Loop
{
If (GUIY > A_ScreenHeight-%A_Gui%_GUIH) ; If the GUI is hidden, show it then break
{
WinMove, % %A_Gui%_Gui_Title,, %GUIX%, % GUIY-(A_Index)
WinGetPos, GUIX, GUIY,,, % %A_Gui%_Gui_Title
}
else
break
}
}
Else If (%A_Gui%_Hide_Direction == "R")
{
Loop
{
If (GUIX+%A_Gui%_GUIW > A_ScreenWidth+%A_Gui%_Number_Of_Offset_Pixels) ; If the GUI is hidden, show it then break
{
WinMove, % %A_Gui%_Gui_Title,, GUIX-A_Index, %GUIY%
WinGetPos, GUIX, GUIY,,, % %A_Gui%_Gui_Title
}
else
break
}
}
Else If (%A_Gui%_Hide_Direction == "L")
{
Loop
{
If (GUIX+%A_Gui%_Number_Of_Offset_Pixels < 0) ; If the GUI is hidden, show it then break
{
WinMove, % %A_Gui%_Gui_Title,, GUIX+A_Index, %GUIY%
WinGetPos, GUIX, GUIY,,, % %A_Gui%_Gui_Title
}
else
break
}
}
CoordMode, Mouse, Screen ;get the mouse position in SCREEN MODE because your GUI is relative to the screen
MouseGetPos, MX, MY
CoordMode, Mouse, Relative
If (%A_Gui%_Hide_Direction == "U" && MX >= %A_Gui%_GUIX && MX <= %A_Gui%_GUIX+%A_Gui%_GUIW && MY >= 0 && MY <= %A_Gui%_GUIH) ; Check if your mouse is still over the GUI (U)
{
goto, RestartGUIActivate ;Restart if it is
}
Else If (%A_Gui%_Hide_Direction == "D" && MX >= %A_Gui%_GUIX && MX <= %A_Gui%_GUIX+%A_Gui%_GUIW && MY >= A_ScreenHeight-%A_Gui%_GUIH && MY-%A_Gui%_GUIH <= A_ScreenHeight) ; Check if your mouse is still over the GUI (D)
{
goto, RestartGUIActivate ;Restart if it is
}
Else If (%A_Gui%_Hide_Direction == "R" && MX >= A_ScreenWidth-%A_Gui%_GUIW && MX <= A_ScreenWidth && MY >= %A_Gui%_GUIY && MY <= %A_Gui%_GUIY+%A_Gui%_GUIH) ; Check if your mouse is still over the GUI (R)
{
goto, RestartGUIActivate ;Restart if it is
}
Else If (%A_Gui%_Hide_Direction == "L" && MX >= 0 && MX <= %A_Gui%_GUIW && MY >= %A_Gui%_GUIY && MY <= %A_Gui%_GUIY+%A_Gui%_GUIH) ; Check if your mouse is still over the GUI (L)
{
goto, RestartGUIActivate ;Restart if it is
}
else ; If your mouse is not over the GUI, prepare to hide it.
{
%A_Gui%_TimeLapse := A_TickCount
SetTimer, HideGUI%LabelDir%, 1000
}
}
}
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
Resolution itself doesn’t matter unless the program that displays the image goes out of its way to render the image differently on different resolutions, which is not typical. An image at one resolution will be the same on another resolution. It’s still the same number of pixels, containing the same colors. The image just takes up a smaller proportion of the screen on the higher resolution screen.milkygirl90 wrote: ↑ 1. If screen resolution is different on every desktop and I want to make it cross-compatible, how will you suggest doing so? I only have 2 resolutions for now - 2560x1440 & 1920x1080. Trying to avoid creating 2 separate screenshots for imagesearch.
It becomes an issue when Windows scaling settings other than 100% are used, usually becoming a problem at 150% or higher. This is because Windows stretches the Image over a larger number of pixels, so it no longer is represented the same on a pixel-by-pixel basis.
Depending on the intensity level of the overlay, you might be able to still find the image using enough allowable variation in the *n (variation) option in the ImageFile parameter of the ImageSearch command.milkygirl90 wrote: ↑ 2. I have a translucent overlay auto-activated at night with different intensity levels and this affects the imagesearch. Is there any way for Findclick to work without disabling my script?
A more reliable approach if the overlay is a different window is to use an image search based on GDI+, such as a popular function called Gdip_ImageSearch. With that method, you can search the contents of a particular window, so if there is another window over the top of the one you are searching, it doesn’t have any impact.
- milkygirl90
- Posts: 565
- Joined: 10 Nov 2020, 21:22
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
1. Exactly, different scaling is used on different computers (some @ 125% and some 150% / 100%). Is there a method to "ignore" the scaling or still have the script work regardless of scaling settings?boiler wrote: ↑19 Feb 2021, 06:29milkygirl90 wrote: ↑ It becomes an issue when Windows scaling settings other than 100% are used, usually becoming a problem at 150% or higher. This is because Windows stretches the Image over a larger number of pixels, so it no longer is represented the same on a pixel-by-pixel basis.
Depending on the intensity level of the overlay, you might be able to still find the image using enough allowable variation in the *n (variation) option in the ImageFile parameter of the ImageSearch command.milkygirl90 wrote: ↑ 2. I have a translucent overlay auto-activated at night with different intensity levels and this affects the imagesearch. Is there any way for Findclick to work without disabling my script?
A more reliable approach if the overlay is a different window is to use an image search based on GDI+, such as a popular function called Gdip_ImageSearch. With that method, you can search the contents of a particular window, so if there is another window over the top of the one you are searching, it doesn’t have any impact.
2. For the *n function, I didn't see it in FindClick documentation. Do you mind sharing 1 example of how this is scripted alongside FindClick?
3. For Gdip - is this the one? I couldn't find a separate documentation on how to use it.
https://github.com/MasterFocus/AutoHotkey/tree/master/Functions/Gdip_ImageSearch
Thanks!
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
No, because when the image is “stretched” by Windows for display at a different scaling factor, it is fundamentally changed. It may look the same to the naked eye, but the number of pixels and the color values of those pixels are no longer the same as the original. What’s worse is that you can’t even count on an image drawn at 150% scaling being rendered the same each time it’s displayed at that same scaling factor, so even having multiple reference images for the different scaling factors usually won’t be a good solution.milkygirl90 wrote: ↑ 1. Exactly, different scaling is used on different computers (some @ 125% and some 150% / 100%). Is there a method to "ignore" the scaling or still have the script work regardless of scaling settings?
The “Quick-Start Guide” on page 4 of the documentation has an example of using the “o” option for allowing variation:milkygirl90 wrote: ↑ 2. For the *n function, I didn't see it in FindClick documentation. Do you mind sharing 1 example of how this is scripted alongside FindClick?
Code: Select all
FindClick("C:\MyImage.png", "o12") ; Allows 12 shades of variation
Yes, that’s it. The documentation on how to use it is in the comments in the function’s script itself.milkygirl90 wrote: ↑ 3. For Gdip - is this the one? I couldn't find a separate documentation on how to use it.
https://github.com/MasterFocus/AutoHotkey/tree/master/Functions/Gdip_ImageSearch
- milkygirl90
- Posts: 565
- Joined: 10 Nov 2020, 21:22
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
very helpful. thank you so much!
- milkygirl90
- Posts: 565
- Joined: 10 Nov 2020, 21:22
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
sorry I got another question: if there are many similar icons I want to search for, how do I tell the function to start searching from say middle bottom of the screen and click on the first one it finds?
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
I believe the default is to click just the first one it finds as long as you don’t specify the e option to find and click every one it finds.
To have it search only a certain area, Use the area option (a) to define a search area. For example, the following will search the rectangle defined by an upper-left corner of x=50 and y=500 with a width of 700 pixels and a height of 300 pixels (along with an allowable variation on the colors found of 12, like before):
Whether that area is relative to the screen or the active window depends on whether you used the r option to specify a specific window.
To have it search only a certain area, Use the area option (a) to define a search area. For example, the following will search the rectangle defined by an upper-left corner of x=50 and y=500 with a width of 700 pixels and a height of 300 pixels (along with an allowable variation on the colors found of 12, like before):
Code: Select all
FindClick("C:\MyImage.png", "a50,500,700,300 o12")
- milkygirl90
- Posts: 565
- Joined: 10 Nov 2020, 21:22
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
I'm a bit confused. the x and y also represents pixels? Thought that we only need 2 values (x and y) to define the location.
Separately, how do I script it as a toggle? E.g. f11 tries to search for either one of these 2 images, but not BOTH (first when the tab is open, and second when the tab is closed)
Separately, how do I script it as a toggle? E.g. f11 tries to search for either one of these 2 images, but not BOTH (first when the tab is open, and second when the tab is closed)
Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]
Yes, x and y are in pixels. While only two values are needed to define a location, my example was defining a rectangle, not a single location. FindClick uses x,y,w,h (upper-left corner and width and height). This differs a bit from ImageSearch, which requires two x,y points to define the search rectangle: x1,y1 is upper-left, and x2,y2 is lower-right. FindClick will search the entire screen/window if you don't specify the a option to modify the default search area. My example was defining a rectangle. As I understand it, you can also specify the lower part of the screen by using a + and a value with the height value (leaving the other values blank). So the following would search the screen starting 500 pixels down from the top (and allow 12 shades of variation):milkygirl90 wrote: ↑ I'm a bit confused. the x and y also represents pixels? Thought that we only need 2 values (x and y) to define the location.
Code: Select all
FindClick("C:\MyImage.png", "a,,,+500 o12")
You could do something like this:milkygirl90 wrote: ↑ Separately, how do I script it as a toggle? E.g. f11 tries to search for either one of these 2 images, but not BOTH (first when the tab is open, and second when the tab is closed)
Code: Select all
F11::
Toggle := !Toggle
if Toggle
FindClick("C:\MyImage1.png", "a,,,+500 o12")
else
FindClick("C:\MyImage2.png", "a,,,+500 o12")
return
Code: Select all
F11::FindClick((Toggle := !Toggle) ? "C:\MyImage1.png" : "C:\MyImage2.png", "a,,,+500 o12")
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: ositoMalvado and 110 guests