Results 1 to 8 of 8
  1. #1
    somanayr is offline Member
    Join Date
    May 2010
    Posts
    27
    Rep Power
    0

    Default Detect keypresses without consol or GUI

    I want to make a bot for someone that will monitor a chatroom and bans any newcommers. All of the bots that I've made before have been fine having a limited number of loops -- if they got out of hand, then I'd just let them run their course until the loop expired.

    This one I want to run for an untold amount of time, and it's a bit of a pain to have to shut off your computer every time you want to end it (because it will control the mouse in order to ban people, and because it will run without a GUI or a consol)

    So to solve that, I figured hotkeys would be a great idea. Except one problem: everywhere I look, people say you need a GUI to detect keypresses...

    If anyone can help, that'd be great. I just need a function that will detect if a key is pressed, like a keylistener. Can be a specific key or any key. Doesn't matter.

  2. #2
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Lightbulb

    well, you can simply run your app with a GUI but set its JFrame as

    Java Code:
    this.setVisible(false);
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

  3. #3
    somanayr is offline Member
    Join Date
    May 2010
    Posts
    27
    Rep Power
    0

    Default

    Quote Originally Posted by Webuser View Post
    well, you can simply run your app with a GUI but set its JFrame as

    Java Code:
    this.setVisible(false);
    The problem is that I'm not quite sure how to run the main and a GUI at the same time :/

    I tried to make a start button for a spam bot with a GUI, and it started the GUI and everything, but I wasn't sure what to do after that, so I made an infinite loop that pressing the start button exits. Didn't work. I haven't been able to get on a computer with a compiler since, so I haven't been able to play around with it.

    If it's easier to have some other sort of input, that would work too. I've though about it a little, and I might set it so the program turns off it the mouse is at 0,0 (because you don't need to move the cursor to detect pixels)
    Would that be more efficient?

    By the way, thanks for the speedy reply :)

  4. #4
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    To create GUI you need to know Swing...

    I recommend read this JFrame tutorials first
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

  5. #5
    somanayr is offline Member
    Join Date
    May 2010
    Posts
    27
    Rep Power
    0

    Default

    Do I still need to learn swing if I took a copy of JBuilder off a school computer?

  6. #6
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    to adapt your code correctly you need to know swing. At least its basic things...
    You can use NetBeans for this but it is another story and should be another thread then :)
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

  7. #7
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    Quote Originally Posted by somanayr View Post
    Do I still need to learn swing if I took a copy of JBuilder off a school computer?
    That should be quite enough to study the tutorial I gave you... As for your current case I mean
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

  8. #8
    somanayr is offline Member
    Join Date
    May 2010
    Posts
    27
    Rep Power
    0

Similar Threads

  1. get keypresses from SVGForm with only SVGLabels
    By erik6048 in forum CLDC and MIDP
    Replies: 1
    Last Post: 02-23-2010, 09:13 AM
  2. Detect new file entry
    By rdemon in forum Advanced Java
    Replies: 4
    Last Post: 01-08-2010, 03:24 AM
  3. Unable to detect OS name
    By neetu.jainvi@gmail.com in forum Advanced Java
    Replies: 1
    Last Post: 12-09-2009, 05:56 PM
  4. Help - Swing Timers, Two Keypresses
    By Gheta in forum AWT / Swing
    Replies: 2
    Last Post: 07-29-2009, 10:23 PM
  5. Detect loading of ImageIcon from URL?
    By barkster in forum Java Applets
    Replies: 1
    Last Post: 01-29-2008, 08:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •