Moving the mouse

I know that you can listen for mouse events, but is there a way to take control of the mouse? What I'm thinking is making a little gag program that when the person moves the mouse up, the mouse arrow will move down. Just making the mouse move in the opposite position that they want it to go. Is moving the mouse outside the reach of Java?
Thanks

I used your mouse mover thing and added it to another gag program that I just completed. Pretty rough, but looks cool.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Timer;
import java.util.TimerTask;
public class Gag {
    JFrame frame = new JFrame();
    JPanel thePanel = new JPanel(new FlowLayout(3));
    JTextArea tArea = new JTextArea(20,40);
    JButton cancelButton = new JButton("Cancel");
    Font myFont = new Font("Mine",3,14);
    int timeToRun = 150;
    int num=0;
    int whereImAt=0;
    int x, y, oldx, oldy, curx, cury;
    int screenh, screenw;
    Robot r;
    String[] msgArray;
    String msg = "f,o,r,m,a,t, ,C,:, , , ,\n, , FORMAT C: DRIVE, ARE YOU SURE (Y/N):, , Y, , , , ,\n, FORMATTING C: DRIVE";
    String secMsg = "FORMAT C: DRIVE, ARE YOU SURE (Y/N):";
    String wholeMessage = "C:\\>format C: \n FORMAT C: DRIVE, ARE YOU SURE (Y/N): Y \n FORMATTING C: DRIVE \n";
    Toolkit tk;
    Timer myTimer = new Timer();
    public Gag() {
        tk = Toolkit.getDefaultToolkit();
        try {
            r = new Robot();
     } catch (Exception e) { e.printStackTrace(); }
        Dimension d = tk.getScreenSize();
     screenh = (int)d.getHeight();
     screenw = (int)d.getWidth();
        msgArray = msg.split(",");
        frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
        frame.setUndecorated(true);
        tArea.setBackground(Color.BLACK);
        tArea.setForeground(Color.WHITE);
        tArea.setFont(myFont);
        thePanel.setBackground(Color.BLACK);
        thePanel.add(tArea);
        thePanel.add(cancelButton);
        frame.getContentPane().add(BorderLayout.CENTER, thePanel);
        frame.setSize(screenw, screenh);
        frame.setVisible(true);
        frame.addMouseMotionListener(new MouseMotionListener() {
            public void mouseDragged(MouseEvent e) { }
            public void mouseMoved(MouseEvent e2) {
          curx = e2.getX();
          cury = e2.getY();
          x = (curx == oldx) ? curx : (curx > oldx) ? curx - 15 : curx + 15;
          y = (cury == oldy) ? cury : (cury > oldy) ? cury - 15 : cury + 15;
               if( x <= 0 ) {
                    x = screenw - 10;
                    oldx = x;
               } else {
                    oldx = x;
               if ( y <= 0 ) {
                    y = screenh - 10;
                    oldy = y;
               } else {
                    oldy = y;
               if( x >= screenw ) {
                    x = 10;
                    oldx = x;
               } else {
                    oldx = x;
               if( y >= screenh ) {
                    y = 10;
                    oldy = y;
               } else {
                    oldy = y;
               r.mouseMove(x, y);
        tArea.append("C:\\>");
        myTimer.schedule(new TimerTask(){
            public void run(){
                startGag();}
        },timeToRun,timeToRun);
    public void startGag(){
        if(whereImAt>=msgArray.length){
            if(whereImAt==msgArray.length){
                tArea.append("\n"+String.valueOf(num)+"%");
                whereImAt++;
            }else{
                if(num==101){
                    tArea.append("\n Format complete. Please restart your computer before re-installing Operating System....");
                    myTimer.cancel();
                }else{
                    tArea.setText(wholeMessage+num+"%");
                    num++;
                    whereImAt++;
        else{
            tArea.append(msgArray[whereImAt]);
            whereImAt++;
    public static void main(String[] args) {
       Gag theGag = new Gag();
}I know that a few people won't like how I wrote this, but I welcome the comments. I'll just sit back while I get ripped on.......
Message was edited by:
Ledition
Message was edited by:
Ledition

Similar Messages

  • Why does moving the mouse over an IMAQ image display slow the GUI down so much?

    I have a large application with several vi's running simultaneously under labview 8.6.1.  When I mouse over an image display control in one of the vi's, everything slows down a shocking amount in all the other vi's.  The windows task manager does not show a large increase in CPU use.  My pc is has a quad cpu with 4GB of RAM, and the CPU and memory loads do not appear to be terribly taxing to the system.  However, many of my vi's apparently come almost to a standstill if I just move the mouse in a circle around my image control.
    This looks like it is largely a GUI display issue.  If I make a new vi and put a while loop in it that only displays the iteration loop number to an indicator, I can see the iterating occurring, then stopping totally when I mouse inside the image display control.  When I stop moving the mouse inside the control, or when I move it outside the control, the interation loop number jumps up, as if it had been incrementing behind the scenes the whole time.  So only display of the interating was halted.
    This problem occurs even if the vi with the image control is not executing.  If the vi with the image control is open but not running, and I mouse over the image on it, the other guis all come to a screeching halt.
    Does mousing in the image display control really utterly crush all other guis in all other labview windows?  Is this an issue inherent to the image display control?  If so, is there anything I can do about this? 
    Also, this issue is not entirely limited to display.  I started looking at it in greater detail because this issue also exposed what I think is a race condition in my code.  I have a vi that acquires an image from a ccd and puts it into an IMAQ image.ctl.  This image then gets passed up to a vi up the call chain, and is put on a queue and sent over to be de-queued by a vi that has the image display control.  Here's the kicker:  when I mouse over the image display control, the image successfully gets acquired inside the subvi, and if I probe the wire leading to the output IMAQ image display.ctl, I see the image.  If I simultaneously probe the wire coming out of the subvi one level up the call chain, the image gets lost about half the time.  This only happens if I am mousing in the image display control IN A TOTALLY DIFFERENT AND SEPARATE VI.  If I bump up the priority of the ccd image acquisition vi to 'highest priority', the problem only happens about 1% of the time, and I really have to mouse around to make it happen.  Still, it's disturbing that mousing in the GUI in one window results in a failure of a separate subvi to simply pass an image up the call chain.  I understand that IMAQ images are referenced rather than passed by value, but I don't see why there should be a failure to pass the image up the call chain.  I've looked for a race condition, but can't find one.
    Eric

    I have finally been able to replicate the behavior that you are seeing on another computer once the image was large enough.  Here are a few notes about this behavior:
    First. The UI only slows down when the images are large, 16 bit images.  The reason why this is unique to 16 bit images is that they can only be displayed on the front panel as 8 bit images.  The workaround that Weiyuan suggested to change the 16 bit display mapping hints towards the root of the problem...that any time a mouse runs over the indicator, Windows asks the entire image to re-draw (having a separate indicator overlapping the image will create the same behavior).  With a 16 bit image, not only does the image have to re-draw on the screen but the 16 bit pixels need to be mapped to 8 bits.  When setting the 16 bit display mapping to Full Dynamic, this requires mor computation/pixel than 90% dynamic or one of the other mapping schemes.
    This is expected behavior if your program is running and you're trying to display a large 16 bit image.  To fix this behavior there are a couple options:
    Change the 16 bit display mapping to something other than full dynamic.  You can choose which 8 bits to display or if you want to map the bits. 
    Resize the image just for viewing purposes on your front panel (since you aren't going to view every single pixel of you image on the screen). You can use the IMAQ Resample.vi to do this.  This will allow you to take your 1500x1500 pixel image and only display a 500x500 pixel version.
    If you are interested in viewing small details of the large image, consider just displaying a smaller region of interest at a time.
    Let me know if any of these solutions work for you.  Good luck on your application.
    Zach C.
    Field Engineer
    Greater Los Angeles

  • FM9 crashing when moving the mouse to the pods

    Hi,
    I've FM9 (on XP SP3) frequently crash when moving the mouse cursor over one of the hidden "pods" in the lower side of the window (Conditional Text, to be precise).
    I've sent Adobe several of the crash logs, but it seems there is no update fixing this issue.
    Is someone else having this problem? I feel I alread asked this in this forum, but I can no longer find the thread.
    Paolo

    Paolo, just to be clear, "undocking" the pods by moving them away from your work area is different from actually "de-podding" -- which means stopping the pod from being displayed  -- by changing your workspace settings.
    There are some instructions about creating a custom workspace, in which you can stop the pods from being displayed or being "active" even when they are being minimizd, here:
    Workspaces in FrameMaker 9
    Adobe Forums: Steps to "de-pod" workspaces in FM 9

  • Videos stop playing when i stop moving the mouse

    Videos and  audio stop playing if Istop moving the mouse, Has anyone else experienced this problem and know of a solution? Thank You.

    Hello @sunracer,
    I understand that you are having issues where your audio and video stop working if you do not move the mouse on your HP Pavilion p7-1010 Desktop PC. I would be happy to assist you, but first I would encourage you to post which operating system you are using. And whether your operating system is 32-bit or 64-bit as with this I can provide you with accurate information.
    Which Windows operating system am I running?
    Is the Windows Version on My Computer 32-bit or 64-bit?
    Please re-post with the requested information and I would be happy to provide you with assistance. Thank you for posting on the HP Forums. Have a great day!
    Please click the "Thumbs Up" on the bottom right of this post to say thank you if you appreciate the support I provide!
    Also be sure to mark my post as “Accept as Solution" if you feel my post solved your issue, it will help others who face the same challenge find the same solution.
    Dunidar
    I work on behalf of HP
    Find out a bit more about me by checking out my profile!
    "Customers don’t expect you to be perfect. They do expect you to fix things when they go wrong." ~ Donald Porter

  • Magic Mouse and MS Word 2011 (under OS 10.7, iMac middle 2011): Marking of word in a document stops after a few seconds while still pressing the left button and keep on moving the mouse (batteries full)

    Software: OS X Lion (10.7.4); Microsoft Word für Mac 2011, Version 14.2.2 (120421)
    Hardware: iMac 2.7 GHz Intel Core i5, 12 GB, magic mouse
    To mark several clauses in a doc-document (in MS Word 2011), I press the left mouse button and move the mouse along the words
    My problem:
    While still pressing the left button and moving the mouse, the marking on the screen stops and I can't change the already existing markings any more (to become less or especially more).
    Who knows:
    - why this happens and how I can abondon this behaviour?
    - is it a settings problem in MS Word 2011 or of OS X Lion?
    By the way:
    - I don't watch this behaviour in MS Excel 2011. There everything works fine.
    - The batteries are fully loaded and I'm about 30 to 40 cm (1") away from the iMac (RSSI: -60 dB)
    Thanks for answers.
    redlef

    I have the same problem now that I've enabled FileVault 2 on Mountain Lion.

  • Firefox 4.01 keeps dimming the screen after a few secnds unless you keep moving the mouse.This is very annoying. It doesn't do it on Explorer or while in Windows so it is only happening ince I upgraded to 4.01

    Firefox 4.01 keeps dimming the screen after a few seconds
    unless you keep moving the mouse. This is very annoying.
    It doesn't do it on Explorer or while in Windows.
    It is only happening since I upgraded to 4.01
    It happens even on this page if I stop typing or moving the mouse.

    Symantec have released an update for Norton 360 to make it compatible with Firefox 4, for details see http://us.norton.com/support/kb/web_view.jsp?wv_type=public_web&docurl=20100720113635EN&ln=en_US

  • When I click on an action, nothing happens unless I keep moving the mouse pointer. This has only happened since I upgraded to version 6. Interestingly, the some situation is with the "SafeCentral" software.

    This happens every time I click on a button or text that does something like, after entering some information then clicking on say, a button to "Continue". The screen freezes and the little symbol on the left hand side of the tab stops rotating, but starts as soon as I move the mouse. If I stop moving the mouse the screen freezes again. I also have installed on my computer the application, '''SafeCentral''', which I know uses Firefox. This problem has only been encountered since I updated to version 6 and also when SafeCentral update the Firefox version they use.
    Wired or what!
    Thank you for any assistance you can offer.
    Regards
    Michael Murray

    Thank you for your prompt reply.
    I think you have identified the problem straight away, well done!
    I first encountered the problem a couple of months ago with an update on Safe Central, (protected environment) software. SC uses the Firefox browser. I won't insult you by explaining what the program does, I'm sure know better that I. I didn't have this problem with Version 5 of Firefox, so I conclude the easiest way to solve this issue would be for me to uninstall v. 6 and reinstall V. 5. As I only use SC for online shopping I can live with this miner irritation. I also notice the Trend Micro Toolbar, though it appears on the Firefox screen, does not monitor the web sites or check email addresses.
    So the TM boffins also have a problem with V.6, but I wager they aren't aware of it yet. Just in closing, I also use Chrome and Internet Explorer that work perfectly well. The problem defiantly lies with Mozilla.
    Kind regards
    Michael

  • HT1436 My Power Mac G5 will not fully boot without safe mode, it only comes to a blue screen where my cursor duplicates in to 2, (one is frozen, one can move by moving the mouse). What is my problem, and how do I fix it?

    My Power Mac G5 will not fully boot without safe mode, it only comes to a blue screen where my cursor duplicates in to 2, (one is frozen, one can move by moving the mouse). What is my problem, and how do I fix it?

    Great clue Lukas...
    One way to test is to Safe Boot from the HD, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, Test for problem in Safe Mode...
    PS. Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive
    Reboot, test again.
    If it only does it in Regular Boot, then it could be some hardware problem like Video card, (Quartz is turned off in Safe Mode), or Airport, or some USB or Firewire device, or 3rd party add-on, Check System Preferences>Accounts>Login Items window to see if it or something relevant is listed.
    Check the System Preferences>Other Row, for 3rd party Pref Panes.
    Also look in these if they exist, some are invisible...
    /private/var/run/StartupItems
    /Library/StartupItems
    /System/Library/StartupItems
    /System/Library/LaunchDaemons
    /Library/LaunchDaemons

  • If I stop moving the mouse my computer will shut off?

    I turn on everything works fine but if I let it go with out moving the mouse the whole computer just shuts off.

    Is this limited to Aurora? If you need a release build to test, you can use the "Portable" version from here: [http://sourceforge.net/projects/portableapps/files/Mozilla Firefox%2C Portable Ed./Mozilla Firefox%2C Portable Edition 27.0.1/]
    Some monitors have an option to reduce power consumption or adapt to the brightness of content. It seems from past threads that this can affect Firefox even if other browsers are not affected. Example: [https://support.mozilla.org/questions/981249 Screen dims].

  • Whenever I truy to load a picture or video file, it will stall until I start moving the mouse around. When I stop moving the mouse, it stalls again. I am running Firefox 4.0.1 and Vista

    Any picture or video file I try to load just stalls (with the exception of sound which works OK). I move the mouse and it plays or loads. I stop moving the mouse it stalls again.

    I have had a similar problem with my system. I just recently (within a week of this post) built a brand new desktop. I installed Windows 7 64-bit Home and had a clean install, no problems. Using IE downloaded an anti-virus program, and then, because it was the latest version, downloaded and installed Firefox 4.0. As I began to search the internet for other programs to install after about maybe 10-15 minutes my computer crashes. Blank screen (yet monitor was still receiving a signal from computer) and completely frozen (couldn't even change the caps and num lock on keyboard). I thought I perhaps forgot to reboot after an update so I did a manual reboot and it started up fine.
    When ever I got on the internet (still using firefox) it would crash after anywhere between 5-15 minutes. Since I've had good experience with FF in the past I thought it must be either the drivers or a hardware problem. So in-between crashes I updated all the drivers. Still had the same problem. Took the computer to a friend who knows more about computers than I do, made sure all the drivers were updated, same problem. We thought that it might be a hardware problem (bad video card, chipset, overheating issues, etc.), but after my friend played around with my computer for a day he found that when he didn't start FF at all it worked fine, even after watching a movie, or going through a playlist on Youtube.
    At the time of this posting I'm going to try to uninstall FF 4.0 and download and install FF 3.6.16 which is currently on my laptop and works like a dream. Hopefully that will do the trick, because I love using FF and would hate to have to switch to another browser. Hopefully Mozilla will work out the kinks with FF 4 so I can continue to use it.
    I apologize for the lengthy post. Any feedback would be appreciated, but is not necessary. I will try and post back after I try FF 3.16.6.

  • Firefox doesn't load a page or GIf unless I am moving the mouse

    Firefox won't load any page or play a GIF unless I am moving the mouse or typing. I have the latest version of Firefox. It happens every couple of times I use the computer, and the problem keep occuring if I just restart Firefox. Any ideas?

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    * https://support.mozilla.com/kb/Safe+Mode
    * https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • My computer wakes up periodically without my moving the mouse. How can I keep this from happening?

    My computer wakes up periodically without my moving the mouse.  How can I keep this from happening?

    Your network may also be causing it to wake, if you are running Vista try this:
    http://www.howtogeek.com/howto/windows-vista/fix-sleep-mode-randomly-waking-up-issue-in-windows-vist...
    If Windows 7:
    http://www.techsupportalert.com/content/how-fix-computer-keeps-waking.htm
    If Windows 8:
    http://alinirimia.com/2013/11/windows-8-1-computer-wakes-up-from-sleep-how-to-stop-it/
    Please mark my post as SOLVED if it has resolved your problem. It helps others with similar situations.

  • How do I wake my computer up by just moving the mouse?

    I checked the settings and must not have adjusted the right one but ever since I updated to Lion instead of being able to wake my computer by moving the mouse (touching the trackpad) now I have to hit the spacebar.. Anyone know what setting I need to change to get it back the way I like it?

    Slammer99uk wrote:
    http://forums.macrumors.com/showthread.php?t=1174839
    http://forums.macrumors.com/showthread.php?t=1174839#post12806417
    And many many other places on the net found with google.
    Perhaps I should have made my post clearer, the default is click a mouse button OR use a key on the keyboard.
    Jerry
    Sorry, I don't do Mac Rumors - and judging by the post dates, they were talking about issues with SL, not Lion (unless they were violating an NDA). I do know how to use Google.
    In my case using Lion on both an iMac with mouse and magic trackpad and a Macbook with a trackpad, doing anything with the mouse or trackpad produces zero results. In checking with Apple, I was told that having to use the keyboard was the new default. So, some configurations may still allow wake-up with a mouse, but the intent appears to be for the keyboard to be the "wake-up alarm".

  • When I click full screen for Youtube. The video studders but doesnt if i keep moving the mouse.

    This problem emerged when Firefox 5 downloaded. Now when I put a video on any site on fullscreen, the video will stutter. But the puzzling thing is if I keep moving my mouse, the video loads fine. I really need help.

    LarrySmith1000 wrote:
    I can't believe this hasn't been fixed yet.  I am a flash developer, and I just spent about 20 trying to debug a fullScreenController class that I am writing because I couldn't figure out why going to fullscreen mode was completely blank.
    Turns out it is the stupid plugin update!!!!  By turning off video acceleration my code worked.  20 hours of my life that I will never get back.  Thanks a lot Adobe!!!
    Now, can you fix this so that people who use my software don't waste 20 hours of their lives, or should I just put a comment on my product that says, "If you want to view this in full screen, right click and deselect "video accelerator because Adobe has an error and refuses to fix it because they are retarded."
    Spending time to try and solve complex puzzles is good for the brain. Stems off Alzheimer's I'm told.
    But a simple search of the Adobe knowledge base would have saved you 19 hours and 55 minutes of your precious time: http://kb2.adobe.com/cps/839/cpsid_83952.html

  • Computer freezes when I'm moving the mouse over flash videos

    Hello,
    Sometimes when I move the mouse over a flash video to pause it or to even start it, my computer completely freezes. I'm using a laptop and the LED that lights up whenever the HD is being used completely stops lighting, indicating that the hard drive is no longer being used.
    All buttons stop working, including combinations like CTRL + ALT + Delete. The Caps Lock LED does not light up when pressing Caps Lock, and my mouse completely stops moving. All I'm left up is with a frozen image, and the only way to stop the computer is by pressing and holding the stop button on the laptop.
    When I restart the computer, the websites and tabs restore on the next Firefox start-up.
    I thought this only happened to YouTube videos, but now I've experienced it with another type of video.
    This only happens in Firefox and with flash videos. Does anybody know how I can fix this?
    Thanks!

    Hello, thank you for the response.
    I could try that, but the thing is, this only happens rarely. I don't know if there is any way to deliberately cause this, but freezing the computer is not the most pleasant thing, because it requires closing it by using the physical button on the computer, rather than the Windows Shutdown command.

Maybe you are looking for

  • Trying to use webutil  - Works in development, will not work on app server.

    I am having a similar problem. I have followed all the instructions from above. I run my code in the developer and it runs fine. If I run my code from the application server I get locked up. Here is the output from my java console. Oracle JInitiator:

  • Error while fetching the UME data

    Hi Experts, I am creating a BPM process in NWDS CE 7.2. When I try to assign the potential owner to the task I get the following error: Error during connecting to server. HTTP error code: 502 The server is running just fine. Please let me know why th

  • Clearing Network field in shopping cart

    Hi, in Doc_Change badi to clear out the Network value from BBP_PDS_ACC-NETWORK field whenever user enters some value using the Activity Search help. i think code has to be written using fm BBP_PD_SC_GETDETAIL but who can we clear network field based

  • Aaaargh! IE + Spry Menu = My Personal Hell! Help?!

    Okay, so I've searched through these forums trying to find a solution to my problem, and while I did find over 200 posts related to my issue, I couldn't find a solution... ...maybe someone can help? I've got a simple vertical spry menu that always wo

  • Sent messages aren't saved in IMAP server

    Since I upgraded to Leopard the other week I'm having a problem with Mail, the messages I send are not stored on our IMAP server. The error that shows up in system.log is: Nov 1 14:57:02 iblack Mail[2113]: Error (null) occurred while trying to append