ImageSeaarch(Buy) - https://drive.google.com/file/d/1h-GVbSXiMhFT1fjic-drjskV2QzBXZxf/view?usp=drive_link
ImageSeaarch/PixelSearch is not able to locate neither the 'Buy' imageIcon nor the pixels for the provided image above.
The region has been set to full screen and still the code gives errorlevel = 1 .
How to resolve this issue?
Code: Select all
;BUyGreeks
;Click Region click_1 = (850,1000) click_2 = (950,600)
x_d := 100
y_d := 400
buyGreeksImage := "C:\Users\User_0\AppData\Roaming\MacroCreator\Screenshots\buyGreeks.jpg"
^+a::RegionIconClick(buyGreeksImage,x_d,y_d)
#Persistent
RegionIconClick(imagePath,x_d,y_d){
EnableClick := True ; Toggle the global variable value
; EnableClick := !EnableClick ; Toggle the global variable value
while (EnableClick) {
; Check if clicking is enabled
MouseGetPos, ClickX, ClickY
Click, %ClickX% , %ClickY% , Right, 1
Sleep, 2000
CoordMode, Pixel, Window
; 0x1E0C94
; ImageSearch, BuyX , BuyY, ClickX , ClickY - 400,ClickX + 100 ,ClickY ,C:\Users\User_0\AppData\Roaming\MacroCreator\Screenshots\buyGreeks.png
; ImageSearch, BuyX , BuyY, 0,0,1920,1024,C:\Users\User_0\AppData\Roaming\MacroCreator\Screenshots\buyGreeks.png
PixelSearch,BuyX , BuyY, 0,0,1920,1024, 0x2F269F, 0, Fast RGB
Sleep, 100
; MsgBox, Image search result: %ErrorLevel%. X: %BuyX%, Y: %BuyY%
if (ErrorLevel = 2) {
MsgBox, RefImageFile unavailable. Exiting script
ExitApp ; Stop script execution
} else if (ErrorLevel = 1) {
MsgBox, (%ClickX% , %ClickY% ) Image not found in the specified region.
ExitApp ; Stop script execution
}else if (ErrorLevel = 0) {
MsgBox, ImageFound
Sleep, 50
Click, %BuyX% , %BuyY% , Left, 1
; MsgBox, Clicking at X: %BuyX%, Y: %BuyY%
ClickXOffset_1 := BuyX + 425
ClickYOffset_1 := BuyY + 78
Sleep, 100 ; Delay before next click (if needed)
Click, %ClickXOffset_1% , %ClickYOffset_1% , Left, 1
Sleep, 100 ; Delay before next click (if needed)
ClickXOffset_2 := BuyX + 525
ClickYOffset_2 := BuyY + 15
Click, %ClickXOffset_2% , %ClickYOffset_2% , Left, 1
Sleep, 100 ; Delay before next click (if needed)
EnableClick := False ; Re-toggle clicking off
}
Sleep, 1000 ; Wait for 1 second before next iteration
}
}