OK, thanks. I moved the Settimer command before the loop, and it makes it run but it doesn't detect the image when I'm on the game's chatscreen. It shows "The program didn't work" on the tooltip so I guess there's something wrong with the image. It's a simple 68x48 .PNG file which I put in the root of my C: drive to minimize the likehihood of this happening.
Code: Select all
#Persistent
SetTitleMatchMode, 3
GroupAdd, WinGroup, Heroes of Might and Magic III
GroupAdd, WinGroup, Heroes of Might and Magic III: Horn of the Abyss
#IfWinActive ahk_group WinGroup
; DISABLE CHAT WHEN ON CHAT SCREEN
; -------------------------------------------------------------------
SetTimer, Checkchat, 100
Return
Checkchat:
ImageSearch, OutputVarX, OutputVarY, 1702, 940, 1911, 1068, C:/arrow.png *50
if ErrorLevel = 2
Tooltip, The program didn't work
Else if ErrorLevel = 1
Tooltip Icon could not be found on the screen.
Else
;CoordMode, Pixel, Window
;PixelGetColor, thepixel, 1838, 34
;If thepixel = A69648
{
Tooltip, Icon was found on the screen.
Suspend, on
}
Return
; MOVE CURSOR TO CENTRE OF SCREEN WHEN ACTIVATING WINDOW
; -------------------------------------------------------------------
Loop
{
WinWaitActive, ahk_group WinGroup
{
MouseMove, 1033, 500
}
WinWaitNotActive, ahk_group WinGroup
}
; ENABLE AND DISABLE SCRIPT WHEN CHATTING AND SAVING
; -------------------------------------------------------------------
^d::
SendInput, s
Suspend, on
Return
Tab::
SendInput, {Tab}
Suspend, on
Return
Enter::
Suspend, off
Sendinput, {Enter}
Return
NumpadEnter::
Suspend, off
Sendinput, {Enter}
Return
; MISC HOTKEYS
; -------------------------------------------------------------------
XButton1::Escape
MButton::Enter
q::h
e::t
f::e
z::d
`::q
^d::s
^c::l
x::z
X::w
C::i
r::u
; Auto attack in combat
+d::
{
MouseGetPos, OrigX, OrigY
MouseClick, Left, 603, 974
MouseMove, OrigX, OrigY
Return
}
; 1-8 HERO HOTKEYS
; -------------------------------------------------------------------
1::
{
MouseGetPos, OrigX, OrigY
MouseClick, Left, 1659, 343
MouseMove, OrigX, OrigY
Return
}
2::
{
MouseGetPos, OrigX, OrigY
MouseClick, Left, 1659, 395
MouseMove, OrigX, OrigY
Return
}
3::
{
MouseGetPos, OrigX, OrigY
MouseClick, Left, 1659, 450
MouseMove, OrigX, OrigY
Return
}
4::
{
MouseGetPos, OrigX, OrigY
MouseClick, Left, 1659, 500
MouseMove, OrigX, OrigY
Return
}
5::
{
MouseGetPos, OrigX, OrigY
MouseClick, Left, 1659, 550
MouseMove, OrigX, OrigY
Return
}
6::
{
MouseGetPos, OrigX, OrigY
MouseClick, Left, 1659, 600
MouseMove, OrigX, OrigY
Return
}
7::
{
MouseGetPos, OrigX, OrigY
MouseClick, Left, 1659, 650
MouseMove, OrigX, OrigY
Return
}
8::
{
MouseGetPos, OrigX, OrigY
MouseClick, Left, 1659, 700
MouseMove, OrigX, OrigY
Return
}
; WASD MAP SCROLLING
; -------------------------------------------------------------------
~s & a::
MouseGetPos, OrigX, OrigY
While GetKeyState("s","P") && GetKeyState("a","P")
{
MouseMove, 0, 1079
}
MouseMove, OrigX, OrigY
~a & s::
MouseGetPos, OrigX, OrigY
While GetKeyState("a","P") && GetKeyState("s","P")
{
MouseMove, 0, 1079
}
MouseMove, OrigX, OrigY
~a & w::
MouseGetPos, OrigX, OrigY
While GetKeyState("a","P") && GetKeyState("w","P")
{
MouseMove, 0, 0
}
MouseMove, OrigX, OrigY
~w & a::
MouseGetPos, OrigX, OrigY
While GetKeyState("w","P") && GetKeyState("a","P")
{
MouseMove, 0, 0
}
MouseMove, OrigX, OrigY
a::
While GetKeyState("a","P")
{
Send, ^{Left}
Sleep, 50
}
~w & d::
MouseGetPos, OrigX, OrigY
While GetKeyState("w","P") && GetKeyState("d","P")
{
MouseMove, 1919, 0
}
MouseMove, OrigX, OrigY
w::
While GetKeyState("w","P")
{
Send, ^{Up}
Sleep, 50
}
~d & w::
MouseGetPos, OrigX, OrigY
While GetKeyState("d","P") && GetKeyState("w","P")
{
MouseMove, 1919, 0
}
MouseMove, OrigX, OrigY
s::
While GetKeyState("s","P")
{
Send, ^{Down}
Sleep, 50
}
~d & s::
MouseGetPos, OrigX, OrigY
While GetKeyState("d","P") && GetKeyState("s","P")
{
MouseMove, 1919, 1079
}
MouseMove, OrigX, OrigY
~s & d::
MouseGetPos, OrigX, OrigY
While GetKeyState("s","P") && GetKeyState("d","P")
{
MouseMove, 1919, 1079
}
MouseMove, OrigX, OrigY
d::
While GetKeyState("d","P")
{
Send, ^{Right}
Sleep, 50
}