• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Making a mouse click in Java?

 
Alex Richards
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I've been trying to find a way to make a program in NetBeans IDE that can make your mouse click.
Does anyone have any idea on how I could go about coding this?
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11914
209
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alex Richards wrote:Hi, I've been trying to find a way to make a program in NetBeans IDE that can make your mouse click.
Does anyone have any idea on how I could go about coding this?

I can read that two ways:
  • I wish to make NetBeans behave as though a mouse had just been clicked within the IDE
  • I wish to emulate mouse clicks in some other (unnamed) environment


  • Can you make your question a little clearer?
     
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander
    Pie
    Posts: 11914
    209
    C++ Firefox Browser IntelliJ IDE Java Mac Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    (I can also read this as you want to have my mouse click, in which case: stay away from my computer! )
     
    Alex Richards
    Greenhorn
    Posts: 9
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I would like to write a program that simulates a mouse being clicked. (In other words, I'd like to be away from the computer while the program makes my mouse click ).
    I understand how I could write a loop to continuously make the mouse click, but I'm unsure of the code I would need to add in that loop to make the cursor simulate a mouse left-click.
     
    Alex Richards
    Greenhorn
    Posts: 9
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    And yes, I'd like it to be able to continue running, even if I had a different window open.
    (For example, I'd like to be able to open up the internet browser and have the mouse still continually be clicking.)
     
    Jesper de Jong
    Java Cowboy
    Saloon Keeper
    Posts: 15448
    42
    Android IntelliJ IDE Java Scala Spring
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I think you can do this with the class java.awt.Robot - look it up in the documentation.
     
    Don't get me started about those stupid light bulbs.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic