Post by TinyTerror on Oct 10, 2004 19:20:11 GMT -5
In most AutoIT FFXI scripts, there are really only a few AutoIT commands that are used. These commands are Sleep, PixelGetColor, and Send. With these 3 commands, you can do just about anything from within your script. This are by no means the only commands you should use, but they are a good place to start.
SLEEP
The sleep command is pretty much self explanitory. It takes a single argument; the number of miliseconds you want to pause the script for. Calling Sleep(3000) will cause your script to stop and wait three seconds before running the next command. This is very usefull for situations where you know a spell or an ability takes a certain amount of time to cast, and need your script to wait for the spell to complete before continuing. Here is an example of how to use this command:
Send("Spell X in 10 seconds! {ENTER}")
Sleep(10000)
Send("Casting spell X! {ENTER}")
The second Send line will run 10 seconds after the first one. While your script is sleeping, it uses virtually no CPU power. This is a good thing to use if you want to slow down a loop to consume less CPU time.
PIXELGETCOLOR
This is another simple command. It is used to get the color number of the pixel at (x,y) on screen. It takes the x and y coordinates as its arguments, and returns an integer representing the color of the target pixel. This is used primarily to "look" at parts of the screen for certain text or graphics. For example, if a certain line of text in the chat log is known to have 5 or 6 pixels of a certain color in specific pixel positions, you can see if that line of text exists by checking the pixels for the target color. If all of the pixels are the right color, then there is a good chance that the line of text is in the chat log. This also works for target boxes, icons, and anything graphical on screen. Keep in mind that this method is highly resolution independent, and should be used only with a non transparent background menu style. Here is an example of how PixelGetColor works:
$MyPixelColor=PixelGetColor($x,$y);
$MyPixelColor will now contain an integer that is the unique color number for the color at (x,y) on the screen.
SEND
Send is the AutoIT function for simulating keystrokes on the keyboard. It takes a single string as its argument. This string is then typed out on the keyboard as if the user hit the keys. Send has the ability to send ALT and CTRL button combos needed to trigger FFXI macros, something that many scripts make use of. Here is how it works:
Send("This is a test {ENTER}")
This command will type in "This is a test" without the quotes on the keyboard. The {ENTER} after the string is the special command that tells AutoIT to press enter. If you want to use CTRL and ALT button combos, this is how you would do it:
Send("!1")
Send("^2")
The first line presses ALT+1 and the second line presses CTRL+2. Preceding any character with an ! causes that character to be pressed while ALT is held down. For CTRL, the ^ character is used. Send is a powerful function with many uses. The complete listing of special characters and behaviors of this function are listed at the following link:
www.autoitscript.com/autoit3/docs/functions/Send.htm
SLEEP
The sleep command is pretty much self explanitory. It takes a single argument; the number of miliseconds you want to pause the script for. Calling Sleep(3000) will cause your script to stop and wait three seconds before running the next command. This is very usefull for situations where you know a spell or an ability takes a certain amount of time to cast, and need your script to wait for the spell to complete before continuing. Here is an example of how to use this command:
Send("Spell X in 10 seconds! {ENTER}")
Sleep(10000)
Send("Casting spell X! {ENTER}")
The second Send line will run 10 seconds after the first one. While your script is sleeping, it uses virtually no CPU power. This is a good thing to use if you want to slow down a loop to consume less CPU time.
PIXELGETCOLOR
This is another simple command. It is used to get the color number of the pixel at (x,y) on screen. It takes the x and y coordinates as its arguments, and returns an integer representing the color of the target pixel. This is used primarily to "look" at parts of the screen for certain text or graphics. For example, if a certain line of text in the chat log is known to have 5 or 6 pixels of a certain color in specific pixel positions, you can see if that line of text exists by checking the pixels for the target color. If all of the pixels are the right color, then there is a good chance that the line of text is in the chat log. This also works for target boxes, icons, and anything graphical on screen. Keep in mind that this method is highly resolution independent, and should be used only with a non transparent background menu style. Here is an example of how PixelGetColor works:
$MyPixelColor=PixelGetColor($x,$y);
$MyPixelColor will now contain an integer that is the unique color number for the color at (x,y) on the screen.
SEND
Send is the AutoIT function for simulating keystrokes on the keyboard. It takes a single string as its argument. This string is then typed out on the keyboard as if the user hit the keys. Send has the ability to send ALT and CTRL button combos needed to trigger FFXI macros, something that many scripts make use of. Here is how it works:
Send("This is a test {ENTER}")
This command will type in "This is a test" without the quotes on the keyboard. The {ENTER} after the string is the special command that tells AutoIT to press enter. If you want to use CTRL and ALT button combos, this is how you would do it:
Send("!1")
Send("^2")
The first line presses ALT+1 and the second line presses CTRL+2. Preceding any character with an ! causes that character to be pressed while ALT is held down. For CTRL, the ^ character is used. Send is a powerful function with many uses. The complete listing of special characters and behaviors of this function are listed at the following link:
www.autoitscript.com/autoit3/docs/functions/Send.htm