Wow AHK Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Toonmax38

Wow AHK  Topic is solved

09 Jun 2018, 21:05

Was wondering if anyone could improve the script I made see below, its very long but works pretty well

Code: Select all

#ifWinActive World of Warcraft
#NoEnv
#KeyHistory 0
#MaxThreads 255
#MaxMem 4095
#MaxThreadsBuffer On
#MaxHotkeysPerInterval 9900000000
#HotkeyInterval 990000000
ListLines Off
setkeydelay -1,-1
SetTitleMatchMode fast
SetBatchLines, -1
SetWorkingDir, C:\Rotations 12
{
$2::
   Loop 
   {
    if not GetKeyState("2" ,"P")
     break
send {]}
ImageSearch, FoundX, FoundY,70,20,80,30,KC.bmp
if ErrorLevel = 0
{
Send {2}
}
ImageSearch, FoundX, FoundY,70,20,80,30,DB.bmp
if ErrorLevel = 0
{
Send {0}
}
ImageSearch, FoundX, FoundY,70,20,80,30,COBRA.bmp
if ErrorLevel = 0
{
Send {1}
}
ImageSearch, FoundX, FoundY,70,20,80,30,TT.bmp
if ErrorLevel = 0
{
send {-}
}
ImageSearch, FoundX, FoundY,70,20,80,30,AMOC.bmp
if ErrorLevel = 0
{
Send {6}
}
ImageSearch, FoundX, FoundY,70,20,80,30,BW.bmp
if ErrorLevel = 0
{
Send {=}
}
ImageSearch, FoundX, FoundY,70,20,80,30,AOTW.bmp
if ErrorLevel = 0
{
Send {4}
}
ImageSearch, FoundX, FoundY,70,20,80,30,MULTI.bmp
if ErrorLevel = 0
{
Send {9}
}
ImageSearch, FoundX, FoundY,70,20,80,30,AT.bmp
if ErrorLevel = 0
{
Send {8}
}
ImageSearch, FoundX, FoundY,70,20,80,30,heal.bmp
if ErrorLevel = 0
{
Send {[}
}
ImageSearch, FoundX, FoundY,70,20,80,30,EX2.bmp
if ErrorLevel = 0
{
Send {,}
}
ImageSearch, FoundX, FoundY,70,20,80,30,DF.bmp
if ErrorLevel = 0
{
Send {0}
}
}
Return
}
Mod edit: Added code tags.
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Wow AHK

09 Jun 2018, 23:39

Whenever you have repeating code its time to think about creating a function.

Code: Select all

#NoEnv
#KeyHistory 0
ListLines Off
SetTitleMatchMode fast
SetBatchLines, -1
SetWorkingDir, C:\Rotations 12
#ifWinActive World of Warcraft
$2::
    Loop 
    {
        if not GetKeyState("2" ,"P")
            break
        send, ]
        ImgSearch("KC","2")
        ImgSearch("DB","0")
        ImgSearch("COBRA","1")
        ImgSearch("TT","-")
        ImgSearch("AMOC","6")
        ImgSearch("BW","=")
        ImgSearch("AOTW","4")
        ImgSearch("MULTI","9")
        ImgSearch("AT","8")
        ImgSearch("heal","[")
        ImgSearch("EX2",",")
        ImgSearch("DF","0")
    }
Return

ImgSearch(imagename,key){
    ImageSearch,,,70,20,80,30,%imagename%.bmp
    if (ErrorLevel = 0)
        SendInput % key
}
I also removed stuff that doesnt apply to the script.
Note: setkeydelay, -1,-1 is the same as sendinput speedwise but sendinput is better as it buffers any keystrokes typed while it is sending.

HTH
Toonmax38

Re: Wow AHK

10 Jun 2018, 06:42

thank you, it doesn't seem to be much faster but its much neater so thank you.
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Wow AHK

10 Jun 2018, 07:09

If you really want it to be faster you need a better image search function.
Recommends AHK Studio
Toonmax38

Re: Wow AHK

10 Jun 2018, 10:20

What other image search functions are their? or do I need a smaller search area? or is pixel search better?

Thanks
Jdriele

Re: Wow AHK

15 Jun 2018, 05:57

Maybe you can use smaller images. The bigger they are, slower is you program.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 72 guests