Mouse position help

When using MouseListener and MouseMotionListener in an applet, I can not record events that happen outside the applet. Is there a way to record the x and y position of the mouse along with button presses when they occur outside the applet window? Thank you for your time.

>
I want to make a program to repeats a bunch of steps on my computer. However, while making it, I found it too hard to hardcode in the co-ordinates. Therefore, I want to record my actions so that I can repeat them.
My plan is to have it record where I click into a text file, then the robot program will read from the text file and move the mouse to those positions and perform the same action everyday at a specific time, like when I wake up or come home. >It would be safer and more reliable to open a File object pointing to the text file, then do the edits using standard Java classes (such as a RandomAccessFile).
>
It doesn't need to be an applet, it can be an application too.>That is good, since the applet would need to be digitally signed in order to access the file system or the Robot.
If this is a 'one off' app. for yourself, it is best launched as a plain application (JFrame without JWS).
So to sum up. I do not think the Robot and related classes can provide the functionality you require, which is far easier/more reliable to program as I stated above.

Similar Messages

  • Zooming image from mouse position(like in  windows vista photo gallery)

    hello all;
    here's my situation, hope someone can help..
    i wanna Zoom an image, which zoom from my mouse position
    like in windows photo gallery in windows vista
    so i do this..
    g2.translate(iMoux,iMouy);       
            g2.scale(zoom, zoom);       
            g2.translate(-iMoux,-iMouy);       
            g.drawImage(icon.getImage(), iSposx, iSposx, d.width/2-iValue, d.height-iBawah, null);
            g.drawImage(icon2.getImage(), d.width/2, iSposy, d.width/2-iValue, d.height-iBawah, null);the problem come when i move my mouse to the different location (like from top right to bottom left)
    the zoom image displayed in the screen like jump from latest location to new location
    anybody can help me...a clue how to do that?
    thx appreciate your help guys
    mao
    Edited by: KingMao on 31 Mei 08 14:27

    Hi Frank.
    Thanks for the response.
    Agreed, the pertinent question is why can't my colleague edit the JPG exported by Aperture. It's probably also worth pointing out, the same problem occurs with JPGs exported from iPhoto.
    The Windows software usually plays nicely with JPGs by all acounts, just not the ones I send - which I do via eMail or my public space on Mobile Me incidently.
    So, another key question is: all settings being equal (color profile, quality, etc.) are the JPGs as produced by iPhoto and Aperture indistinguishable from those produced by other apps on other platforms - i.e. does the use of JPG enforce a common standard?
    If that is the case, I suspect ours might be a permissions issue.
    According to the Microsoft support page on editing in Windows Live Photo Gallery, the inability to edit a picture is commonly caused by unsupported file type, or read-only attribute set on the file.
    Unfortunately, he and I are not in the same place, and he's not particularly au-fait with this type of problem solving. Hence, before involving him, I'd like to know:
    1. it's possible (i.e. someone else does it), and,
    2. what's involved (at my end and/or his).
    Thanks again,
    PB

  • Hwo to "track the mouse position"

    I m a java newbie, and need to write a small program to track the mouse position.
    basically, it opens a small window, and tell you the current mouse x, y coordinate. when mouse moves, hte x, y changes...
    by the way, how can i compile it to .exe file, after i finished coding.
    i try this way, but so many errors.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class mouseWin {
    public static void main(String[] args)
              protected int last_x=0, last_y=0;
              mouseMoved(MouseEvent e);
    JFrame frame = new JFrame("Mike's Mouse");
    JLabel X = new JLabel("x: " + last_x + "y: " + last_y);
    frame.getContentPane().add(X);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
         public mouseMoved(mouseEvent e)
              last_x = e.getx();
              last_y = e.gety();

    please help.
    i rewrite the code, but still cannot get it work
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.EventListener;
    public class mouseWin implements MouseMotionListener
    public static void main(String[] args)
                   int last_x;
                   int last_y;
                   last_x = 0;
                   last_y = 0;
                   JFrame frame = new JFrame("Mike's Mouse");
                   JLabel X = new JLabel("x: " + last_x + "y: " + last_y);
              frame.getContentPane().add(X);
                   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   frame.pack();
                   frame.setVisible(true);
         public void mouseMoved(MouseEvent e)
              last_x = e.getx();
              last_y = e.gety();
              JLabel X = new JLabel("x: " + last_x + "y: " + last_y);
    }

  • Mouse position capturing

    I was wondering if there is a way to capture the mouse position w/o the use of a frame or jframe? I already know how to use the MouseListener on the JFrame/Frame, but that is no help to me since I'm not using a frame at all. Any suggestions????

    What is your goal. This will work -- (the window is 1 pixel!) -- because the robot starts a "drag" and
    swing has mouse capture during drag, but as soon as the use clicks, it's over...
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class X {
        public static void main(String[] args) throws AWTException {
            JWindow w = new JWindow();
            Container cp = w.getContentPane();
            cp.addMouseMotionListener(new MouseMotionListener() {
                public void mouseDragged(MouseEvent e) {
                       System.out.println(e.getPoint());
                public void mouseMoved(MouseEvent e) {
            w.setBounds(new Rectangle(0,0,1,1));
            w.setVisible(true);
            Robot rob = new Robot();
            rob.mouseMove(0,0);
            rob.mousePress(InputEvent.BUTTON1_MASK);
            rob.mouseMove(100,100);
    [/code[

  • Detect Mouse Position?

    I can't (within actionscript 3) determine where the mouse is
    relative to the flash player window.
    I can get stage.mouseX and stage.mouseY but those coordinates
    are in relation to the size of the entire ORIGINAL stage at compile
    time.
    I need to know where the mouse is in relation to the window
    playing the swf, which is significantly smaller than the original.
    That is the play screen has been resized.
    If I zoom way in and scroll to the right edge of the stage
    and mouseover a spot on the right edge, then trace the mouse
    position (in a mouseover event proc) it shows me a number that is
    the width of the ORIGINAL stage. It seems to be completely
    oblivious to the play window.
    Is there any way at all to determine where the mouse is
    relative to the play window?
    For example,
    if the original stage is 1350 and the play window is 540 and
    I'm zoomed WAY in and scrolled all the way to the right and
    I put the mouse directly in the middle of the window,
    I need something that tells me (in actionscript 3) that the
    mouse's x coordinate is at 270, NOT 12XX (somewhere near the end of
    the orginal size of the stage).
    Is this possible in Flash C3??

    Hi there!
    I don´t know if it´s right but have you tried
    localX
    localY
    from the occuring MouseEvent?
    Hope that helps :)
    CU
    Ingo

  • Convert mouse position to image position

    Using a zoomed IMAQ image in an image control, I want to recover the position of the mouse in the co-ords of the underlying image. LastMousePositionX (and Y) give the info I want but they are one click in the past and not the current position. Amazingly, there doesn't appear to be an equivalent CurrentMousePositionX. I can't seem to find the info I need to do the conversion manually. The mousedown event returns the current mouse position and I can get the position in the image container by subtracting off its left and top position. But to convert this to the image position I need to know both the zoom and where the images origin is relative to what is displayed. I can't seem to find that origin position in the list of property nodes. The only thing I can seem to come up with is to extract the info from teh image information string, but this seems like an incredibly poor way to extract such obvious information - espeically since the info must be calculated to put in the string anyway. Can anyone help with this?

    Hi,
    I am confused why you get the mouse position one click in the past because it seems to work ok for me. I've had to use four of the image properties to recreate the effect using the mousemove event, but this seems to give the same values as the Last Mouse Position property so I think it does what you want. I couldn't see an origin property so I did the conversion using the position given at the image center. I wanted to post a snippet here but I'm new to posting and couldn't seem to get it to work for the whole block diagram, so I'm using a screenshot instead. I hope this helps in some way.
    Will
    Attachments:
    mouse position test.vi ‏58 KB

  • Bitmap Rotation According to Mouse Position?

    Hi,
    I am working on a 2d computer graphics project, and I need a good function to rotate a Bitmap 360 degree according to my mouse position.
    for example: 

    Hi,
    I am working on a 2d computer graphics project, and I need a good function to rotate a Bitmap 360 degree according to my mouse position.
    for example: 
    Hello,
    To rotate that image, we need to deal with the following tips.
    1. The image size.
    If the area for that image rotated is not big enough, it will just lose some parts of that image.
    Here is a nice code shared in this thread
    http://stackoverflow.com/questions/5199205/how-do-i-rotate-image-then-move-to-the-top-left-0-0-without-cutting-off-the-imag/5200280#5200280.
    private Bitmap RotateImage(Bitmap b, float Angle)
    // The original bitmap needs to be drawn onto a new bitmap which will probably be bigger
    // because the corners of the original will move outside the original rectangle.
    // An easy way (OK slightly 'brute force') is to calculate the new bounding box is to calculate the positions of the
    // corners after rotation and get the difference between the maximum and minimum x and y coordinates.
    float wOver2 = b.Width / 2.0f;
    float hOver2 = b.Height / 2.0f;
    float radians = -(float)(Angle / 180.0 * Math.PI);
    // Get the coordinates of the corners, taking the origin to be the centre of the bitmap.
    PointF[] corners = new PointF[]{
    new PointF(-wOver2, -hOver2),
    new PointF(+wOver2, -hOver2),
    new PointF(+wOver2, +hOver2),
    new PointF(-wOver2, +hOver2)
    for (int i = 0; i < 4; i++)
    PointF p = corners[i];
    PointF newP = new PointF((float)(p.X * Math.Cos(radians) - p.Y * Math.Sin(radians)), (float)(p.X * Math.Sin(radians) + p.Y * Math.Cos(radians)));
    corners[i] = newP;
    // Find the min and max x and y coordinates.
    float minX = corners[0].X;
    float maxX = minX;
    float minY = corners[0].Y;
    float maxY = minY;
    for (int i = 1; i < 4; i++)
    PointF p = corners[i];
    minX = Math.Min(minX, p.X);
    maxX = Math.Max(maxX, p.X);
    minY = Math.Min(minY, p.Y);
    maxY = Math.Max(maxY, p.Y);
    // Get the size of the new bitmap.
    SizeF newSize = new SizeF(maxX - minX, maxY - minY);
    // ...and create it.
    Bitmap returnBitmap = new Bitmap((int)Math.Ceiling(newSize.Width), (int)Math.Ceiling(newSize.Height));
    // Now draw the old bitmap on it.
    using (Graphics g = Graphics.FromImage(returnBitmap))
    g.TranslateTransform(newSize.Width / 2.0f, newSize.Height / 2.0f);
    g.RotateTransform(Angle);
    g.TranslateTransform(-b.Width / 2.0f, -b.Height / 2.0f);
    g.DrawImage(b, 0, 0);
    return returnBitmap;
    2. The location of that control which displays that image.
    If we use a picturebox, and set its sizemode to autosize like the following line, then if you just want to rotate that image to show, and you don't want to that affects the original image, then we need to keep its center point.
    this.pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
    We could add resize event handler after we set image for that picturebox.
            Point pOrign;
            Size sOrign;private void Form1_Load(object sender, EventArgs e)
    this.pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
    Image img = Image.FromFile(@"D:\Documents\New folder\New folder\TestImage.PNG");
    this.pictureBox1.Image = img;
    this.pictureBox1.InitialImage = img;
    pOrign = new Point(this.pictureBox1.Left , this.pictureBox1.Top );
    sOrign = new Size(this.pictureBox1.Width, this.pictureBox1.Height);
    this.pictureBox1.BorderStyle = BorderStyle.FixedSingle;
    this.pictureBox1.Resize += pictureBox1_Resize;
    private void pictureBox1_Resize(object sender, EventArgs e)
    this.pictureBox1.Left = this.pOrign.X + (this.sOrign.Width - this.pictureBox1.Width) / 2;
    this.pictureBox1.Top = this.pOrign.Y + (this.sOrign.Height - this.pictureBox1.Height) / 2;
    3. The angle between that center point and your mouse postion.
    We could get that value inside the picturebox's container's mouse_move event.
    Double angleNew ; private void pictureBoxContainer_MouseMove(object sender, MouseEventArgs e)
    angleNew = Math.Atan2(this.pOrign.Y + this.sOrign.Height / 2 - e.Y, this.pOrign.X + this.sOrign.Width/2 - e.X) * 180.0 / Math.PI;
    But when to start rotate that image, it should be your chooice, and you could decide when rotate that image with the following line.
    this.pictureBox1.Image = (Image)RotateImage(new Bitmap(this.pictureBox1.InitialImage), (float)angleNew);
    If you just want to save that change to that image, then you could save that bitmap to file directly.
    Happy new year.
    Regards.
    Carl
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Quartz Composer Photo Booth initialize mouse position or number slider

    I am new to this forum so I hope this is the correct place to ask this question.
    I am trying to develop a quartz composition for a Photo Booth effect that uses the mouse position or the numeric slider (see the 'Dent' effect in Photo Booth). I have been able to access data created by the mouse or the slider, my problem is that Photo Booth seems to 'reset' the mouse position or slider position to .5 (in a range from 0 to 1) when you first select the effect. I need to figure out if there is away to set the default from .5 to 0.
    An example would be if I selected an effect in Photo Booth, I want to have the slider appear all the way to the left (0) as apposed to being in the middle (.5)
    Thanks for any help.

    I am new to this forum so I hope this is the correct place to ask this question.
    I am trying to develop a quartz composition for a Photo Booth effect that uses the mouse position or the numeric slider (see the 'Dent' effect in Photo Booth). I have been able to access data created by the mouse or the slider, my problem is that Photo Booth seems to 'reset' the mouse position or slider position to .5 (in a range from 0 to 1) when you first select the effect. I need to figure out if there is away to set the default from .5 to 0.
    An example would be if I selected an effect in Photo Booth, I want to have the slider appear all the way to the left (0) as apposed to being in the middle (.5)
    Thanks for any help.

  • The programs open tab ( list of programs open on comp) is always popping up on middle of screen whenever I go near the mouse.  HELP!!!  Have turned it off recently and moved it, a mac mini, now on new plug in and set up it now does it.

    The programs open tab ( list of programs open on comp) is always popping up on middle of screen whenever I go near the mouse.  HELP!!!  Have turned it off recently and moved it, a mac mini, now on new plug in and set up it now does it.
    Yes I have turned it off and restarted it, ubnplugged mouse and plugged it back  in.
    Have not updated it in a little bit
    running mavericks, which I dislike.10.9.1
    This is a new problem,
    Why where and what do I need to do to fix it? Please.
    Thanks for your help community, You guys are awesome, better than the guys n girls at Apple!!
    I have also noticed the drop down menu arrow on Numbers Tabs has dissappeared since move.
    you know the invisible arrow that appears in the additional tabs pages in "Numbers program"
    Especially an inconvenient for previous Numbers users as you all know.
    any word on New Numbers Tutes at all??
    You'd think with a Billion dollars they could make a 10 min clip saying here are changes guys, go enjoy new layout.....  Just saying...  not.
    anyway Hi and any help out there tonight is GREATLY APPRECIATED.
    Cheers Jason.

    If the reset doesn't work:
    FORCE IPAD INTO RECOVERY MODE
    1. Turn off iPad
    2. Turn on computer and launch iTune (make sure you have the latest version of iTune)
    3. Plug USB cable into computer's USB port
    4. Hold Home button down and plug the other end of cable into docking port. Do not release button until you see picture of iTune and plug (very important)
    5. Release Home button.
    ON COMPUTER
    6. iTune has detected iPad in recovery mode. You must restore this iPad before it can be used with iTune.
    7. Select "Restore iPad"...
    Note: Data will be lost

  • System not sensing mouse position

    Starting today, my computer (iMac G5 PPC) no longer senses the position of my mouse pointer. For instance:
    - The dock doesn't magnify when the mouse is in it
    - None of the corners activate things like screensaver, expose, desktop
    - When I select a menu in the menu bar, moving the mouse over another menu item doesn't open that menu.
    In other words, OSX simply has no clue where my mouse pointer is located as I move it for all those neat automatic things. Yet, I can still use the mouse to click on items to make them work, then OSX knows where the mouse is.
    I've rebooted several times to no effect, but did notice something. As apps start up, the instant a window opens, OSX will sense the mouse position for that brief moment. For example, putting the mouse over the dock doesn't magnify, but when an app window appears, the dock will magnify that very instance. Moving the mouse out of the dock area doesn't unmagnify the dock, it's stuck in that state until either another window opens, causing OSX to sense the new position, or I click any mouse button which all gets OSX's attention and senses the mouse position.
    The pointer never changes when I'm over things like Links.
    Strange stuff. The mouse moves fine, it's just not being detected as it moves.
    Now, yesterday I installed a new ScanSnap scanner with the ScanSnap Manager software and Acrobat Standard ver. 7. But the mouse didn't have this behavior yesterday, or even this morning. This strange problem just appeared out of the blue mid-day today.
    I've since used Disk Utility and Onyx, and re-installed the 10.4.9 update. I switched to another user account, no difference, so it's definitely system wide.
    This doesn't stop me from using my iMac, but I just don't know how to fix this mouse issue besides a OSX re-install.

    Ok everybody, I finally got proper behavior, it's just too bad I'm not sure of the procedure.
    When I go to bed I usually run the mouse pointer to the upper left corner to activate the screensaver. Of course it didn't work. But I also knew that clicking a button causes the mouse to be sensed, so I was pushing some of the buttons while in the corner to see if I could get the screensaver going.
    Well, after doing this, everything is back to normal operation again. So, I fixed it totally by accident. Makes me wonder if there's some features that are turned on and off somehow by doing whatever it was I did up in that corner.
    Just so you know, I use a Logitech Cordless Optical Trackman. I swapped to the original Apple corded mouse but that made no difference.
    I never had a chance to try the suggestions since I just read them before posting this.
    Anyway, I hope I don't do again whatever it was that caused the behavior, but I am going to store this info in DEVONthink just in case something like this happens again.
    Anyway, it would still be interesting if someone could shed some light on this fix I accidently found. Perhaps some hidden capabilities/features? Or just dumb luck?

  • MAC OS X + stage.fullScreenSourceRect + renderMode set to GPU = problem with mouse position

    When setting stage.fullScreenSourceRect, stage.displayState to StageDisplayState.FULL_SCREEN_INTERACTIVE; and renderMode to GPU, mouse position is read incorrectly. This is not only for mouseX and mouseY position, but also all the mouse interactions with Sprites, Buttons etc are not working correctly.
    Anybody know a solution for this issue?
    Here is the bug reported, but there is no response yet.
    https://bugbase.adobe.com/index.cfm?event=bug&id=3486120
    Greg.

    Bump up.
    Anybody has the same problem and have an idea how to fix it? Or please just check if you have the same problem.. I'm going to submit my game "Amelia and Terror of the Night" (successfully added to iOS store) to MAC App Store but can't do it while this problem appears.
    I am disappointed nobody  even verified the bugs I submitted at  the bugbase.adobe.com for AIR 3.5 and 3.6
    thanks
    Greg

  • Mouse position on screen

    is there any way to get the mouses position on the screen (not a window)?
    Stephen

    Component c = (Component)e.getSource();
    Point p = e.getPoint();
    SwingUtilities.convertPointToScreen(p, c);
    System.out.println(p);

  • Get mouse position during Custom UI Draw event?

    I am building a Custom UI for one of my plugin effect.
    I want to get the mouse position during the Custom UI Draw event (PF_Event_DRAW), but cannot manage to get it.
    From what I understand, it seems we can only get the mouse position during the events PF_Event_DRAG, PF_Event_DO_CLICK, and PF_Event_ADJUST_CURSOR.
    I tried to use PFAppSuite4::PF_GetMouse() too, but this resulted in the error message "After Effects error: internal verification failure, sorry! {PF_GetMouse can only be called during valid events.}".
    Therefore I want to store the mouse position during PF_Event_ADJUST_CURSOR, and use it later during PF_Event_DRAW.
    Where can I store those values in a "clean" way (ensuring there will not be conflicts if two instances of the same effect are running, etc)?
    Or is there an easier method to get the mouse position during a Custom UI Draw event?

    //SequenceDataVars is the name of your data structure
    //this is how you create the sequence data
    out_data->sequence_data = PF_NEW_HANDLE(sizeof(SequenceDataVars));
    SequenceDataVars *seqData =
    (SequenceDataVars*)PF_LOCK_HANDLE(out_data->sequence_data);
    //and now you can store stuff in it.
    seqData->var1 = 7;
    //after it's created, on other calls, you just do a simple cast
    SequenceDataVars *seqData = *(SequenceDataVars **)out_data->sequence_data;
    seqData->var1 = 100;
    //this is how you delete it. (if you don't delete it, it will be saved with
    the project, and loaded on the next session. (if you want)
    PF_DISPOSE_HANDLE(out_data->sequence_data);
    there's more to know, so look up SequenceSetup, SequenceSetdown, ect in the
    sample project.

  • Checking Mouse position every second?

    Hello,
    I have a program that needs to check the mouse position on the program's window every loop, but if I use MouseMotionListener's mouseMoved(), it is not what I want because it checks ONLY when I move my mouse, it doesn't check if I don't move my mouse. For example, I have a while loop will check if the mouse pointer now in the area of (25, 50), the program will do something. Thus what should I use? I tried moveEntered(), it doesn't work as well any hints?
    Andy

    okay, for example, like Warcraft 3, starcraft type RTS game, when you move your mouse pointer to the edge of the screen, the screen will scroll over the map. But remember when you move to the edge of the screen, it will move automatically so you don't need to move your mouse until you want to stop moving the screen, you move away your pointer from the edge right? With mouseMoved(), it doesn't work that way cuz whenever it checks mouseMovement only, if there is no mouse movement, it doesn't know whether if the pointer is on the edge or not. How do I check that, since I don't wanna use a Runnable class to do that, I rather use a loop to check it. Which method that I can get the mouse pointer position by not implementing MouseListener.
    Andy

  • DnD - Get Drop Mouse Position

    I want to Drag some image file from a JList, and then drop it on a JPanel. The dropping on the panel functions. The problem is, i would like to get the position of the mouse, when the item is dropped on the panel. I use the panel to visualize graphics with Graphics2D, and the image dragged from the list should then be displayed at the position on the panel, where it is dropped. So how could i get this position? I have added a MouseListener to the panel, but it does not react on the mouse events which are caused by the DnD action.

    I am really helpless... Is this a stupid question or does nobody know the answer?
    I just want to get the mouse position of the drop, after a drag and drop.
    I found a MouseDragGestureRecognizer Class, but i am not able to implement. Actually i have just a JList, from which Strings are dragged, and a JPanel, on which the Strings are dropped.
    The drag and dropping functions, but i need the mouse position on the JPanel, when the String is dropped.

Maybe you are looking for