I just wrote my first code and it works wonderfully in the foreground. I was wondering how would I be able to have it run in the background so that I would still be able to do other things on my computer. Below is the code I created.
Code: Select all
#NoEnv
SetWorkingDir %A_ScriptDir%
CoordMode, Mouse, Window
SendMode Input
#SingleInstance Force
SetTitleMatchMode, 2
#WinActivateForce
SetControlDelay, 1
SetWinDelay, 0
SetKeyDelay, -1
SetMouseDelay, 1
SetBatchLines, -1
; Open a lobby for game with mode first.
Loop
{
WinActivate, StarCraft II ahk_class StarCraft II
d := 0
;Sleep, 15000
Click, 208, 876, 0 ; start game
Sleep, 15
Click, 208, 876 Left, Down
Sleep, 15
Click, 208, 876 Left, Up
Sleep, 40000 ; wait for game to load
Click, 480, 65, 0 ; Hide hero list
Sleep, 15
Click, 480, 65 Left, Down
Sleep, 15
Click, 480, 65 Left, Up
Send {Enter} ; selects Toyia Hero
Sleep 100
Send {-}
Sleep 100
Send {T}
Sleep 100
Send {O}
Sleep 100
Send {Y}
Sleep 100
Send {I}
Sleep 100
Send {A}
Sleep 100
Send {Enter}
Sleep 2000
Send {F2}
Sleep, 150
;Spam Extinction
While d < 80
{
Send {W}
d += 1
Sleep 5000
}
Send {F10} ; open game menu
Sleep, 50
Click, 960, 387, 0 ; quit game
Sleep, 15
Click, 960, 387 Left, Down
Sleep, 15
Click, 960, 387 Left, Up
Sleep, 8000
Click, 422, 869, 0 ; play again
Sleep, 15
Click, 422, 869 Left, Down
Sleep, 15
Click, 422, 869 Left, Up
Sleep, 13000 ; wait to restart
}