FIXED , DELETE THREAD PLEASE!
Nextron edit: Restored content:
What I'm trying to do is have AHK search the area on the screen I specify for an image that is changing almost every 1-2 seconds. every time it sees that image it will then spam press keyboard number I assigned to the image, if the image changes then AHK does the same thing in loop. If it doesn't have anything in the region then it will idle until an image comes up. Any help is really appreciated thank you so much! This is what I have so far as to what i'm trying to do but im kind of stuck on what do do next.
I'm also trying to have it only working while I hold down a specified button on my keyboard like "j" or anything like that.
ImageSearch, OutputVarX, OutputVarY, 936, 668, 980, 715, C:\Users\A\Downloads\WoW\Garrote.png
ImageSearch, OutputVarX, OutputVarY, 936, 668, 980, 715, C:\Users\A\Downloads\WoW\envenom.png
ImageSearch, OutputVarX, OutputVarY, 936, 668, 980, 715, C:\Users\A\Downloads\WoW\Mutilate.png
ImageSearch, OutputVarX, OutputVarY, 936, 668, 980, 715, C:\Users\A\Downloads\WoW\rupture.png
ImageSearch, OutputVarX, OutputVarY, 936, 668, 980, 715, C:\Users\A\Downloads\WoW\vanish.png
ImageSearch, OutputVarX, OutputVarY, 936, 668, 980, 715, C:\Users\A\Downloads\WoW\vendetta.png
This big icon in the middle that is changing is the region I set it to search for if i'm correct.
This is the video
https://streamable.com/hl8qu
Imagesearch region + execute keybind if true [Post deleted]
Imagesearch region + execute keybind if true [Post deleted]
Last edited by Blick on 04 Oct 2018, 12:21, edited 2 times in total.
Re: Imagesearch region + execute keybind if true / need help
Code: Select all
#NoEnv
#SingleInstance Force
SendMode Input
SetBatchLines -1
CoordMode Pixel
*j::SetTimer WatchSpells, 10
*j Up::SetTimer WatchSpells, Off
WatchSpells() {
static X1 := 936, Y1 := 668, X2 := 980, Y2 := 715
, SPELL_KEYMAP := {"Garrote": "q"
, "envenom": "w"
, "Mutilate": "e"
, "rupture": "r"
, "vanish": "t"
, "vendetta": "y"}
for spell, key in SPELL_KEYMAP
{
ImageSearch, , , X1, Y1, X2, Y2, % "C:\Users\A\Downloads\WoW\" spell ".png"
if !ErrorLevel
Send % key
}
}
Re: Imagesearch region + execute keybind if true / need help
Nextron edit: Restored content:
Code: Select all
#NoEnv
#SingleInstance Force
SendMode Input
SetBatchLines -1
CoordMode Pixel
*j::SetTimer WatchSpells, 10
*j Up::SetTimer WatchSpells, Off
WatchSpells() {
static X1 := 936, Y1 := 668, X2 := 980, Y2 := 715
, SPELL_KEYMAP := {"Garrote": "q"
, "envenom": "w"
, "Mutilate": "e"
, "rupture": "r"
, "vanish": "t"
, "vendetta": "y"}
for spell, key in SPELL_KEYMAP
{
ImageSearch, , , X1, Y1, X2, Y2, % "C:\Users\A\Downloads\WoW\" spell ".png"
if !ErrorLevel
Send % key
}
}
It didn't work if so. I might need to change my pics to be smaller for AHK to recognize the image inside x1y1y1y2
Thank you so much for the help, really looking forward to learning more.
*EDIT*
Worked perfectly. Thank you so much for the help!!
Last edited by Blick on 04 Oct 2018, 12:19, edited 1 time in total.
Re: Imagesearch region + execute keybind if true / need help
u can change the coordinates, the spell names/image files, and the keys to which spells are bound(q,w,e,r,t,y in this case, likely something else in urs)
Re: FIXED!DELETE THREAD PLEASE!
fixed, delete thread please................... ughh for fucks sake, i dont even
https://autohotkey.com/forumrules/
https://autohotkey.com/forumrules/
Brick wrote: Hey man the script you posted on the thread works perfectly but it's just spamming the output key when image found a little bit too slow and i'm wantint to make it a bit faster. Was wondering where I could change that in the script?
This is a video of how slow the output is. Other than that thanks for being a great person and helping the community!
https://streamable.com/iyjh7
Code: Select all
#IfWinActive World of Warcraft #NoEnv #SingleInstance Force SendMode Input SetBatchLines -1 CoordMode Pixel *1::SetTimer WatchSpells, 10 *1 Up::SetTimer WatchSpells, Off WatchSpells() { static X1 := 936, Y1 := 668, X2 := 980, Y2 := 715 , SPELL_KEYMAP := {"Garrote": "1" , "envenom": "7" , "Mutilate": "9" , "rupture": "8" , "vanish": "=" , "vendetta": "-" , "toxicblade": "0" , "cobra": "1" , "crows": "9" , "killcommand": "2" , "wrath": "3" , "aspect": "5" , "barbed": "0" , "chimera": "8" , "barbed2": "0" , "barbed3": "0" , "barbed4": "0" , "anh": "3" , "aura": "2" , "chaos": "3" , "dance": "8" , "eyebeam": "4" , "sweep": "8" , "demon": "9"} for spell, key in SPELL_KEYMAP { ImageSearch, , , X1, Y1, X2, Y2, % "C:\Users\A\Downloads\o\" spell ".png" if !ErrorLevel Send % key } }
swagfag wrote: ur bottleneck is the ImageSearch, which is computationally very expensive. To increase its speed, narrow its search space, or increase its variance setting(although this might result in failures to match accurately).
Furthermore, im no wow aficionado but it would seem youve added spells belonging to different classes all in the same script. While convenient for u perhaps, this causes avoidable delays. It makes little sense to needlessly check for hunter spells while playing a rogue is what im getting at - either make separate scripts or load the images manually according to what youre playing atm(eg via different hotkeys)
Another optimization would be to do away with image searching altogether and resort to something else, eg PixelGetColor. If u can uniquely identify each spell by a single pixel, this approach would be viable. See this img(look for 1 pixel, instead of imagesearching a whole rectangle)
Look at this similar thread also: https://autohotkey.com/boards/viewtopic.php?f=5&t=48122
U can use an addon maybe like tellmewhen or something to assign each spell a different brightly colored square(r, g, b, cyan, magenta, etc) and PixelGetColor on it, if finding unique pixel in the original textures isnt feasible
ive no recollection of the original question and have nothing to cross reference it with, since u overwrote the thread. it sounds to me like wrapping the imagesearch loop in a function would do the trick and then pass it whatever coords it needs to look at:Brick wrote: Hey this was the code that you helped me out with and very grateful for but 1 more question regarding this if you could help me out. I'm wondering how to input another scan area on the screen for the script to look for and be optimized so it wouldn't slow anything down. I know how to get coordinates but I don't know where in the AHK script to input them to not screw anything up.
Any help would be appreciated and grateful as always!
Code: Select all
#NoEnv
#SingleInstance Force
SendMode Input
SetBatchLines -1
CoordMode Pixel
#IfWinActive World of Warcraft
*1::SetTimer WatchSpells, 10
*1 Up::SetTimer WatchSpells, Off
WatchSpells() {
static SPELL_KEYMAP := {"Garrote": "1"}
ImgSearch(936, 668, 980, 715, SPELL_KEYMAP)
ImgSearch(100, 100, 200, 200, SPELL_KEYMAP)
}
ImgSearch(X1, Y1, X2, Y2, SpellKeyMap) {
for spell, key in SpellKeyMap
{
ImageSearch, , , X1, Y1, X2, Y2, % "C:\Users\A\Downloads\o\" spell ".png"
if !ErrorLevel
Send % key
}
}
Re: FIXED!DELETE THREAD PLEASE!
Hey i'm trying to do this but it keeps telling me that theres an error missing "}" on line 18. Tried fixing it but still won't execute for me. What am I doing wrong?swagfag wrote: ↑19 Oct 2018, 17:47fixed, delete thread please................... ughh for fucks sake, i dont even
https://autohotkey.com/forumrules/
Brick wrote: Hey man the script you posted on the thread works perfectly but it's just spamming the output key when image found a little bit too slow and i'm wantint to make it a bit faster. Was wondering where I could change that in the script?
This is a video of how slow the output is. Other than that thanks for being a great person and helping the community!
https://streamable.com/iyjh7
Code: Select all
#IfWinActive World of Warcraft #NoEnv #SingleInstance Force SendMode Input SetBatchLines -1 CoordMode Pixel *1::SetTimer WatchSpells, 10 *1 Up::SetTimer WatchSpells, Off WatchSpells() { static X1 := 936, Y1 := 668, X2 := 980, Y2 := 715 , SPELL_KEYMAP := {"Garrote": "1" , "envenom": "7" , "Mutilate": "9" , "rupture": "8" , "vanish": "=" , "vendetta": "-" , "toxicblade": "0" , "cobra": "1" , "crows": "9" , "killcommand": "2" , "wrath": "3" , "aspect": "5" , "barbed": "0" , "chimera": "8" , "barbed2": "0" , "barbed3": "0" , "barbed4": "0" , "anh": "3" , "aura": "2" , "chaos": "3" , "dance": "8" , "eyebeam": "4" , "sweep": "8" , "demon": "9"} for spell, key in SPELL_KEYMAP { ImageSearch, , , X1, Y1, X2, Y2, % "C:\Users\A\Downloads\o\" spell ".png" if !ErrorLevel Send % key } }
swagfag wrote: ur bottleneck is the ImageSearch, which is computationally very expensive. To increase its speed, narrow its search space, or increase its variance setting(although this might result in failures to match accurately).
Furthermore, im no wow aficionado but it would seem youve added spells belonging to different classes all in the same script. While convenient for u perhaps, this causes avoidable delays. It makes little sense to needlessly check for hunter spells while playing a rogue is what im getting at - either make separate scripts or load the images manually according to what youre playing atm(eg via different hotkeys)
Another optimization would be to do away with image searching altogether and resort to something else, eg PixelGetColor. If u can uniquely identify each spell by a single pixel, this approach would be viable. See this img(look for 1 pixel, instead of imagesearching a whole rectangle)
Look at this similar thread also: https://autohotkey.com/boards/viewtopic.php?f=5&t=48122
U can use an addon maybe like tellmewhen or something to assign each spell a different brightly colored square(r, g, b, cyan, magenta, etc) and PixelGetColor on it, if finding unique pixel in the original textures isnt feasibleive no recollection of the original question and have nothing to cross reference it with, since u overwrote the thread. it sounds to me like wrapping the imagesearch loop in a function would do the trick and then pass it whatever coords it needs to look at:Brick wrote: Hey this was the code that you helped me out with and very grateful for but 1 more question regarding this if you could help me out. I'm wondering how to input another scan area on the screen for the script to look for and be optimized so it wouldn't slow anything down. I know how to get coordinates but I don't know where in the AHK script to input them to not screw anything up.
Any help would be appreciated and grateful as always!Code: Select all
#NoEnv #SingleInstance Force SendMode Input SetBatchLines -1 CoordMode Pixel #IfWinActive World of Warcraft *1::SetTimer WatchSpells, 10 *1 Up::SetTimer WatchSpells, Off WatchSpells() { static SPELL_KEYMAP := {"Garrote": "1"} ImgSearch(936, 668, 980, 715, SPELL_KEYMAP) ImgSearch(100, 100, 200, 200, SPELL_KEYMAP) } ImgSearch(X1, Y1, X2, Y2, SpellKeyMap) { for spell, key in SpellKeyMap { ImageSearch, , , X1, Y1, X2, Y2, % "C:\Users\A\Downloads\o\" spell ".png" if !ErrorLevel Send % key } }
Re: FIXED!DELETE THREAD PLEASE!
what ive posted, as is, executes without throwing:
Code: Select all
#NoEnv
#SingleInstance Force
SendMode Input
SetBatchLines -1
CoordMode Pixel
#IfWinActive World of Warcraft
*1::SetTimer WatchSpells, 10
*1 Up::SetTimer WatchSpells, Off
WatchSpells() {
static SPELL_KEYMAP := {"Garrote": "1"}
ImgSearch(936, 668, 980, 715, SPELL_KEYMAP)
ImgSearch(100, 100, 200, 200, SPELL_KEYMAP)
}
ImgSearch(X1, Y1, X2, Y2, SpellKeyMap) { ; <-- line 18 in this script
for spell, key in SpellKeyMap
{
ImageSearch, , , X1, Y1, X2, Y2, % "C:\Users\A\Downloads\o\" spell ".png"
if !ErrorLevel
Send % key
}
} ; is this perhaps missing??
Re: FIXED!DELETE THREAD PLEASE!
@blick If you ever post another question and then overwrite it again as you have done here and i find out. you will be banned
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
Re: FIXED!DELETE THREAD PLEASE!
You were right, it was because I was missing that at the end! Thank you.swagfag wrote: ↑20 Oct 2018, 14:25what ive posted, as is, executes without throwing:Code: Select all
#NoEnv #SingleInstance Force SendMode Input SetBatchLines -1 CoordMode Pixel #IfWinActive World of Warcraft *1::SetTimer WatchSpells, 10 *1 Up::SetTimer WatchSpells, Off WatchSpells() { static SPELL_KEYMAP := {"Garrote": "1"} ImgSearch(936, 668, 980, 715, SPELL_KEYMAP) ImgSearch(100, 100, 200, 200, SPELL_KEYMAP) } ImgSearch(X1, Y1, X2, Y2, SpellKeyMap) { ; <-- line 18 in this script for spell, key in SpellKeyMap { ImageSearch, , , X1, Y1, X2, Y2, % "C:\Users\A\Downloads\o\" spell ".png" if !ErrorLevel Send % key } } ; is this perhaps missing??
I made the scan areas and the images smaller but they are still outputting the keys pretty slowly. Any way to speed up the output? When only scanning one area the output is very fast.
Re: FIXED!DELETE THREAD PLEASE!
I didn't know if this was against the game rules and didn't want anyone else to do the same thing as i'm doing for this game in case this was going to get people banned. I'm not 100% so if I get banned i'm on a throw away account and I won't care as much as another player who has spent 3+ years on his/her account. Even if someone else will be using this script for learning it wouldn't be advised to be used on any games as the anti-cheat might pick up this and get you banned.
Re: Imagesearch region + execute keybind if true [Post deleted]
If I would like to loop this, instead of holding a button, where would I need to put the loop in? =\ (Newbie here)
Re: Imagesearch region + execute keybind if true [Post deleted]
Change:
Code: Select all
*1::SetTimer WatchSpells, 10
*1 Up::SetTimer WatchSpells, Off
Code: Select all
*1::SetTimer WatchSpells, % (t:=!t) ? 10 : "Off"
Re: Imagesearch region + execute keybind if true [Post deleted]
Amazing, thank youXtra wrote: ↑10 Dec 2020, 15:55Change:to:Code: Select all
*1::SetTimer WatchSpells, 10 *1 Up::SetTimer WatchSpells, Off
Now it will toggle.Code: Select all
*1::SetTimer WatchSpells, % (t:=!t) ? 10 : "Off"
Who is online
Users browsing this forum: Rohwedder and 94 guests