Hi!
I was working on a bot for a game i use to play. All it has to do is check a screen pixel at (218, 60) and if its black press a few key.
So i used the Robot class to make the keyPress and getScreenPixle. If the pixel is black then press 1 in a loop untill the pixel is a different color.
Now this works when i run the program and have a notepad up, if the pixel is black i goet "11111111111...." in the notepad but soon as i swap to the game window press1() is executed once and then stops.
However if i press enter ingame it opens the ingame chat and i get 111111 in the gamechat but soon as i get out of chat nothing is happening although skill with hotkey 1 be pressed in a loop.
Here is the code:
import java.awt.AWTException; import java.awt.Color; import java.awt.Robot; import java.awt.Window; public class KayListener { static Robot r ; public static void main(String[] args) throws AWTException{ r = new Robot(); Color c1; Color c2; c1 = r.getPixelColor(20, 20); c2 = new Color(0,0,0); while(true){ c1 = r.getPixelColor(218, 60); if(c1.equals(c2)){ press1(); } } } public static void press1(){ r.keyPress(49); } }