Jump to content

fiveworlds

Senior Members
  • Posts

    1903
  • Joined

  • Last visited

Everything posted by fiveworlds

  1. It is an infinite loop. public static void function(int x){ int answer = 0; int p = 0; while(true){ if(p%2 == 0}{ ​ answer = answer + java.lang.Math.pow((x/2),​2p)/java.lang.Math.pow(factorial(p),2) system.out.println(answer); } else{ answer = answer - java.lang.Math.pow((x/2),​2p)/java.lang.Math.pow(factorial(p),2) ​​ system.out.println(answer); } } } public static int factorial(int n) { int result = 1; for (int i = 1; i <= n; i++) { result = result * i; } return result; }
  2. Probably doomed. What do you want us to do about it??
  3. Complacency ww2 is over. Or maybe you just didn't hear about it 20 years ago with the lack of social media. As I see it everbody says stupid stuff. Now everybody knows when you say stupid stuff. Standard tests? Yep I haven't had to count anything in my head in years computers do that.
  4. No, you need to document everything. If you are going to learn something outside of college keep records of what you have done. This could just be a bunch of excel/R programs to circuit diagrams. You could put stuff on github or circuits.io etc. That way when next you are in college you can say I have studied a,b,c and I have done some practical work which you can have a look at.
  5. Like this??? import java.awt.AWTException; import java.awt.MouseInfo; import java.awt.Point; import java.awt.PointerInfo; import java.awt.Robot; import java.awt.event.InputEvent; import java.io.IOException; import java.lang.InterruptedException; import java.util.BitSet; import lc.kra.system.keyboard.GlobalKeyboardHook; import lc.kra.system.keyboard.event.GlobalKeyAdapter; import lc.kra.system.keyboard.event.GlobalKeyEvent; import lc.kra.system.mouse.GlobalMouseHook; import lc.kra.system.mouse.event.GlobalMouseAdapter; import lc.kra.system.mouse.event.GlobalMouseEvent; public class App extends Thread implements Runnable { private static boolean run = true; private static GlobalKeyboardHook keyboardHook = new GlobalKeyboardHook(); private static GlobalMouseHook mouseHook = new GlobalMouseHook(); private BitSet keyboardInputHandlers() { keyboardHook.addKeyListener(new GlobalKeyAdapter() { @Override public void keyPressed(GlobalKeyEvent event) { System.out.println(event); if (event.getVirtualKeyCode() == GlobalKeyEvent.VK_ESCAPE) { Thread.currentThread().interrupt(); try { Thread.currentThread().join(); } catch (InterruptedException e) { run = false; } } } @Override public void keyReleased(GlobalKeyEvent event) { System.out.println(event); } }); BitSet statusCode = new BitSet(0); statusCode.set(0); return statusCode; } private BitSet mouseInputHandlers() { mouseHook.addMouseListener(new GlobalMouseAdapter() { @Override public void mouseMoved(GlobalMouseEvent event) { PointerInfo a = MouseInfo.getPointerInfo(); Point b = a.getLocation(); int x = (int) b.getX(); int y = (int) b.getY(); if (x < 1500) { Thread.currentThread().interrupt(); try { Thread.currentThread().join(); } catch (InterruptedException e) { run = false; } } } }); BitSet statusCode = new BitSet(0); statusCode.set(0); return statusCode; } private BitSet taskRunner() { BitSet statusCode = new BitSet(0); Robot bot = null; try { bot = new Robot(); } catch (AWTException e) { return statusCode; } bot.mouseMove(1600, 600); while (run == true) { bot.mousePress(InputEvent.BUTTON1_MASK); bot.mouseRelease(InputEvent.BUTTON1_MASK); } keyboardHook.shutdownHook(); mouseHook.shutdownHook(); statusCode.set(0); return statusCode; } public void run() { System.out.println("thread is running..."); BitSet statusCode; statusCode = keyboardInputHandlers(); if(!statusCode.get(0)){ System.out.println("Keyboard Error in App Thread"); } statusCode = mouseInputHandlers(); if(!statusCode.get(0)){ System.out.println("Mouse Handler Error in App Thread"); } statusCode = taskRunner(); if(!statusCode.get(0)){ System.out.println("Task Runner Error in App Thread"); } } public static void main(String[] args) throws IOException, AWTException { final App t1 = new App(); t1.start(); } }
  6. Okay I found an answer on stackoverflow supposedly I have to use Java Native Interface and C. There is a github project that did that already https://github.com/kristian/system-hook so I imported that in an eclipse maven project and it seems to work. import java.awt.AWTException; import java.awt.Robot; import java.awt.event.InputEvent; import java.io.IOException; import lc.kra.system.keyboard.GlobalKeyboardHook; import lc.kra.system.keyboard.event.GlobalKeyAdapter; import lc.kra.system.keyboard.event.GlobalKeyEvent; import lc.kra.system.mouse.GlobalMouseHook; import lc.kra.system.mouse.event.GlobalMouseAdapter; import lc.kra.system.mouse.event.GlobalMouseEvent; public class App extends Thread{ public void run(){ System.out.println("thread is running..."); Robot bot; try { bot = new Robot(); bot.mouseMove(1600, 600); for(int i =0; i < 10000; i ++){ bot.mousePress(InputEvent.BUTTON1_MASK); bot.mouseRelease(InputEvent.BUTTON1_MASK); } } catch (AWTException e) { // TODO Auto-generated catch block e.printStackTrace(); } } private static boolean run = true; public static void main(String[] args) throws IOException, AWTException { App t1=new App(); t1.start(); // might throw a UnsatisfiedLinkError if the native library fails to load or a RuntimeException if hooking fails GlobalKeyboardHook keyboardHook = new GlobalKeyboardHook(); System.out.println("Global keyboard hook successfully started, press [escape] key to shutdown."); keyboardHook.addKeyListener(new GlobalKeyAdapter() { @Override public void keyPressed(GlobalKeyEvent event) { System.out.println(event); if(event.getVirtualKeyCode()==GlobalKeyEvent.VK_ESCAPE) run = false; } @Override public void keyReleased(GlobalKeyEvent event) { System.out.println(event); } }); try { while(run) Thread.sleep(128); } catch(InterruptedException e) { /* nothing to do here */ } finally { keyboardHook.shutdownHook(); } } } That would work for what I am doing but it doesn't capture keypresses globally. I suppose it is hard to find because you could make keyloggers out of it.
  7. I am using Java.awt.robot task automation. How can I capture a global button press event in windows to cancel the click automater when the user isn't clicking on eclipse in java? public class autoclicker extends Thread{ public void run(){ System.out.println("thread is running..."); Robot bot; try { bot = new Robot(); bot.mouseMove(1600, 600); for(int i =0; i < 1200000; i ++){ bot.mousePress(InputEvent.BUTTON1_MASK); bot.mouseRelease(InputEvent.BUTTON1_MASK); } } catch (AWTException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static final int BINSIZE = 17; public static void main(String[] args) throws IOException, AWTException { autoclicker t1=new autoclicker(); t1.start(); }
  8. You didn't invent atheism.... Don't you have something better to be doing with your time???
  9. Generally instead of using method overloading it is better to use generics. package generics; public class Box<T> { private T t; public void add(T t) { this.t = t; } public T get() { return t; } public String manipulation(T p, T p1, T p2) { int a = 0, b = 0; String s = p.toString(); char c1 = p1.toString().charAt(0); char c2 = p2.toString().charAt(0); for (int i = 0; i < ((String) s).length(); i++) { if (s.charAt(i) == c1) { a = i; System.out.println(i); break; } } for (int j = s.length() - 1; j >= 0; j--) { if (s.charAt(j) == c2) { b = j; break; } } System.out.println(a); System.out.println(b); if(a > 0 && b > 0){ String s2 = s.substring(a + 1, b - 1); s = s.replace(s2, ""); return s; } return null; } public static void main(String[] args) { Box<Integer> integerBox = new Box<Integer>(); Box<String> stringBox = new Box<String>(); stringBox.manipulation("Hello World","H","W"); integerBox.manipulation(123,4,8); } }
  10. Are you sure all the paragraph options are the exact same. From your selection in the images the line height of the paragraph is different.
  11. I spend alot of my time sitting in college and the bus etc everyday since starting college and am losing my six pack. My brother recommended using an exercise ball as a chair to work my abdominal muscles at home. What are the advantages and disadvantages of using an exercise ball as a chair over say getting a standing desk??
  12. Why would it? Do you believe this configuration would be more stable?? If chlorine shares an electron with boron then it has a full sublevel. Regardless the other the accepted theory.
  13. Could you not just add a row above the table with the heading in it???
  14. So arc-length is some form of a measure of how variable the graph is. In the case of heart rate it could indicate arrhythmia. When do you ever have the arc-length by itself??
  15. Lets say we know how fast a person's heart beats. The machine will tell you if it beats to fast or too slow but what does the arc-length tell you??
  16. You take a bus from your home to school/work along a curved road. If you leave your house at 8:20 and arrive at 9:10. What is the arc length??
  17. An engine takes a source of mechanical energy and converts it into desirable motion. A motor converts other sources of energy into mechanical energy.
  18. Or a motor with an magnets at all (steam engine)
  19. List Attached bealls.html
  20. If you pay to have it hosted I don't mind coding it. Or you could just start a thread here.
  21. Usually this is caused by dissolved substances in the water not necessarily the tablet itself. Again probably due to the quality of the water the whiskey company is using. More likely leaving your whiskey out caused water to evaporate from it causing dissolved solids to come out of solution.
  22. Does anybody know if CPanel (Enkompass) is still available for use with Windows Server 2012 R2 Datacentre? Also is it possible to use one machine as both the primary and secondary dns nameserver??
  23. Then why not make money online by making circuits for people??
  24. Asynchronous is a word commonly used in computer science to describe the process of the computer handling operations in sequence. As opposed to synchronous or happening all at the same time. When applied to an example consists of a series of base pairs. Rna = ACGUACGUACGU There are two ways that these base pairs could be processed. Asynchronous = read say x number of pairs then do something with that info or Synchronous = read all base pairs and do something with that info. There is a theory that this process actually happens asynchronously.
  25. No somebody could put a sim card on the motherboard which when it recieves a text will turn on the computer. Not all the computer actually turns off. Then it is probably because the circuit has aged and needs replacement.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.