Hi guys!
Could you help me with a small script that will search for a image and play a sound if it's found?
Start button (any button)
Search for a image (could be two or three images)
If found
Play sound file
Loop sound
When image disappear then it stops playing that sound.
Hope someone can help.
Thanks!
Image search + sound
Re: Image search + sound
Code: Select all
image = ....png
sound = ....wav
F3::
WinGetPos,,, width, height, A
Loop {
Sleep, 200
ImageSearch, x,, 0, 0, width, height, %image%
SoundPlay, % ErrorLevel ? "" : sound, Wait
} Until (x = "")
Return
Re: Image search + sound
Thank you !
Does AHK work that way I can just have any image in the AHK folder that ends in with a .png and this scripts search for it ?
Right now this script cant find any test image I make.
Could you help me a little more here ?
[Mod edit: [code][/code] tags added.]
This is how my folder looks right now:
Does AHK work that way I can just have any image in the AHK folder that ends in with a .png and this scripts search for it ?
Right now this script cant find any test image I make.
Could you help me a little more here ?
Code: Select all
image = ....png
sound = ....wav
F3::
WinGetPos,,, width, height, A
Loop {
Sleep, 200
ImageSearch, x,, 0, 0, width, height, %image%
SoundPlay, % ErrorLevel ? "" : sound, Wait
} Until (x = "")
Return
This is how my folder looks right now:
Re: Image search + sound
You can loop through various images, but start with just one, so that you can get the script working. Change the first two lines: provide a full path to an image & sound file. The script searches with coordinates relative to the active window (can be changed), so ensure that the target window is active before you trigger the hotkey.
Re: Image search + sound
That works thank you.
I get it working when I am browsing in chrome... It finds the image and makes the sound.
But I am trying to do it from a computer game and it seems that it´s not finding any pictures there.
Do you know why that could be ?
I get it working when I am browsing in chrome... It finds the image and makes the sound.
But I am trying to do it from a computer game and it seems that it´s not finding any pictures there.
Do you know why that could be ?
Re: Image search + sound
Should I add *50 in it if the shades are not exactly the same ?
Where would I add it ?
edit***
This actually works !
So I have another question.
When the program finds the image... It start´s playing the sound.
So far so good.
Then when the picture disappears it´s like the script does not reload or something ?
I have to manually press F3 again to turn it on.
Is it possible to keep going without my input to refresh it ?
And also.. Would it be possible to search the whole screen even if the window is not active ?
Where would I add it ?
edit***
This actually works !
So I have another question.
When the program finds the image... It start´s playing the sound.
So far so good.
Then when the picture disappears it´s like the script does not reload or something ?
I have to manually press F3 again to turn it on.
Is it possible to keep going without my input to refresh it ?
And also.. Would it be possible to search the whole screen even if the window is not active ?
Who is online
Users browsing this forum: No registered users and 25 guests