DotA Script - Hero Detection Beta 4

After many hours of hard work, the result is a script that identifies which hero has been selected by the user.

The exe to run this script is here

To use the script. If it doensn't automatically find your hero, press Ctrl-Alt-R and it will try to find it.
If it cannot find it, every 4 seconds text saying Checking Hero will appear.
If found, text saying "Your hero is 'heroname'" should appear.

For fellow AutoHotKey scriptors, scripts depending on the character you select will soon come!
If any errors occur during this script, please email them and your own ideas to admin@dotakey.com

I have worked in my meepo script, the mouse wheel script and an additional script for Puck - Faerie Dragon.
To active their 'ultimate' attack, press Caps Lock once. 

NOTE: Your Screen Resolution must be set to 800x600x32

Aug 18/09 Edit: I have stopped working on this script due to its incompatibility with different screen sizes. Instead I've already developed a script that performs the same thing except faster and with better results. It will be up within 2 weeks.

DotA Script - Hero Detection Beta 4

#IfWinActive ahk_class Warcraft III

#SingleInstance Force

;#NoEnv  
;SendMode Input  
;SetWorkingDir %A_ScriptDir% 

SetKeyDelay, 5, -1, -1/-1 ;; Prevents the code from pressing keys too quickly and placing them in the wrong order.

/* The purpose of this script is, by use of the hero icon that is located at the top left corner of the game screen, determine which hero is being used, and run a script for that hero.
If any errors regarding which hero was selected occur, please email me regarding that at:
admin@dotakey.com
Thanks
*/

while Width = ""  ;; While no screen has been detected, keep checking. 
{
If WinActive("ahk_class Warcraft III")  ;; Once Warcraft is your main screen..
{
sleep 1000
WinGetPos, , , Width, Height  ;;Check the height and width of the screen.
if (Width <> "800" OR Height <> "600") ;; If not 800x600 display messagebox.
Msgbox, Your screen size is wrong. For this script to work, change it to 800x600x32.
DetectLoading()  
sleep 1000
Send, {Enter} Script Running.. {Enter}
sleep 18000
Send {Enter}To check for hero press Ctrl-Alt-R{Enter}
CheckHero()
Send {Enter}Your Hero is %hero%!{Enter}
Send {Enter}If this is incorrect, press Ctrl-Alt-R{Enter}
}
}

Pause::Pause ;; To pause the code press pause once to stop, and again to continue.


^!r::
Checkhero()
Send {Enter}Your Hero is %hero%!{Enter}
Send {Enter}If this is incorrect press Ctrl-Alt-R{Enter}
return


CapsLock::
If (hero = "Geomancer")
;;Code for all Meepos to poof to the first/nearest one to your mouse pointer. 
;;NOTE: all meepos must be selected in one group.
{
        SetKeyDelay, 10, -1, -1/-1 ;;sets a delay of 1/100 of a second between keystrokes.
        Loop 4    ;;does this to all four meepos (i may make meepo detection in the future)
        {
            Send E{Lbutton}{TAB}
            sleep 10
        }
}
else if (hero = "")
Send, ^!r
else if (hero = "Fairy Dragon")
;;Code for Puck to orb replace, silence, ultimate and whatever item is in the first inventory slot.
SetKeyDelay, 100, -1, -1/-1
Send QE{Numpad7}T
keyWait, LButton, D T2
return



MButton::Send ^9{F1}{Numpad8}{LButton}9 ;;Clicking the mouse wheel will use your top right item.
WheelUp::Send ^9{F1}{Numpad7}{LButton}9 ;;Scroll up will use the top left item.
WheelDown::Send ^9{F1}{Numpad4}{LButton}9 ;;Scroll down will use the middle left item.
WheelLeft::Send ^9{F1}{Numpad5}{LButton}9 ;;Clicking the wheel left will use the middle right item.
WheelRight::Send ^9{F1}{Numpad2}{LButton}9 ;;Clicking the wheel right will use the bottom left item.
;; WheelLeft and WheelRight are only active if your mouse supports such actions.








DetectLoading()
{
loop
{
PixelGetColor, color, 593, 535
if (color = 0x735610 OR color = 0x735410)
{
sleep 100
PixelGetColor, color, 593, 535
if (color != 0x735610 OR color != 0x735410)
break
else
continue
}
else
continue
}
}






CheckHero()
{
global hero
a = 0
x = 7
pixelgetcolor, color, 7, 28
sleep 2000
pixelgetcolor, color2, 7, 28
sleep 2000
pixelgetcolor, color3, 7, 28
Send, {Enter}Checking Hero{Enter}
if (color := color2 AND color := color3)
{
loop 10
{
PixelGetColor, Array%a%, %x%, 28
item := Array%a%
x += 1
a += 1
}
}
else
Checkhero()
a = 0
if (Array%a% = 0x989C9F)
hero = Dwarven Sniper
else if (Array%a% = 0x9B9F9F)
{
a += 1
if (Array%a% = 0x9D9E9F)
hero = Luna Moonfang
else if (Array%a% = 0x999E9F)
hero = Templar Assassin
else if (Array%a% = 0x9B9D9F)
hero = Spectre
else
Checkhero()
}
else if (Array%a% = 0x9B9AA0)
hero = Troll Warlord
else if (Array%a% = 0xA09FA0)
{
a += 1
if (Array%a% = 0x9BA09F)
hero = Shadow Shaman
else if (Array%a% = 0x9C9FA0)
hero = Juggernaut
else
Checkhero()
}
else if (Array%a% = 0x9BA2A2)
hero = Bristleback
else if (Array%a% = 0x9BA29E)
hero = Pandaran Brewmaster
else if (Array%a% = 0x9F9D9F)
{
a += 1
if (Array%a% = 0x9C9C9C)
hero = Centaur Warchief
else if (Array%a% = 0x9C9C9F)
hero = Faceless Void
else
Checkhero()
}
else if (Array%a% = 0x98A19C)
hero = Bounty Hunter
else if (Array%a% = 0x999B9F)
hero = Dragon Knight
else if (Array%a% = 0x9B99A0)
hero = Anti-Mage
else if (Array%a% = 0xA1A2A0)
hero = Drow Ranger
else if (Array%a% = 0x989B9A)
hero = Omniknight
else if (Array%a% = 0x9D9EA4)
{
a += 1
if (Array%a% = 0x9F9D9B)
hero = Vengeful Spirit
else if (Array%a% = 0x9B9E9D)
hero = Lightning Revelant
else
Checkhero()
}
else if (Array%a% = 0x989E9F)
hero = Lord of Olympia
else if (Array%a% = 0x9F9F9F)
{
a += 1
if (Array%a% = 0x9D9D9F)
hero = Enchantress
else if (Array%a% = 0x999F9B)
hero = Obsidian Destroyer
else
Checkhero()
}
else if (Array%a% = 0x9F9BA3)
hero = Morphling
else if (Array%a% = 0x9F9DA4)
{
a += 1
if (Array%a% = 0x9C9C9B)
{
a += 1
if (Array%a% = 0x9EA0A2)
hero = Crystal Maiden
else if (Array%a% = 0x9D9DA1)
{
a += 4
if (Array%a% = 0x8F9393)
{
a += 1
if (Array%a% = 0x9B9E9E)
hero = Ogre Magi
else if (Array%a% = 0x989C9D)
hero = Doom Bringer
else
Checkhero()
}
else if (Array%a% = 0x909393)
hero = Pit Lord
else if (Array%a% = 0x8F9493)
hero = Dark Seer
else
Checkhero()
}
else if (Array%a% = 0x9D9D9D)
hero = Nerubian Weaver
else
Checkhero()
}
else if (Array%a% = 0x9C9E9B)
hero = Shadow Fiend
else
Checkhero()
}
else if (Array%a% = 0x9F9DA0)
hero = Rouge Knight
else if (Array%a% = 0x9D9AA0)
hero = Naga Siren
else if (Array%a% = 0x9F9B9F)
{
a += 1
if (Array%a% = 0x9E9C99)
{
a += 1
if (Array%a% = 0x9D9EA1)
{
a += 4
if (Array%a% = 0x8F9593)
hero = EarthShaker
else if (Array%a% = 0x8F9694)
hero = Slayer
else if (Array%a% = 0x909594)
hero = Undying
else 
Checkhero()
}
else if (Array%a% = 0x9A9A9D)
hero = Goblin Techies
else if (Array%a% = 0x9A9E9C)
hero = Syllabear
else 
Checkhero()
}
else if (Array%a% = 0x9E9F99)
hero = Witch Doctor
else if (Array%a% = 0x9C9D9F)
hero = Magnataur
else 
Checkhero()
}
else if (Array%a% = 0xA19C9D)
hero = Stealth Assassin
else if (Array%a% = 0x9B9F9D)
hero = Silencer
else if (Array%a% = 0xA0A3A0)
hero = Treant Protector
else if (Array%a% = 0x8F7F7F)
hero = Enigma
else if (Array%a% = 0x9B9BA0)
{
a += 1
if (Array%a% = 0x9E9F99)
hero = Keeper of the Light
else if (Array%a% = 0x9C9F9D)
hero = Admiral
else
Checkhero()
}
else if (Array%a% = 0x949D9B)
hero = Ursa Warrior
else if (Array%a% = 0x9DA1A3)
hero = Tinker
else if (Array%a% = 0x9E9D9B)
hero = Furion
else if (Array%a% = 0xB7B0A6)
hero = Phantom Lancer
else if (Array%a% = 0x9B999F)
hero = Stone Giant
else if (Array%a% = 0xA09CA0)
{
a += 1
if (Array%a% = 0x9B9D9D)
hero = Holy Knight
else if (Array%a% = 0x9A9EA0)
hero = Netherdrake
else
Checkhero()
}
else if (Array%a% = 0x989EA4)
hero = Beastmaster
else if (Array%a% = 0x9D9FA4)
{
a += 1
if (Array%a% = 0x999F9F)
hero = Twin Headed Dragon
else if (Array%a% = 0x999E9D)
hero = Night Stalker
else
Checkhero()
}
else if (Array%a% = 0x9F9FA4)
{
a += 1
if (Array%a% = 0x9C9C9B)
hero = Alchemist
else if (Array%a% = 0x9CA09D)
hero = Shadow Priest
else
Checkhero()
}
else if (Array%a% = 0x9EA7A7)
hero = Priestess of the Moon
else if (Array%a% = 0xA8A1A8)
hero = Storm Spirit
else if (Array%a% = 0x989BA0)
{
a += 1
if (Array%a% = 0xA09D9E)
hero = Sacred Warrior
else if (Array%a% = 0x9B9EA0)
hero = Venomancer
else
Checkhero()
}
else if (Array%a% = 0x979EA3)
hero = Fairy Dragon
else if (Array%a% = 0x9B9F9B)
hero = Clockwerk Goblin
else if (Array%a% = 0x9FA39F)
hero = Windrunner
else if (Array%a% = 0x9D979B)
hero = Medusa
else if (Array%a% = 0x979C9B)
hero = Skeleton King
else if (Array%a% = 0xA19D9B)
hero = Nerubian Assassin
else if (Array%a% = 0xA19B9F)
hero = Slarder
else if (Array%a% = 0x9F9BA4)
{
a += 1
if (Array%a% = 0x9C9D9D)
{
a += 1
if (Array%a% = 0x9E9E9E)
hero = Queen of Pain
else if (Array%a% = 0xA09E9E)
hero = TideHunter
else
{
a = 0
Checkhero()
}
}
else if (Array%a% = 0x9C9D9B)
hero = Lycanthrope
else
Checkhero()
}
else if (Array%a% = 0x9D9F9B)
hero = Bone Fletcher
else if (Array%a% = 0x9FA09B)
hero = Lifestealer
else if (Array%a% = 0x97A0A4)
hero = Terrorblade
else if (Array%a% = 0x9B9B9F)
hero = Tormented Soul
else if (Array%a% = 0x9BA3A4)
hero = Lich
else if (Array%a% = 0x979FA2)
hero = Death Prophet
else if (Array%a% = 0xA8A8B1)
hero = Demon Witch
else if (Array%a% = 0x989FA0)
hero = Necro'lic
else if (Array%a% = 0x9D9FA3)
hero = Chaos Knight
else if (Array%a% = 0x9F9FA0)
hero = Broodmother
else if (Array%a% = 0x9B9D9F)
hero = Phantom Assassin
else if (Array%a% = 0xC0A1A9)
hero = Oblivion
else if (Array%a% = 0xA49D9B)
hero = Bane Elemental
else if (Array%a% = 0x9B9FA7)
hero = Necrolyte
else if (Array%a% = 0x999AA0)
hero = Butcher
else if (Array%a% = 0x999297)
hero = Spiritbreaker
else if (Array%a% = 0xA0A4A3)
hero = Sand King
else if (Array%a% = 0x979E9F)
hero = Axe
else if (Array%a% = 0x999EA1)
hero = Bloodseeker
else if (Array%a% = 0x98A4A0)
hero = Lord of Avernus
else if (Array%a% = 0xA0A89B)
hero = Warlock
else if (Array%a% = 0x9A9F9E)
hero = Geomancer
else if (Array%a% = 0x9B9E9E)
hero = Invoker
else if (Array%a% = 0x989D97)
hero = Batrider
else if (Array%a% = 0x9B9B98)
hero = Tauren Cheiftan
else
Checkhero()
}