Now you will need to create a second AHK script for your rotation. Create a script and name it whatever you find appropriate. Open the file with the "Edit Script" method, and then go to the second file of my GitHub repository at
[Only registered and activated users can see links. Click Here To Register...] and copy the script into your own file. This is the template that I have used for every rotation script I have ever made. It may look complicated, but it's really not.
To explain what is happening in this template, I will go through the important parts line by line:
First, we will look at Line 8:
Code:
#ifWinActive World of Warcraft
This line tells our rotation script to only run when WoW is actively running and in focus. So, for example, if you switch to Chrome while the script is running, it won't try to press any keys in Chrome.
Next, we will look at Lines 10 and 11:
Code:
$2::
While GetKeyState("2","p"){
Here, you will need to specify which key on your keyboard will start the rotation script. As long as you press this key, the script will do the rotation for you. In my case, it is the key "2". This means that whenever I am in WoW and press the number 2 and keep pressing it, the script will start the rotation. You can change this to whatever key you prefer. You can use any key in your action bar, as pressing that key won't actually cast the spell bound to that keybind because the script will prevent the key from being registered by WoW unless it presses it itself. Remember to change both Line 10 and 11 to your preferred hotkey. For example, if you want to change from "2" to the key "t" on your keyboard, the lines should look like this:
Code:
$t::
While GetKeyState("t","p"){
Don't change the "p" in Line 11. This is a function command that will ensure the rotation script keeps running as long as we keep pressing the specified hotkey. The "p" in this case means "pressed." So you could also read the line as "While the key "t" on your keyboard is pressed, do whatever follows in the subsequent lines."
Now we can finally put our rotation together. Lines 12 to 17 will be our template for one spell. Here is a breakdown of the meaning of each line and how to customize it for your needs:
Line 12:
Code:
PixelGetColor, color, 2498, 396,
This line starts the PixelGetColor function of AHK. The only important part here is the numbers, which represent the X and Y coordinates of a specific pixel on your monitor. In this case, 2498 is the X value and 396 is the Y value of the pixel that we want to check. You will only want to change these numbers and leave the rest as is. The Pixeltool will give you the color as a BGR value. You could read this line as "Using the PixelGetColor function, check the pixel at position (x, y) on your monitor and read its BGR value."
Line 13:
Code:
If (color = 0x37376B){
In this line, we will check if the BGR value of the pixel at the coordinates (2498, 396) is equal to the value "0x37376B". If this check evaluates to true, then the script will execute the code block enclosed in the curly braces "{}". Essentially, the line can be read as "If the color found at the specified coordinates is the same as the one specified, then perform the actions within the curly braces."
Line 15:
In this line, we specify which button the script should press if the color value found matches the one we are searching for. For example, if we are searching for a pixel in the spell icon of a "Firebolt" on the Action bar in World of Warcraft (WoW), and we want the script to press the button corresponding to the "Firebolt" spell, we would specify the key "6" on the Action bar. If we want to press hotkeys with modifiers, such as a spell macro "/cast [mod:shift] SomeSpellhere," we can add additional keys to the line. For example, if we want the script to press the shift and 6 keys at the same time, the line would be modified to:
Code:
Send, {Shift down}{6}{Shift up}
You can check the official AHK websites for all the possible key combinations.
Line 16:
This line simply tells the script to wait 20 milliseconds before executing the next instruction. We want to always do this after pressing keys. Otherwise, the commands get executed too fast and it's also not good for performance.
Line 17:
This line simply closes the "if" statement of Line 13. That means specifically that if the pixel value found was not the one we specified in line 13, it would immediately jump to line 18.