lordliquid
Joined: 29 Jul 2009 Posts: 8
|
Posted: Wed Jul 29, 2009 6:00 pm Post subject: Problem with an old script.. |
|
|
I run this script with a couple of loops in it, It runs great for a few times sometimes more. Then it will just crash and say "Auto HotKey has stopped working" When I choose to debug it says something about a stack overflow. Which I assume would be caused by the loops, if I am wrong please help me here.
Here is the script if it helps.
| Code: |
SendMode Input
SetWorkingDir %A_ScriptDir%
#NoEnv
#Persistent
Menu, Mainmenu, Add, Melee 1h, Select1
Menu, MainMenu, Add, Melee 2h, Select2
Menu, MainMenu, Add, Rend, Select3
Menu, MainMenu, Add, Archery, Select4
^!r::Pause
^!h::Menu, MainMenu, Show
Select1:
Setup()
1hm()
return
Select2:
Setup()
2hm()
return
Select3:
Setup()
rend()
Select4:
SetupArchery()
archery()
return
Setup()
{
Global
WinGet, darkfallid, List, Darkfall Online
WinActivate, ahk_id %darkfallid1%
MsgBox, 4,, Is this your First window? (press Yes or No)
IfMsgBox Yes
idFirst = %darkfallid1%
else
idFirst = %darkfallid2%
If idFirst = %darkfallid1%
{
idSecond = %darkfallid2%
} else {
idSecond = %darkfallid1%
}
WinActivate, ahk_id %idFirst%
WinActivate, ahk_id %idSecond%
}
SetupArchery()
{
Global
WinGet, darkfallid, List, Darkfall Online
WinActivate, ahk_id %darkfallid1%
MsgBox, 4, , Is this the shooter?
IfMsgBox, Yes
{
idTarget = %darkfallid2%
idShooter = %darkfallid1%
}
else
{
idShooter = %darkfallid2%
idTarget = %darkfallid1%
}
WinActivate, ahk_id %idShooter%
WinActivate, ahk_id %idTarget%
}
1hm(){
Loop
{
Sleep, 1000
SwapDual(1,5)
Arm(1)
Arm(2)
AttackMeleeRotate(18,18,500)
Disarm(1)
Disarm(2)
Rest()
SwapDual(2,6)
Arm(1)
Arm(2)
AttackMeleeRotate(18,18,500)
Disarm(1)
Disarm(2)
Rest()
SwapDual(3,7)
Arm(1)
Arm(2)
AttackMeleeRotate(18,18,500)
Disarm(1)
Disarm(2)
Rest()
SwapDual(4,8)
Arm(1)
Arm(2)
AttackMeleeRotate(18,18,500)
Disarm(1)
Disarm(2)
Rest()
}
}
2hm(){
Loop
{
Sleep, 1000
SwapSingle(1)
Arm(1)
Arm(2)
AttackMeleeRotate(8,4,1500)
Disarm(1)
Disarm(2)
Rest()
SwapSingle(2)
Arm(1)
Arm(2)
AttackMeleeRotate(8,4,1500)
Disarm(1)
Disarm(2)
Rest()
SwapSingle(1)
Arm(1)
Arm(2)
AttackMeleeRotate(8,4,1500)
Disarm(1)
Disarm(2)
Rest()
SwapSingle(2)
Arm(1)
Arm(2)
AttackMeleeRotate(8,4,1500)
Disarm(1)
Disarm(2)
Rest()
}
}
rend(){
Loop
{
Sleep, 1000
SwapAlternate(5,6,1,1)
Arm(1)
Arm(2)
AttackAltMagic(1)
;SwapAlternate(5,6,1,2)
;AttackAltMagic(2)
Disarm(1)
;Disarm(2)
Rest()
SwapAlternate(5,6,2,1)
Arm(1)
Arm(2)
AttackAltMagic(1)
;SwapAlternate(5,6,2,2)
;AttackAltMagic(2)
Disarm(1)
;Disarm(2)
Rest()
SwapAlternate(5,6,3,1)
Arm(1)
Arm(2)
AttackAltMagic(1)
;SwapAlternate(5,6,3,2)
;AttackAltMagic(2)
Disarm(1)
;Disarm(2)
Rest()
SwapAlternate(5,6,4,1)
Arm(1)
Arm(2)
AttackAltMagic(1)
;SwapAlternate(5,6,4,2)
;AttackAltMagic(2)
Disarm(1)
;Disarm(2)
Rest()
}
}
archery() {
Sleep, 1000
SwapArchery(1)
ArcheryArm()
AttackArchery(200)
Loop
{
Sleep, 1000
SwapArchery(2)
AttackArchery(200)
SwapArchery(3)
AttackArchery(200)
SwapArchery(4)
AttackArchery(200)
SwapArchery(1)
AttackArchery(200)
}
}
AttackArchery(loop1){
global idShooter
global idTarget
Loop, %loop1%
{
WinActivate, ahk_id %idShooter%
Sleep, 2000
Click down
Sleep, 3000
Click up
Send, {r down}
Sleep, 200
Send, {r up}
Sleep, 1000
Send, {r down}
Sleep, 200
Send, {r up}
}
}
AttackMeleeRotate(loop1,loop2,cooldown) {
global idFirst
global idSecond
Loop, %loop1%
{
WinActivate, ahk_id %idFirst%
Sleep, 50
Click
Sleep, %cooldown%
WinActivate, ahk_id %idSecond%
Sleep, 50
Click
Sleep, %cooldown%
}
Loop, %loop2%
{
WinActivate, ahk_id %idFirst%
Sleep, 50
Send, {v down}
Sleep, 1000
Send, {v up}
Sleep, 1000
Click
Sleep, 50
WinActivate, ahk_id %idSecond%
Sleep, 50
Send, {v down}
Sleep, 1000
Send, {v up}
Sleep, 1000
Click
Sleep, 50
}
}
AttackAltMagic(c) {
global idFirst
global idSecond
Loop, 30
{
if (c = 1) {
WinActivate, ahk_id %idFirst%
} else {
WinActivate, ahk_id %idSecond%
}
Sleep, 100
Send, {9}
Sleep, 200
Click
Sleep, 500
if (c = 1) {
WinActivate, ahk_id %idSecond%
} else {
WinActivate, ahk_id %idFirst%
}
Sleep, 500
Send, {v down}
Sleep, 500
Send, {v up}
Sleep, 2000
}
}
Attack() {
global idFirst
global idSecond
Loop, 40
{
Sleep, 5000
WinActivate, ahk_id %idFirst%
Sleep, 100
Send, {1}
Sleep, 1500
Click
Sleep, 100
WinActivate, ahk_id %idSecond%
Sleep, 100
Send, {1}
Sleep, 1500
Click
Sleep, 100
}
}
SwapDual(num1,num2) {
global idFirst
global idSecond
downnum1 := "{" . num1 . " down}"
upnum1 := "{" . num1 . " up}"
downnum2 := "{" . num2 . " down}"
upnum2 := "{" . num2 . " up}"
WinActivate, ahk_id %idFirst%
Sleep, 500
Send, %downnum1%
Sleep, 200
Send, %upnum1%
Sleep, 500
Send, %downnum2%
Sleep, 200
Send, %upnum2%
Sleep, 500
WinActivate, ahk_id %idSecond%
Sleep, 500
Send, %downnum1%
Sleep, 200
Send, %upnum1%
Sleep, 500
Send, %downnum2%
Sleep, 200
Send, %upnum2%
Sleep, 500
}
SwapAlternate(num1,num2,num3,c) {
global idFirst
global idSecond
downnum1 := "{" . num1 . " down}"
upnum1 := "{" . num1 . " up}"
downnum2 := "{" . num2 . " down}"
upnum2 := "{" . num2 . " up}"
downnum3 := "{" . num3 . " down}"
upnum3 := "{" . num3 . " up}"
if (c = 1) {
WinActivate, ahk_id %idFirst%
} else {
WinActivate, ahk_id %idSecond%
}
Sleep, 500
Send, %downnum3%
Sleep, 200
Send, %upnum3%
Sleep, 500
if (c = 1) {
WinActivate, ahk_id %idSecond%
} else {
WinActivate, ahk_id %idFirst%
}
Sleep, 500
Send, %downnum1%
Sleep, 200
Send, %upnum1%
Sleep, 500
Send, %downnum2%
Sleep, 200
Send, %upnum2%
Sleep, 500
}
SwapSingle(num1) {
global idFirst
global idSecond
downnum1 := "{" . num1 . " down}"
upnum1 := "{" . num1 . " up}"
;downnum2 := "{" . num2 . " down}"
;upnum2 := "{" . num2 . " up}"
WinActivate, ahk_id %idFirst%
Sleep, 500
Send, %downnum1%
Sleep, 200
Send, %upnum1%
Sleep, 500
WinActivate, ahk_id %idSecond%
Sleep, 500
Send, %downnum1%
Sleep, 200
Send, %upnum1%
Sleep, 500
}
SwapArchery(num1) {
global idShooter
global idTarget
downnum1 := "{" . num1 . " down}"
upnum1 := "{" . num1 . " up}"
WinActivate, ahk_id %idShooter%
Sleep, 500
Send, %downnum1%
Sleep, 200
Send, %upnum1%
Sleep, 500
}
ArcheryArm(){
global idShooter
global idTarget
WinActivate, ahk_id %idShooter%
Sleep, 500
Send, {r down}
Sleep, 200
Send, {r up}
Sleep, 500
WinActivate, ahk_id %idTarget%
Sleep, 500
Send, {r down}
Sleep, 200
Send, {r up}
Sleep, 500
}
Arm(c) {
global idFirst
global idSecond
if (c = 1) {
WinActivate, ahk_id %idFirst%
} else {
WinActivate, ahk_id %idSecond%
}
sleep, 100
PixelSearch, Px, Py, 16, 436, 34, 456, 0x006E0D, 50, Fast
if !ErrorLevel {
return
}
else
{
Sleep, 500
Send, {r down}
Sleep, 200
Send, {r up}
Sleep, 500
Arm(c)
}
}
Disarm(c) {
global idFirst
global idSecond
if (c = 1) {
WinActivate, ahk_id %idFirst%
} else {
WinActivate, ahk_id %idSecond%
}
sleep, 100
PixelSearch, Px, Py, 16, 436, 34, 456, 0x006E0D, 50, Fast
if !ErrorLevel {
Sleep, 500
Send, {r down}
Sleep, 200
Send, {r up}
Sleep, 500
Disarm(c)
}
else
{
return
}
}
Rest() {
global idFirst
global idSecond
Sleep, 500
WinActivate, ahk_id %idFirst%
Sleep, 1000
;Send, {Space}
;Sleep, 500
Send, {0 down}
Sleep, 200
Send, {0 up}
Sleep, 500
Click
Sleep, 100
WinActivate, ahk_id %idSecond%
Sleep, 500
Send, {0 down}
Sleep, 200
Send, {0 up}
Sleep, 500
Click
Sleep, 100
CheckHighStam(1)
CheckHighstam(2)
CheckHighHealth(1)
CheckHighHealth(2)
CheckHighMana(1)
CheckHighMana(2)
GetUp(1)
Sleep, 100
;Send, {alt down}
;Sleep, 200
;Send, {c down}
;Sleep, 200
;Send, {c up}
;Sleep, 200
;Send, {alt up}
GetUp(2)
}
CheckHighStam(c)
{
global idFirst
global idSecond
if (c = 1) {
WinActivate, ahk_id %idFirst%
} else {
WinActivate, ahk_id %idSecond%
}
Sleep, 100
;Send, {F1}
;Sleep, 500
PixelSearch, Px, Py, 784, 55, 788, 59, 0x28A0CC, 1, Fast
Sleep, 100
;Click
;Sleep, 200
;Send, {F1}
;Sleep, 500
if !ErrorLevel
{
return
}
else
{
Sleep, 5000
CheckHighStam(c)
}
}
CheckHighHealth(c)
{
global idFirst
global idSecond
if (c = 1) {
WinActivate, ahk_id %idFirst%
} else {
WinActivate, ahk_id %idSecond%
}
Sleep, 100
;Send, {F1}
;Sleep, 500
PixelSearch, Px, Py, 784, 49, 788, 53, 0x2828CC, 1, Fast
Sleep, 100
;Click
;Sleep, 200
;Send, {F1}
;Sleep, 500
if !ErrorLevel
{
return
}
else
{
Sleep, 5000
CheckHighHealth(c)
}
}
CheckHighMana(c)
{
global idFirst
global idSecond
if (c = 1) {
WinActivate, ahk_id %idFirst%
} else {
WinActivate, ahk_id %idSecond%
}
Sleep, 100
;Send, {F1}
;Sleep, 500
PixelSearch, Px, Py, 784, 61, 788, 66, 0xCC7850, 1, Fast
Sleep, 100
;Click
;Sleep, 200
;Send, {F1}
;Sleep, 500
if !ErrorLevel
{
return
}
else
{
Sleep, 5000
CheckHighMana(c)
}
}
GetUp(c) {
global idFirst
global idSecond
if (c = 1) {
WinActivate, ahk_id %idFirst%
} else {
WinActivate, ahk_id %idSecond%
}
Sleep, 500
Send, {w}
Sleep, 500
} |
|
|