if imagefound > display a number onscreen

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kentpachi
Posts: 152
Joined: 15 May 2016, 01:23

if imagefound > display a number onscreen

Post by kentpachi » 28 Sep 2023, 08:39

sample sscript

Code: Select all

loop

{

CoordMode, Pixel, Window
ImageSearch, FoundX, FoundY, 10, 9, 536, 69, apple.png
If ErrorLevel = 0
{
	; display number 1 onscreen

}



CoordMode, Pixel, Window
ImageSearch, FoundX, FoundY, 10, 9, 536, 69, orange.png
If ErrorLevel = 0
{
	; display number 2 onscreen

}


CoordMode, Pixel, Window
ImageSearch, FoundX, FoundY, 10, 9, 536, 69, mango.png
If ErrorLevel = 0
{
; display number 3 onscreen


}


}

[Mod edit: Replaced c-tags with code-tags.]


there are 3 imagesearch which is apple, orange and mango.
if apple is found > show 1 on the middle of the screen and its clickable through it
if orange is found > show 2 on the middle of the screen and its clickable through it
if mango is found > show 3 on the middle of the screen and its clickable through it


basically if the fruits are found, display onscreen text on the middle of the screen and text can be click through which doesnt obstruct clicking.

if the 3 fruits are not present then display 0 text

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: if imagefound > display a number onscreen

Post by mikeyww » 28 Sep 2023, 08:48

Since your script does not work, start with a three-line test script. On the first line, set the CoordMode. On the second line, search for your image. On the third line, display your ErrorLevel. This approach will enable you to troubleshoot a script with only three lines. If the ErrorLevel is 1, it means that your image was not found.

In this script, coordinates are relative to the active window by default, so setting the CoordMode to the active window is not necessary. If your target window is not active, you might get unexpected results with this CoordMode.

kentpachi
Posts: 152
Joined: 15 May 2016, 01:23

Re: if imagefound > display a number onscreen

Post by kentpachi » 28 Sep 2023, 09:01

mikeyww wrote:
28 Sep 2023, 08:48
Since your script does not work, start with a three-line test script. On the first line, set the CoordMode. On the second line, search for your image. On the third line, display your ErrorLevel. This approach will enable you to troubleshoot a script with only three lines. If the ErrorLevel is 1, it means that your image was not found.

In this script, coordinates are relative to the active window by default, so setting the CoordMode to the active window is not necessary. If your target window is not active, you might get unexpected results with this CoordMode.
thank you for your reply,

i see, and for the display?

how to make it display an onscreen text when the images are found?
preferably that can be click-though

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: if imagefound > display a number onscreen

Post by mikeyww » 28 Sep 2023, 09:12

I would get the first part working first. See if your image can be found.

Code: Select all

#Requires AutoHotkey v1.1.33
Gui +AlwaysOnTop +E0x20 +LastFound -Caption
Gui Color, trans := EEAA99
WinSet TransColor, trans
Gui Font, s30 w700
Gui Add, Text, w230 cRed Center vtxt

F3::show(1)
F4::show(2)

show(txt) {
 GuiControl,, txt, % txt
 Gui Show, x100 NoActivate
}

Post Reply

Return to “Ask for Help (v1)”