OSA script help in ARD...mouse click

Hello,
Lets say I want to use ARD (3.6.1) from my macbook air to click on a specific part of the screen on a 10.7.5 mac air. 
I have found this osascript but it does not work. Lets say I want it to click at {330,220} in Pages.
osascript -e 'tell application "System Events" to tell process "Directory Access" to click at {x,y}'
I have tried changing "Directory Access" to the program I am running, "Pages" but that does not work. I am also running command as root.
Any suggestions?

If you google around, you can probable find allot of unix scripts out there to do most of what you can do in Directory Access. (enable root, enable/bind to a directory service, map attributes, extra) and they would be faster and more reliable then trying to perform that action at the finder level with emulate mouse clicks.
FYI Not all process support the to click at funtion of applescript.
Another option some times is to script actions by the GUI elements which isn't relient on the window being in exactly the right spot to work. BUT again it's easier to do allot of this stuff at the unix/command base level.
What are you trying to do with Directory Access?
If you want to use applescript, have you tried some thing you know should work like:
activate application "AppleScript Editor"
tell application "System Events" to tell process "AppleScript Editor" to click at {0, 0}

Similar Messages

  • Help on right mouse click in swing GUI.

    I am working on a swing GUI interface which has Panels. One Panel contains two sub panels. I want to add the Right Mouse click feature to the panels. How should i go about achieving this? Please provide sample example if any.
    Thanks in advance.

    anyPanel.addMouseListener(new MouseAdapter(){
       public void mouseReleased(MouseEvent e){
          if(e.isPopupTrigger()){
              // right clicked
    });

  • Please help with script for right-mouse click on 3D objects

    Hi!
    I have PDF file with two simple 3d objects (for example with two cube).
    I need to make script that when user right-click to first cube, a PDF file (c:\a.pdf) opening (or c:\b.pdf for second one) in new windows. How to make it? Thank you so much!

    Hi,
    please check SDK sample 22 Right-Click, there is everything you need.
    First catch RightClickEvent, then create the menu entry when beforeAction = true, and when beforeAction = false you have to remove it again (otherwise you will receive an error when rightclicking again).
    Regards
    Sebastian

  • A script that captures the coordinates of the mouse clicks and saves them into a file

    Hello,
    I'm trying to create a cartoon taking a movie (I've chosen blade runner) as base. I've got the real movie and I've exported all the pictures using VirtualDUB. Now I have a lot of images to modify. I would like to modify the actors faces with the faces generated by Facegen modeller. I'm thinking how to make the whole process automatic because I have a lot of images to manage. I've chosen to use Automate BPA,because it seems the best for this matter. I'm a newbie,so this is my first attempt using Adobe Photoshop and Automate BPA. I wrote a little script. It takes a face generated with Facegen modeller and tries to put it above the original actors faces. But it doesn't work very good and I'm not really satisfied,because the process is not fully automated. To save some time I need to write a script that captures the coordinates of the mouse when I click over the faces and that saves them into a file,so that Automate BPA can read these coordinates from that file and can put the face generated with Facegen Modeller above the original face. I think that Automate BPA is not good for this matter. I think that two coordinates are enough,X and Y. They can be the coordinates of the nose,because it is always in the middle of every face. It is relevant to knows how big should be the layer of the new face,too. This is the Automate BPA code that I wrote :
    <AMVARIABLE NAME="nome_foto" TYPE="TEXT"></AMVARIABLE>
    <AMVARIABLE NAME="estensione_foto" TYPE="TEXT"></AMVARIABLE>
    <AMSET VARIABLENAME="nome_foto">br</AMSET>
    <AMSET VARIABLENAME="estensione_foto">.jpeg</AMSET>
    <AMVARIABLE NAME="numero_foto" TYPE="NUMBER"></AMVARIABLE>
    <AMVARIABLE NAME="coord_x" TYPE="NUMBER"></AMVARIABLE>
    <AMVARIABLE NAME="coord_y" TYPE="NUMBER"></AMVARIABLE>
    <AMWINDOWMINIMIZE WINDOWTITLE="Aggiungere_layer - AutoMate BPA Agent
    Task Builder" />
    <AMWINDOWMINIMIZE WINDOWTITLE="AutoMate BPA Server Management Console
    - localhost (Administrator)" AM_ONERROR="CONTINUE" />
    <AMENDPROCESS PROCESS="E:\Programmi_\Adobe Photoshop
    CS5\Photoshop.exe" AM_ONERROR="CONTINUE" />
    <AMRUN FILE="%&quot;E:\Programmi_\Adobe Photoshop CS5\Photoshop.exe&quot;%" />
    <AMPAUSE ACTION="waitfor" SCALAR="15" />
    <AMSENDKEY>{CTRL}o</AMSENDKEY>
    <AMPAUSE ACTION="waitfor" SCALAR="1" />
    <AMINPUTBOX RESULTVARIABLE="numero_foto">Inserire numero FOTO di
    partenza -1</AMINPUTBOX>
    <AMINCREMENTVARIABLE RESULTVARIABLE="numero_foto" />
    <AMPAUSE ACTION="waitfor" SCALAR="1" />
    <AMMOUSEMOVEOBJECT WINDOWTITLE="Apri" OBJECTNAME="%nome_foto &amp;
    numero_foto &amp; estensione_foto%" OBJECTCLASS="SysListView32"
    OBJECTTYPE="ListItem" CHECKOBJECTNAME="YES" CHECKOBJECTCLASS="YES"
    CHECKOBJECTTYPE="YES" />
    <AMMOUSECLICK CLICK="double" />
    <AMPAUSE ACTION="waitfor" SCALAR="10" />
    <AMSENDKEY>{CTRL}+</AMSENDKEY>
    <AMPAUSE ACTION="waitfor" SCALAR="20" />
    <AMSENDKEY>l</AMSENDKEY>
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="429" MOVEY="281" RELATIVETO="screen" />
    <AMMOUSECLICK />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="659" MOVEY="281" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="659" MOVEY="546" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="429" MOVEY="546" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="429" MOVEY="281" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMSENDKEY>v</AMSENDKEY>
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK CLICK="hold_down" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="131" MOVEY="99" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="99" MOVEY="162" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK CLICK="release" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMINPUTBOX RESULTVARIABLE="coord_x">Inserire coordinata X</AMINPUTBOX>
    <AMINPUTBOX RESULTVARIABLE="coord_y">Inserire coordinata Y</AMINPUTBOX>
    <AMMOUSEMOVE MOVEX="200" MOVEY="200" RELATIVETO="screen" />
    <AMMOUSECLICK CLICK="hold_down" />
    <AMMOUSEMOVE MOVEX="%coord_x%" MOVEY="%coord_y%" RELATIVETO="position" />
    <AMMOUSECLICK />
    and this is a short video to explain better what I want to do :
    http://www.flickr.com/photos/26687972@N03/5331705934/
    In the last scene of the video you will see the script asking to input the X and the Y coordinates of the nose. This request is time consuming. For this reason I want to write a script that captures automatically the coordinates of the mouse clicks. The only thing to do should be click over the nose and the script should make the rest. As "c.pfaffenbichler" suggested here : http://forums.adobe.com/thread/775219, I could explore 3 ways :
    1) use the Color Sampler Tool’s input with a conventional Photoshop Script.
    2) use After Effects would provide a better solution.
    3) Photoshop’s Animation Panel might also offer some easier way as it might be possible to load two movies (or one movie and one image) and animate the one with the rendered head in relation to the other.
    Since I'm a totally newbie in graphic and animation,could you help me to explore these ways ? Thanks for your cooperation.

    These are the coordinates of the contours of the face that you see on the picture. Can you explain to me how they are calculated ? The coordinates of the first colums are intuitive,but I'm not able to understand how are calculated the coordinates of the second one.
    Thanks.
    1 COL     2 COL (how are calculated these values ?)
    307.5000 182.0000 m
    312.5000 192.0000 l
    321.5000 194.0000 l
    330.5000 193.0000 l
    335.0000 187.0000 l
    337.0000 180.5000 l
    340.0000 174.0000 l
    338.5000 165.5000 l
    336.0000 159.0000 l
    331.5000 153.0000 l
    324.5000 150.0000 l
    317.0000 154.0000 l
    312.5000 161.0000 l
    309.0000 173.0000 l
    307.5000 182.0000 l
    Message was edited by: LaoMar

  • I need to get mouse click???? Pls help!!!!!!!!!!!!!

    I have to wait & get a mouse click into textframe and again the process should continue.Please help!!
    Actually I can get cursor position. But every time the user will have to run the script again and again.

    Hi, I have tried the following code:
    byte b1 = 1;
    byte b2 = 2;
    byte b3 = 4;
    byte b4 = 8;
    byte results = 0;
    results |= b1;
    results |= b3;
    results |= b4;
    System.out.println(results == (results | b1));
    System.out.println(results == (results | b2));
    System.out.println(results == (results | b3));
    System.out.println(results == (results | b4));And the result is:
    true
    false
    true
    true
    However, I noticed that it's important to assign the bytes the values of the bits right to left:
    0000 0001
    0000 0010
    0000 0100
    0000 1000
    The first byte should have value 1
    The second should have value 2
    The third should have value 4
    The fourth should have value 8
    So that the | operator works.

  • Mouse 'clicks' itself! Help!

    My Macbook's "mouse" clicks itself!
    Sometimes when I'm typing, my Macbook's "mouse" will click itself and put the cursor wherever the mouse happens to be at the time. If it is behind it, it highlights everything I have already typed, and when I type the next letter, it all gets deleted. This is getting ridiculous. Help?
    It is NOT set to "tap to click," it just sometimes randomly clicks itself.
    I'm not the only one with this issue (someone over on Yahoo forums has the same).
    Help?

    Hi loveistheonlyway and welcome to Apple Discussions!
    It sounds very much like you have a hardware issue with your MacBook. If it is still under warranty or if you purchase an AppleCare Protection Plan, contact Apple (800-275-2273) and see about getting a repair set up. Alternatively you can carry the MacBook in to an Apple retail store for the repair. Be sure to [make an appointment|http://www.apple.com/retail/geniusbar> first as otherwise you may spend a long time waiting to talk to a Mac Genius.
    You can do the same things if you are out of warranty, but you may have to pay for the repair.
    Best of luck.

  • HELP - mouse click no longer working - Tiger bug?

    Hi Guys,
    I had a weird issue with Tiger (10.4.10) on my PowerBook G4 this evening. I was dragging a file to the trash, and "dropped" it onto the dock by mistake, just missing the trash. I was slightly to the left of the trashcan. I expected the icon to jump back to the desktop, as the place I had dropped it was invalid, but to my surprise, as I moved the pointer across the screen with the mouse button unclicked, a ghost version of the icon was still attached to the mouse pointer.
    I was unable to click on anything, as the OS still believed for some reason that I was dragging this icon around. I used the keyboard to reboot the laptop, and when it came back up, the mouse click was not working - I can drag around, but can't click on anything. This is with the on board trackpad. I also have a bluetooth apple mouse, which exhibits exactly the same behaviour.
    I've rebooted several times (and shutdown and removed the battery), zapped the PRAM. Nothing has helped. I've tried logging in as a different user, but the click still doesn't work with the on-board or external mouse. It's like something within the OS has been corrupted, but I don't know what I can do. I have loads of data on the laptop, so I am not rebuilding. There is something on the help pages about resetting my PowerBook PMU, but I don't think this should be required.
    This is a major, urgent issue for me, as I can't use the laptop until I figure out how to resolve this.
    Anyone - please help
    Thanks,
    Robin

    Thanks for the feedback. Since resetting the PMU fixed the problem, it's not a bug but some conflict in the original setup.
    If you want to report this to Apple, either send Feedback or send bug reports and enhancement requests to Apple via its Bug Reporter system. Join the Apple Developer Connection (ADC)—it's free and available for all Mac users and gets you a look at some development software. Since you already have an Apple username/ID, use that. Once a member, go to Apple BugReporter and file your bug report/enhancement request. The nice thing with this procedure is that you get a response and a follow-up number; thus, starting a dialog with engineering.

  • My iMac doesn't recognize mouse clicks... HELP!

    Ok, I reset the SMC and PRAM (and repaired permissions)that made the mouse work until I shut down then I would have the problem again when I started up so I would have to zap the PRAM again.  I downloaded Mountain Lion and loaded it thinking this would overwrite any errors but now I can't log in at all. Even zapping the PRAM can't get it to recognize mouse clicks (the courser does move) .  Somebody please give me some advice I have total work stopage and I'm desperate!

    Bootup holding CMD+r, or the Option/alt key to boot from the Restore partitirion & use Disk Utility from there to Repair the Disk, then Repair Permissions.
    If that doesn't help Reinstall the OS.

  • Scripting a mouse click and drag

    does anyone know how to script a mouse click and drag. I tried XTools. No luck. What about Cliclick. I had tons of success with TextCommands but I dont know how to get OSAX plugin code to work. Thanks in advance.
    I am trying to move a desktop clock (QuartzClock) from the center of the screen to the side.

    I tried (unsuccessfully) to find a mouse move and click solution in Applescript.
    My search brought me to this site: http://www.geekorgy.com/index.php/2010/06/python-mouse-click-and-move-mouse-in-a pple-mac-osx-snow-leopard-10-6-x/
    The following python script will move an object from position 60.100 to 60.300
    #!/usr/bin/python
    import sys
    import time
    from Quartz.CoreGraphics import * # imports all of the top-level symbols in the module
    def mouseEvent(type, posx, posy):
    theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
    CGEventPost(kCGHIDEventTap, theEvent)
    def mousemove(posx,posy):
    mouseEvent(kCGEventMouseMoved, posx,posy);
    def mouseclickdn(posx,posy):
    mouseEvent(kCGEventLeftMouseDown, posx,posy);
    def mouseclickup(posx,posy):
    mouseEvent(kCGEventLeftMouseUp, posx,posy);
    def mousedrag(posx,posy):
    mouseEvent(kCGEventLeftMouseDragged, posx,posy);
    ourEvent = CGEventCreate(None);
    currentpos=CGEventGetLocation(ourEvent); # Save current mouse position
    mouseclickdn(60, 100);
    mousedrag(60, 300);
    mouseclickup(60, 300);
    time.sleep(1);
    mousemove(int(currentpos.x),int(currentpos.y)); # Restore mouse position
    See also:
    http://developer.apple.com/mac/library/documentation/Carbon/Reference/QuartzEven tServicesRef/Reference/reference.html
    http://developer.apple.com/graphicsimaging/pythonandquartz.html
    Tony

  • Applescript help pt 2...Mouse Clicks & Click Lock?

    Hi all,
    Second challenge for me, it would be great to be able to use voice commands for mouse clicks. Most specifically I would like to be able to do a click-lock so that I can draw with a trackball and not have to hold down the button. It would be nice as well to be able to single and double click...
    I tried to figure it out based on the help I got in the last thread but could use a nudge in the right direction.
    Thanks!!!

    I suggest you take a look at this it has an example of the Systems Events 'click'
    I actually had seen this but it ties the click event to a specific button. When I tried to program just a click event w/o a button or target specified it did not seem to work.
    I would need something like "click current mouse position"....
    You should also re-think the click and hold idea. A click/hold/drag/release, is really just a select/copy/paste if done with menus.
    What I need to do click lock for is to control drawing in Adobe Illustrator. I need to be able to use alternative tools to the Wacom Pen, because no matter how good a tool is if you use it enough hours you will get hand fatigue. I want to be able to draw part of the time with a large trackball, and in order to make that work the mouse button has to be held down continuously while drawing.
    Message was edited by: V Silly

  • HT201361 After taking the screenshot clicking on my trackpad just acting like right mouse click or 2 finger click. Could you help!

    After taking a screenshot command + Shift + 4, clicking on my trackpad is like right mouse click or 2 finger click. Please help!

    Maybe your trackpad battery is running low? If not I would suggest just restarting your Mac. Post again if those things don't fix your problem and some more involved problem-solving can be attempted.

  • Draw with single mouse click, help me!!!!

    I am using this code - as you understood from it- to paint with the mouse click.
    please help me either by completing it or by telling me what to do.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class Hello extends JFrame{
         Graphics g;
         ImageIcon icon = new ImageIcon("hello.gif");
         public Hello(){
              super("Hello");
              setSize(200, 200);
              addMouseListener(
                   new MouseAdapter(){
                        public void mouseClicked(MouseEvent e){
                             icon.paintIcon(Hello.this, g, e.getX(), e.getY());
                             g.fillRect(10, 40, 10, 80);
                             JOptionPane.showMessageDialog(Hello.this, e.getX() + ", " + e.getY());
                             //repaint();
         // i have tried to place this listener in the paint method, but no way out.
              setVisible(true);
         public void paint(final Graphics g){
              this.g = g;
              icon.paintIcon(this, g, 100, 50);
         public static void main(String[] args){
              new Hello();
    **

    You can't save a graphics object like that and then paint on it.
    What you need is to use a BufferedImage, paint on that, and then paint that to the screen.
    See my paintarea class. You are welcome to use + modify this class as well as take any code snippets to fit into whatever you have but please add a comment where ever you've incorporated stuff from my class
    PaintArea.java
    ===========
    * Created on Jun 15, 2005 by @author Tom Jacobs
    package tjacobs.ui;
    import java.awt.image.BufferedImage;
    import java.awt.*;
    import java.awt.event.*;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import javax.swing.ImageIcon;
    import javax.swing.JComboBox;
    import javax.swing.JComponent;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JToolBar;
    import javax.swing.SwingUtilities;
    import tjacobs.MathUtils;
    * PaintArea is a component that you can draw in similar to but
    * much simpler than the windows paint program.
    public class PaintArea extends JComponent {
         BufferedImage mImg; //= new BufferedImage();
         int mBrushSize = 1;
         private boolean mSizeChanged = false;
         private Color mColor1, mColor2;
         static class PaintIcon extends ImageIcon {
              int mSize;
              public PaintIcon(Image im, int size) {
                   super(im);
                   mSize = size;
         public PaintArea() {
              super();
              setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
              addComponentListener(new CListener());
              MListener ml = new MListener();
              addMouseListener(ml);
              addMouseMotionListener(ml);
              setBackground(Color.WHITE);
              setForeground(Color.BLACK);
         public void paintComponent(Graphics g) {
              if (mSizeChanged) {
                   handleResize();
              //g.drawImage(mImg, mImg.getWidth(), mImg.getHeight(), null);
              g.drawImage(mImg, 0, 0, null);
              //super.paintComponent(g);
              //System.out.println("Image = " + mImg);
              //System.out.println("Size: " + mImg.getWidth() + "," + mImg.getHeight());
         public void setBackground(Color c) {
              super.setBackground(c);
              if (mImg != null) {
                   Graphics g = mImg.getGraphics();
                   g.setColor(c);
                   g.fillRect(0, 0, mImg.getWidth(), mImg.getHeight());
                   g.dispose();
         public void setColor1(Color c) {
              mColor1 = c;
         public void setColor2(Color c) {
              mColor2 = c;
         public Color getColor1() {
              return mColor1;
         public Color getColor2() {
              return mColor2;
         class ToolBar extends JToolBar {
              ToolBar() {
                   final ColorButton fore = new ColorButton();
                   fore.setToolTipText("Foreground Color");
                   final ColorButton back = new ColorButton();
                   back.setToolTipText("Background Color");
                   JComboBox brushSize = new JComboBox();
                   //super.createImage(1, 1).;
                   FontMetrics fm = new FontMetrics(getFont()) {};
                   int ht = fm.getHeight();
                   int useheight = fm.getHeight() % 2 == 0 ? fm.getHeight() + 1 : fm.getHeight();
                   final BufferedImage im1 = new BufferedImage(useheight, useheight, BufferedImage.TYPE_INT_RGB);
                   Graphics g = im1.getGraphics();
                   g.setColor(Color.WHITE);
                   g.fillRect(0, 0, useheight, useheight);
                   g.setColor(Color.BLACK);
                   g.fillOval(useheight / 2, useheight / 2, 1, 1);
                   g.dispose();
                   //im1.setRGB(useheight / 2 + 1, useheight / 2 + 1, 0xFFFFFF);
                   final BufferedImage im2 = new BufferedImage(useheight, useheight, BufferedImage.TYPE_INT_RGB);
                   g = im2.getGraphics();
                   g.setColor(Color.WHITE);
                   g.fillRect(0, 0, useheight, useheight);
                   g.setColor(Color.BLACK);
                   g.fillOval(useheight / 2 - 1, useheight / 2 - 1, 3, 3);
                   g.dispose();
    //               im2.setRGB(useheight / 2 - 1, useheight / 2 - 1, 3, 3, new int[] {     0, 0xFFFFFF, 0,
    //                                                            0xFFFFFF, 0xFFFFFFF, 0xFFFFFF,
    //                                                            0, 0xFFFFFF, 0}, 0, 1);
                   final BufferedImage im3 = new BufferedImage(useheight, useheight, BufferedImage.TYPE_INT_RGB);
                   g = im3.getGraphics();
                   g.setColor(Color.WHITE);
                   g.fillRect(0, 0, useheight, useheight);
                   g.setColor(Color.BLACK);
                   g.fillOval(useheight / 2 - 2, useheight / 2 - 2, 5, 5);
                   g.dispose();
    //               im3.setRGB(useheight / 2 - 2, useheight / 2 - 2, 5, 5, new int[] {     0, 0, 0xFFFFFF, 0, 0, 
    //                                                            0, 0xFFFFFF, 0xFFFFFFF, 0xFFFFFF, 0,
    //                                                            0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF,
    //                                                            0, 0xFFFFFF, 0xFFFFFFF, 0xFFFFFF, 0,
    //                                                            0, 0, 0xFFFFFF, 0, 0}, 0, 1);
                   //JLabel l1 = new JLabel("1 pt", new ImageIcon(im1), JLabel.LEFT);
                   //JLabel l2 = new JLabel("3 pt", new ImageIcon(im2), JLabel.LEFT);
                   //JLabel l3 = new JLabel("5 pt", new ImageIcon(im3), JLabel.LEFT);
                   brushSize.addItem(new PaintIcon(im1, 1));
                   brushSize.addItem(new PaintIcon(im2, 3));
                   brushSize.addItem(new PaintIcon(im3, 5));
                   //brushSize.addItem("Other");
                   add(fore);
                   add(back);
                   add(brushSize);
                   PropertyChangeListener pl = new PropertyChangeListener() {
                        public void propertyChange(PropertyChangeEvent ev) {
                             Object src = ev.getSource();
                             if (src != fore && src != back) {
                                  return;
                             Color c = (Color) ev.getNewValue();
                             if (ev.getSource() == fore) {
                                  mColor1 = c;
                             else {
                                  mColor2 = c;
                   fore.addPropertyChangeListener("Color", pl);
                   back.addPropertyChangeListener("Color", pl);
                   fore.changeColor(Color.BLACK);
                   back.changeColor(Color.WHITE);
                   brushSize.addItemListener(new ItemListener() {
                        public void itemStateChanged(ItemEvent ev) {
                             System.out.println("ItemEvent");
                             if (ev.getID() == ItemEvent.DESELECTED) {
                                  return;
                             System.out.println("Selected");
                             Object o = ev.getItem();
                             mBrushSize = ((PaintIcon) o).mSize;
                   //Graphics g = im1.getGraphics();
                   //g.fillOval(0, 0, 1, 1);
                   //BufferedImage im1 = new BufferedImage();
                   //BufferedImage im1 = new BufferedImage();
         protected class MListener extends MouseAdapter implements MouseMotionListener {
              Point mLastPoint;
              public void mouseDragged(MouseEvent me) {
                   Graphics g = mImg.getGraphics();
                   if ((me.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {
                        g.setColor(mColor1);
                   } else {
                        g.setColor(mColor2);
                   Point p = me.getPoint();
                   if (mLastPoint == null) {
                        g.fillOval(p.x - mBrushSize / 2, p.y - mBrushSize / 2, mBrushSize, mBrushSize);
                        //g.drawLine(p.x, p.y, p.x, p.y);
                   else {
                        g.drawLine(mLastPoint.x, mLastPoint.y, p.x, p.y);
                        //g.fillOval(p.x - mBrushSize / 2, p.y - mBrushSize / 2, mBrushSize, mBrushSize);
                        double angle = MathUtils.angle(mLastPoint, p);
                        if (angle < 0) {
                             angle += 2 * Math.PI;
                        double distance = MathUtils.distance(mLastPoint, p) * 1.5;
                        if (angle < Math.PI / 4 || angle > 7 * Math.PI / 4 || Math.abs(Math.PI - angle) < Math.PI / 4) {
                             for (int i = 0; i < mBrushSize / 2; i ++) {
                                  g.drawLine(mLastPoint.x, mLastPoint.y + i, p.x, p.y + i);
                                  g.drawLine(mLastPoint.x, mLastPoint.y - i, p.x, p.y - i);
    //                              System.out.println("y");
    //                              System.out.println("angle = " + angle / Math.PI * 180);
                        else {
                             for (int i = 0; i < mBrushSize / 2; i ++) {
                                  g.drawLine(mLastPoint.x + i, mLastPoint.y, p.x + i, p.y);
                                  g.drawLine(mLastPoint.x  - i, mLastPoint.y, p.x - i, p.y);
    //                              System.out.println("x");
    //                    System.out.println("new = " + PaintUtils.printPoint(p));
    //                    System.out.println("last = " + PaintUtils.printPoint(mLastPoint));
                        //System.out.println("distance = " + distance);
                        //Graphics2D g2 = (Graphics2D) g;
                        //g2.translate(mLastPoint.x + mBrushSize / 2, mLastPoint.y);
                        //g2.rotate(angle);
                        //g2.fillRect(0, 0, (int) Math.ceil(distance), mBrushSize);
                        //g2.rotate(-angle);
                        //g2.translate(-mLastPoint.x + mBrushSize / 2, -mLastPoint.y);
    //                    g.setColor(Color.RED);
    //                    g.drawRect(p.x, p.y, 1, 1);
                   mLastPoint = p;
                   g.dispose();
                   repaint();
              public void mouseMoved(MouseEvent me) {}
              public void mouseReleased(MouseEvent me) {
                   mLastPoint = null;
         private void handleResize() {
              Dimension size = getSize();
              mSizeChanged = false;
              if (mImg == null) {
                   mImg = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
                   Graphics g = mImg.getGraphics();
                   g.setColor(getBackground());
                   g.fillRect(0, 0, mImg.getWidth(), mImg.getHeight());
                   g.dispose();
              else {
                   int newWidth = Math.max(mImg.getWidth(),getWidth());
                   int newHeight = Math.max(mImg.getHeight(),getHeight());
                   if (newHeight == mImg.getHeight() && newWidth == mImg.getWidth()) {
                        return;
                   BufferedImage bi2 = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_RGB);
                   Graphics g = bi2.getGraphics();
                   g.setColor(getBackground());
                   g.fillRect(0, 0, bi2.getWidth(), bi2.getHeight());
                   g.drawImage(mImg, mImg.getWidth(), mImg.getHeight(), null);
                   g.dispose();
                   mImg = bi2;
         public JToolBar getToolBar() {
              if (mToolBar == null) {
                   mToolBar = new ToolBar();
              return mToolBar;
         private ToolBar mToolBar;
         public static void main (String args[]) {
              PaintArea pa = new PaintArea();
              JPanel parent = new JPanel();
              parent.setLayout(new BorderLayout());
              parent.add(pa, BorderLayout.CENTER);
              pa.setPreferredSize(new Dimension(150, 150));
              parent.add(pa.getToolBar(), BorderLayout.NORTH);
              WindowUtilities.visualize(parent);
         protected class CListener extends ComponentAdapter {
              public void componentResized(ComponentEvent ce) {
                   mSizeChanged = true;
    }

  • How modificate this script from mouse click to release

    how modificate this script from mouse click to release
    package
    * A Colorful Fireworks Demonstration in Actionscript 3
    *   from shinedraw.com
    import flash.events.MouseEvent;
    import flash.system.ApplicationDomain;
    import flash.events.Event;
    import flash.display.MovieClip;
    import com.shinedraw.effects.ColorfulFireworks;
    public class Document extends MovieClip{
    private var _colorfulFireworks : ColorfulFireworks;
    public function Document(){
    this.addEventListener(Event.ADDED_TO_STAGE, on_added_to_stage);
    private function on_added_to_stage(e : Event):void{
    // place the object to the stage
    _colorfulFireworks = new ColorfulFireworks();
    addChild(_colorfulFireworks);
    // add the cover to save CPU time
    var coverClass : Class = ApplicationDomain.currentDomain.getDefinition("Cover") as Class;
    var cover : MovieClip = new coverClass();
    addChild(cover);
    cover.addEventListener(MouseEvent.CLICK, on_cover_click);
    // remove the cover after click
    private function on_cover_click(e:MouseEvent):void{
    var cover:MovieClip = e.target as MovieClip;
    removeChild(cover);
    _colorfulFireworks.start();

    solved close pls

  • Automator - How do I: Mouse Click, Move Windows, and more

    Hello,
    I am attempting to create my own Automator programs and for a while I had some that worked nicely. I have recently been tweaking my iMac so that it can "think" on its own (by automator of course) and do things for me. However, I've run across a block with Mavericks (I believe it's due to Mavericks).
    1. How can I get Automator to register a mouse click? "Watch me do" does not seem to want to work for me at all. I also would prefer if it would just be a registered mouse click, but not actually use the mouse (I know this is possible) so that if I'm doing something and it runs, it won't disturb my mouse and I can keep working.
    2. How can I register a keyboard stroke? Same as above
    3. How can I have automator move windows? I have two monitors and there are times when I may want it to move a window from one mintor to another
    The following is a list of all the things I'm attempting to accomplish at the moment (with other things when I think of them) with automator (either through applications, folder actions, or ical actions):
    1. Register a mouse click at a given area or on a given element in a safari page
    2. Register a keyboard stroke in a given program (be able to focus on a program and then do the keystroke)
    3. Move windows from one location to another
    4. Full-screen and Un-full-screen iTunes at certain times of day
    5. Download all purchased items on iTunes that aren't on the computer (sometimes iTunes doesn't download stuff if it was downloaded on my MacBook Pro first)
    6. Automatically voice read reminders (that I've set in Reminders) each day at a given time (I can use loop to repeat it to make sure I hear it all)
    I'll think of more of course, but the mouse click, keyboard stroke, and moving windows is the big thing I'm trying to figure out how to do. Can anyone help?
    Also, I am not a computer tech. I am tinkering with this because it's fun and helpful, but an answer of "just use applescript" or "just use java" will likely just give me a headache. I know that it's going to be one of those codes, but I'm hoping someone has a "base" code that can be copied and pasted that's just a standard click that I can adjust for where I need to click and what process I need to click on.
    If there is an Action Pack that includes a "Register Mouse Click" and/or "Register Keyboard Stroke", then that would work great, but the only action packs for automator I've seen that work with Mavericks is for photoshop.

    You're asking for a lot in one post.  It would be better to break your requests down a bit. 
    For example, to deal with mouse clicks, you can use the Automator Action Run Shell Script with this python script:
    import sys
    import time
    from Quartz.CoreGraphics import *
    def mouseEvent(type, posx, posy):
            theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
            CGEventPost(kCGHIDEventTap, theEvent)
    def mousemove(posx,posy):
            mouseEvent(kCGEventMouseMoved, posx,posy);
    def mouseclick(posx,posy):
            mouseEvent(kCGEventLeftMouseDown, posx,posy);
            mouseEvent(kCGEventLeftMouseUp, posx,posy);
    ourEvent = CGEventCreate(None);
    # Save current mouse position
    currentpos=CGEventGetLocation(ourEvent);
    # Click the "Apple"
    mouseclick(25, 5);  
    # 1 second delay       
    time.sleep(1);        
    # Restore mouse position
    mousemove(int(currentpos.x),int(currentpos.y))
    It will look like this in Automator:
    To drag something (i.e. a window, a file icon) from position 40,60 to 60,300:
    import time
    from Quartz.CoreGraphics import *
    def mouseEvent(type, posx, posy):
               theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
               CGEventPost(kCGHIDEventTap, theEvent)
    def mousemove(posx,posy):
               mouseEvent(kCGEventMouseMoved, posx,posy);
    def mouseclickdn(posx,posy):
               mouseEvent(kCGEventLeftMouseDown, posx,posy);
    def mouseclickup(posx,posy):
               mouseEvent(kCGEventLeftMouseUp, posx,posy);
    def mousedrag(posx,posy):
               mouseEvent(kCGEventLeftMouseDragged, posx,posy);
    ourEvent = CGEventCreate(None);
    # Save current mouse position
    currentpos=CGEventGetLocation(ourEvent);
    # move mouse to upper left of screen
    mouseclickdn(40, 60);
    # drag icon to new location
    mousedrag(60, 300);
    # release mouse
    mouseclickup(60, 300);
    # necessary delay
    time.sleep(1);
    # return mouse to start positon
    mouseclickdn(int(currentpos.x),int(currentpos.y));
    For keystokes in AppleScript (which can be added to Automator with the Run Applescript Action) see: http://dougscripts.com/itunes/itinfo/keycodes.php

  • Is there a way to simulate a mouse click anywhere on a screen in Dictate ?

    I'm using Dictate because of hand problems. Unfortunately, it does not seem to have the ability as supplied to simulate mouse clicks anywhere on the screen as Dragon Naturally Speaking does on the Windows side.( I do not mean by this the ability to select an item in the menu, which It does have the built in ability to do.) It can, however, so I read, be scripted to do a lot of things. Is there an Applescript out there that would allow for the simulation of mouse clicks anywhere on the screen (as opposed to just on a UI item)?

    Platform: 2.2 gHz iMac using Mac OS X 10.5.5; Dictate v. 1.2.1 Build
    Okay, so, here, after a great deal of research, is a procedure for implementing a single mouse click anywhere on the screen. Since it’s a procedure, I’m detailing each step.
    !. Download the scripting addition (sometimes known as an OSAX) xTool.sax from: http://lestang.org/osax/XTool/XTool-2.0.dmg.tgz. You will have to decompress the file (StuffIt) and double-click it to get it to unfold into a .dmg (disk image) file. In this file you will find the file Xtool.osax. Drag it into your MacHD (or whatever the name of your topmost volume is)/library/ScriptingAdditions (no spaces in the name) folder. The purpose of this is to place it into a folder where Applescript is expecting to find scripting additions. In other words, it’s hard-coded and you can’t just drop it anywhere because Applescript may not find it. Also, there may be more than one Library folder in other directories. Under 10.5.5. which I’m running, I can tell you it works where I placed it.
    The effect all of this has is that when you create your script in Dictate’s New Commands window (Script Editor), Dictate will know what the commands “click mouse’ and “position of the mouse” mean. These are not standard Applsecript commands but are additions, hence the name Scripting Additions.
    2. Start Dictate and in the File drop-down select New Command. This will take you to a window with a pane on the left with names such as Applications, Global, and several others. Click on Global (so that the command will be recognized no matter what application your are in). To the right of the pane you will see a number of commands listed by name and, underneath, a (very small) “+” (and a minus sign and a small icon). Ignore everything but the “+”. Click on the “+”.
    Below several boxes will appear: Command, Description, Context, Type.
    In Command Name type in the name you want Dictate to recognize to do the click. (I call mine Mouse click.) In Description you can type something like Single-clciks the mouse. In the Context drop-down make sure to select Global. In the Type drop-down, select Applescript.
    Paste the following into Text Edit (orTexEdit Plus,if you have that):
    click mouse {(position of the mouse), [1]}
    For reasons unknown to me, you can’t just select that text, copy, and paste it into Dictate’s Script Editor winodw. You will have to select it in Text Edit and drag it into the Source text box.
    Click on the Compile button at the left bottom. After it finishes compiling (a matter of seconds if everything is normal), click on the Run button with your mouse. If all has gone well, you will very likely see the Run button get pressed repeatedly. Take your mouse off the button so it stops blinking like mad. (The Mouse click Appplescript is repeatedly looking at the position it find itself and clicking again, and again.)
    While your mileage may vary, I have been able to simulate single mouse-click using this workaround.
    So far, I have not been able to simulate a double-click reliably. There is, I believe, an issue with the amount of time between the two clicks (a parameter of the click mouse command above which I did not go into here). For anyone out there who wants to work on that, I would be glad to hear your results. I’ve tried values up to 2000 in the DELAY parameter after the TIMES parm. Here is what the dictionary shows for this command.
    click mouse?v
    click mouse [point] : where to do the mouse click
    [times integer] : how many times you want to clik the mouse
    [delay integer] : delay between two mouse clicks
    [using primary button/secondary button/middle button] : which mouse button
    If I get this to work I will let my fellow sufferers know.
    Thanks to Hiroto and Andrew99 in particular for their help.

Maybe you are looking for