Skip to content

Instantly share code, notes, and snippets.

@BenjaminAdams
Last active November 20, 2017 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenjaminAdams/a2ab186d9e928c6d1900f0b8870914f6 to your computer and use it in GitHub Desktop.
Save BenjaminAdams/a2ab186d9e928c6d1900f0b8870914f6 to your computer and use it in GitHub Desktop.
Final Fantasy Record Keeper Auto macro for Shinras Finest event
#NoEnv
SetWorkingDir %A_ScriptDir%
;Sets the working directory to be where the script is located.
CoordMode, Mouse, Window
;Lets the finding of X and Y to be determined by the mouse's coordinates on the functions below.
SendMode Input
#SingleInstance Force
SetTitleMatchMode 2
#WinActivateForce
SetControlDelay 1
SetWinDelay 0
SetKeyDelay -1
SetMouseDelay -1
SetBatchLines -1
F1::
;Press F1 to start your macro.
Macro1:
CoordMode, Pixel, Window
WinActivate, NoxPlayer ahk_class Qt5QWindowIcon
Sleep, 350
Loop
{
mainloopstart:
FoundX := 0
FoundY := 0
ConfirmPixel(FoundX, FoundY, 1723, 743, "0x0D270F", 10, "Fast")
If ErrorLevel >= 1
return
;Finds the color "0x0D2910" within the square that starts from X:374 Y:478 to X:374 Y:478,
;with 10 shade color variation,
;and then saves the resulting pixel to FoundX and FoundY.
;This is done to ensure that the screen has changed and confirm the color you passed exist within
;this pixel at this particular time.
;If the color is not found, the error count will be incremented to 1, resulting in the confirmation to re-run.
;It takes into account any possible lag so it won't proceed until the correct screen is confirmed.
;This check is for the Green Shinra's finest event box.
;The rest of the script follows the same logic. Optimize as you see fit.
;The ConfirmPixel function is defined down below.
Sleep, 300
Click, 1723, 743 Left, 1
Sleep, 300
;Left Mouse clicks on the Shinra Finest event button.
ConfirmPixel(FoundX, FoundY, 2006, 1662, "0xDF6A21", 10, "Fast")
If ErrorLevel >= 1
return
;This check is for the Blue Enter Dungeon button.
Sleep, 300
Click, %FoundX%, %FoundY% Left, 1
Sleep, 300
;Clicks the Enter Dungeon button.
ConfirmPixel(FoundX, FoundY, 1808, 1779, "0xF7961D", 10, "Fast")
If ErrorLevel >= 1
return
;This check is for the Next on the Party Select screen button.
Sleep, 1100
Click, %FoundX%, %FoundY% Left, 1
Sleep, 300
;Clicks the Next button.
;ConfirmPixel(FoundX, FoundY, 1808, 1779, "0xF7961D", 10, "Fast")
;If ErrorLevel >= 1
; return
;This check is for the GO! button in the RW select screen.
Sleep, 2000
Click, 1808, 1779 Left, 1
Sleep, 1000
;Clicks the GO! button.
ConfirmPixel(FoundX, FoundY, 1497, 908, "0xB49181", 10, "Fast")
If ErrorLevel >= 1
return
;This check is for the white edges of the boss platform button.
Click, 1688, 939 Left, 1
Sleep, 350
;This check is for the begin battle button.
ConfirmPixel(FoundX, FoundY, 2006, 1373, "0xf08018", 30, "Fast")
If ErrorLevel >= 1
return
Sleep, 450
Click, 2009, 1360 Left, 1
Sleep, 250
WorthyBoss := 0
Loop
{
battleloop:
PixelSearch, FoundX, FoundY, 1495, 1376, 1495, 1376, 0xEE8318, 5, Fast
If ErrorLevel = 0
{
Goto, resultsloop
}
;Checks if the fight has ended and you are in the champion screen.
;If it is, it will click and check whether it should return to the beginning of the loop.
;click magicite
PixelSearch, FoundX, FoundY, 1985, 1421, 1985, 1421, 0xFFFFFF, 10, Fast
If ErrorLevel = 0
{
Click, 1985, 1421 Left, 1
}
;google play login errors
PixelSearch, FoundX, FoundY, 1544, 1224, 1544, 1224, 0xF5F5F5, 10, Fast
If ErrorLevel = 0
{
Click, 1544, 1244 Left, 2
}
If ErrorLevel >= 1
PixelSearch, FoundX, FoundY, 1998, 1722, 1998, 1722, 0xF8F6F6, 10, Fast
;Checks if your turn available by ensuring the 2nd ability slot includes the color white that is on the outer ring of the ability.
If ErrorLevel = 0
{
;If the turn is available..
PixelSearch, FoundX, FoundY, 1619, 1742, 1619, 1742, 0xCD6137, 10, Fast
;Checks if the CMD2 is blue colored for attack/defend, meaning burst mode is inactive
If ErrorLevel = 0
;If it is blue..
{
Click, 2348, 1750 Left, 1
;Click the BSB button
Sleep, 300
Goto, battleloop
;Left click on bsb. Repeat the loop.
}
Else If ErrorLevel >= 1
;If it is not blue, meaning the cmd2 exists..
;PixelSearch, FoundX, FoundY, 1725, 654, 1725, 654, 0x78793A, 10, Fast
;Check 2nd boss
;If ErrorLevel = 0
;{
; WorthyBoss += 1
;}
PixelSearch, FoundX, FoundY, 1633, 971, 1633, 971, 0x78793A, 10, Fast
;Check boss with 4 red legs
If ErrorLevel = 0
{
WorthyBoss += 1
}
PixelSearch, FoundX, FoundY, 1544, 946, 1544, 946, 0x2334B6, 50, Fast
;Check Guard Scorpion
If ErrorLevel = 0
{
WorthyBoss += 1
}
;First we check if it is a worthy boss. There is a static spot on this boss.
;You can add one more counter if you want to do it for the other bosses as well, just have to find a good pixel.
If WorthyBoss > 0
{
;If we confirmed it is this boss..
Click, 1421, 1776 Left, 1
Sleep, 300
WorthyBoss := 0
Goto, battleloop
;Left click on cmd1. Repeat the loop.
}
Else
{
;Otherwise we will use cmd2.
Click, 1619, 1742 Left, 1
Sleep, 300
Goto, battleloop
;Left click on cmd2. Repeat the loop.
}
}
}
resultsloop:
Loop
{
Sleep, 1000
;click bottom next btn
PixelSearch, FoundX, FoundY, 1735, 1770, 1735, 1770, 0xDE641F, 10, Fast
If ErrorLevel = 0
{
Click, 1735, 1770 Left, 2
}
;click ok BTN after orbs
PixelSearch, FoundX, FoundY, 1792, 1546, 1792, 1546, 0xDE641F, 10, Fast
If ErrorLevel = 0
{
Click, 1792, 1546 Left, 2
}
;Checks the shinra screen
PixelSearch, FoundX, FoundY, 1723, 743, 1723, 743, 0x0D270F, 10, Fast
If ErrorLevel = 0
{
Sleep, 2000
Goto, mainloopstart
}
;google play login errors
PixelSearch, FoundX, FoundY, 1544, 1224, 1544, 1224, 0xF5F5F5, 10, Fast
If ErrorLevel = 0
{
Click, 1544, 1244 Left, 2
}
}
}
Return
F2::ExitApp
F3::Pause
ConfirmImage(byRef Out1, byRef Out2, X1, Y1, X2, Y2, ImageFile)
{
CoordMode, Pixel, Window
myImg = %A_ScriptDir%\img\%ImageFile%
Loop, 3000
{
ImageSearch, Out1, Out2, X1, Y1, X2, Y2, %myImg%
; MsgBox, 1,, %ErrorLevel% %ImageFile%
CenterImgSrchCoords(myImg, Out1, Out2)
If ErrorLevel = 0
Break
Sleep, 100
}
; MsgBox, 1,, %Out1% %Out2%
}
ConfirmPixel(byRef Out1, byRef Out2, X1, Y1, color, tol, opt)
{
Loop, 3000
{
PixelSearch, Out1, Out2, X1, Y1, X1, Y1, %color%, tol, %opt%
if ErrorLevel = 0
Break
Sleep, 100
}
}
CenterImgSrchCoords(File, ByRef CoordX, ByRef CoordY)
{
static LoadedPic
LastEL := ErrorLevel
Gui, Add, Pic, vLoadedPic, %File%
GuiControlGet, LoadedPic, Pos
Gui, Destroy
CoordX += LoadedPicW // 2
CoordY += LoadedPicH // 2
ErrorLevel := LastEL
}
;Last edited by /u/richiealvian. Thanks /u/spirialis!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment