Java and a text editor
Java IDE![]()
Biting my elbows with zero java knowledge while trying to get hotkey to work.
Found out about jnativehook, managed to hook itself working but for some reason I can't call moveMouse() using "if (e.getKeyCode() == NativeKeyEvent.VC_K)".
I mean I can but calling it from inside or changing boolean doesn't works.
Private Paste - Pastie
Use a timer
@comic-1337 Where do I change the colors so it doesn't aim at random shit.
im using hold left alt to activate aimbot try this
Code:import org.jnativehook.GlobalScreen; import org.jnativehook.NativeHookException; import org.jnativehook.keyboard.NativeKeyEvent; import org.jnativehook.keyboard.NativeKeyListener; import java.util.logging.Level; import java.util.logging.Logger; import java.util.logging.LogManager; public class OWAimbot implements NativeKeyListener { private static Robot robot; private static Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); private static double width = screenSize.getWidth(); private static double height = screenSize.getHeight(); . . . private static Boolean hold = false; public void nativeKeyPressed(NativeKeyEvent e) { if (NativeKeyEvent.getKeyText(e.getKeyCode()) == "Left Alt") hold = true; } public void nativeKeyReleased(NativeKeyEvent e) { if (NativeKeyEvent.getKeyText(e.getKeyCode()) == "Left Alt") hold = false; } public void nativeKeyTyped(NativeKeyEvent e) {} . . . public static void main(String[] args) throws Exception { LogManager.getLogManager().reset(); Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName()); logger.setLevel(Level.OFF); try { GlobalScreen.registerNativeHook(); } catch (NativeHookException ex) { System.err.println("There was a problem registering the native hook."); System.err.println(ex.getMessage()); System.exit(1); } robot = new Robot(); OWAimbot listen = new OWAimbot(); while(true){ GlobalScreen.addNativeKeyListener(listen); if(hold){ moveMouse(analysis(ss())[0],analysis(ss())[1]); } } }
Last edited by Snowbot; 07-30-2016 at 02:42 AM.
Thanks, works smoother than my workaround I've had earlier, but it also has issues (maybe I'm doing smth wrong, not sure).
When you hold alt key for too long it forgets to stop aiming.
Longer you hold then longer it takes to understand that you've released key.
EDIT: Nvm, my windows is drunk, and even with AHK it reacts badly to Left Alt being held.
Last edited by qqzzxxcc; 07-30-2016 at 04:21 AM.
Need a bit of help figuring out what I'm doing wrong.
The first 4 lines it says the package does not exist, On line 9 it says duplicate class, On lines 14 and 31 it says illegal start of type and on the last line it says reached end of file while parsing but shows a red marker. Can someone please tell me What's wrong and how I can fix it?
Thats not whole code, thats a snippet for hotkey function.
I got illegal start of statement can someone help me ? heres the code
import java.awt.*;
import java.awt.image.BufferedImage;
import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;
import org.jnativehook.keyboard.NativeKeyEvent;
import org.jnativehook.keyboard.NativeKeyListener;
public class test implements NativeKeyListener{
private static Robot robot;
private static Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
private static double width = 1920;
private static double height = 1080;
private static BufferedImage img =null;
private static int red = 0;
private static int green = 0;
private static int blue = 0;
private static int rgb = 0;
private static Boolean on=false;
private static Boolean appended=false;
private static int globalOffsetX,globalOffsetY;
private static final int SEARCH_WIDTH = 490;
private static final int SEARCH_HEIGHT = 390;
public static void main(String[] args) throws Exception {
try {
GlobalScreen.registerNativeHook();
}
catch (NativeHookException ex) {
System.err.println("There was a problem registering the native hook.");
System.exit(1);
}
GlobalScreen.addNativeKeyListener(new test());
robot = new Robot();
if (on){
moveMouse(analysis(ss())[0],analysis(ss())[1]);
}
}
public void nativeKeyPressed(NativeKeyEvent e) {
if (e.getKeyCode() == NativeKeyEvent.VC_K) {
on=true;
try {
moveMouse(analysis(ss())[0],analysis(ss())[1]);
}
catch (Exception ex) {
System.exit(1);
}
}
}
public void nativeKeyReleased(NativeKeyEvent e) {
if (e.getKeyCode() == NativeKeyEvent.VC_K) {
on=false;
System.out.println("Key Released: " + NativeKeyEvent.getKeyText(e.getKeyCode())== "Left Alt");
}
}
public void nativeKeyTyped(NativeKeyEvent e) {
if (NativeKeyEvent.getKeyText(e.getKeyCode()) == "Left Alt")
}
private static void moveMouse(double x, double y){
if(appended){
robot.mouseMove((int)((width/2)+x+50),(int) ((height/2)+y+33));
}
}
private static BufferedImage ss(){
return robot.createScreenCapture(new Rectangle((int)(width/2)-245,(int)(height/2)-245, SEARCH_WIDTH,SEARCH_HEIGHT));
}
private static double[] analysis(BufferedImage iA) throws Exception{
appended = false;
for (int x = 0; x< iA.getWidth(); x ++) {
for(int y = 0; y < iA.getHeight(); y ++) {
rgb = iA.getRGB(x, y);
red = (rgb >> 16) & 0x000000FF;
green = (rgb >> 8 ) & 0x000000FF;
blue = (rgb) & 0x000000FF;
if(red>=251&&green<=3&&blue<=1{
if(!appended){
appended=true;
globalOffsetX = x-(SEARCH_WIDTH/2);
globalOffsetY = y-(SEARCH_HEIGHT/2);//145
}
}
if(appended)
break;
}
if(appended)
break;
}
return new double[]{globalOffsetX,globalOffsetY};
}
}
Man.. do not spoonfeed those people, I've given enough hints here.