Copy/paste icons & icns using AppleScriptObjC

I'm opening a new thread following this one to see what can be done with AppleScriptObjC.
As an Applescripter since 1992, it's my duty to learn this language.
My need is very simple on paper: copy an icon, icns or image file to paste it on a Finder item.
Running Mountain Lion 10.8.5, I'm still using Xcode 3.2.6 because I'm not familiar with AppleScriptObjC and I need to make and update several Applescript based applications for my work.
If I'm not wrong, it's impossible to have 2 versions of Xcode on the same startup disk.
Is it possible to write AppleScriptObjC scripts in Applescript Editor or even Script Debugger?
Red_menace, if you are here…

@Red_menace
Your project is a piece of art!
But I need time to read and undersatand everything.
It's not so hard. Just some things are obscure for me.
For example, I understand why you call current application's to get NSEvent's modifierFlags()
But why for NSImage's alloc's initWithContentsOfFile_??
@twtwtw
I made a Applet as you said and pasted in the following code.
No way to make it run.
I'm missing something. But what?
script iconTest
          property NSWorkspace : class "NSWorkspace"
          property NSImage : class "NSImage"
          on run
  -- first, an icns file
                    set filePath to "/Users/xxx/Desktop/iconChange/dossier sans titre 1"
                    set imagePath to "/Volumes/MacPro 2/xxx/Icones en cours/2013 icons by Factory/excel/excel-16.icns"
                    set image to NSImage's alloc's initWithContentsOfFile_(imagePath)
  NSWorkspace's sharedWorkspace()'s setIcon_forFile_options_(image, filePath, 0)
  -- second, a folder with custom icon
                    set filePath to "/Users/xxx/Desktop/iconChange/dossier sans titre 2"
                    set imagePath to "/Volumes/MacPro 2/xxx/Icones en cours/2013 icons by Factory/marques"
                    set image to NSWorkspace's sharedWorkspace's iconForFile_(imagePath)
  NSWorkspace's sharedWorkspace's setIcon_forFile_options_(image, filePath, 0)
          end run
end script

Similar Messages

  • Copy/Paste in JTextField using JMenuItems/Keystrokes

    I'm having trouble getting this to work, could someone please point me in the right direction? I've made this as much SCCE as possible so it probably won't compile but you can see what I'm trying to do... Neither the menu items nor the keypresses seem to copy or paste.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    public class Main extends JFrame implements ActionListener, KeyListener
        private JMenuBar menuBar;
        private JMenu mEdit;
        private JMenuItem copyItem, pasteItem;
        private JTextField output;
        private static final int WIN_WIDTH=300, WIN_HEIGHT=300;
        public Main()
            super("Main");
            this.setSize(WIN_WIDTH,WIN_HEIGHT);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setLayout(new BorderLayout());
            this.setJMenuBar(createMenu());
            this.setResizable(false);
            this.setIconImage(new ImageIcon("icon.png").getImage());
            this.addKeyListener(this);
            this.setFocusable(true);
            this.add(createTxtField());
        public Component createTxtField()
            output = new JTextField();
            output.setBounds(5, 5, 240, 30);
            // output.setEditable(false);
            output.setVisible(true);
            output.setEnabled(true);
            output.setText("0.");
            output.setBackground(Color.WHITE);
            output.setHorizontalAlignment(JTextField.RIGHT);
            return output;
        public JMenuBar createMenu()
            // Create the menu bar.
            menuBar = new JMenuBar();
            // Build the first menu.
            mEdit = new JMenu("Edit");
            menuBar.add(mEdit);
            // Build items for first menu.
            copyItem = new JMenuItem("Copy", KeyEvent.VK_C);
            copyItem.setAccelerator(KeyStroke.getKeyStroke(
                    KeyEvent.VK_C, ActionEvent.CTRL_MASK));
            copyItem.addActionListener(this);
            copyItem.addKeyListener(this);
            mEdit.add(copyItem);
            pasteItem = new JMenuItem("Paste", KeyEvent.VK_V);
            pasteItem.setAccelerator(KeyStroke.getKeyStroke(
                    KeyEvent.VK_V, ActionEvent.CTRL_MASK));
            pasteItem.addActionListener(this);
            pasteItem.addKeyListener(this);
            mEdit.add(pasteItem);
            return menuBar;
        public void actionPerformed(ActionEvent e)
            if (e.getActionCommand().equals("Copy"))
                output.selectAll();
                output.copy();
            else if (e.getActionCommand().equals("Paste"))
                output.selectAll();
                output.paste();
            else
                //  performAction(e.getActionCommand());
        public void keyPressed(KeyEvent e)
            if (e.equals(KeyStroke.getKeyStroke
                    (KeyEvent.VK_C, ActionEvent.CTRL_MASK)))
                output.selectAll();
                output.copy();
            else if (e.equals(KeyStroke.getKeyStroke
                    (KeyEvent.VK_V, ActionEvent.CTRL_MASK)))
                output.selectAll();
                output.paste();
    }

    Actually I was wrong sorry, I just realized while doing other stuff (scientific option). I only changed the code in KeyListener and not in ActionListener.
    The above works perfectly:
    public void actionPerformed(ActionEvent e)
            if (e.getActionCommand().equals("Copy"))
                output.setEditable(true);
                output.selectAll();
                output.copy();
                output.setEditable(false);
            else if (e.getActionCommand().equals("Paste"))
                output.setEditable(true);
                output.selectAll();
                output.paste();
                output.setEditable(false);
        // and same for KeyListener
    public void keyPressed(KeyEvent e)
    }As far as JTextField.copy(); and paste(), it does the from the system clipboard under-the-hood.
    void javax.swing.text.JTextComponent.copy()
    Transfers the currently selected range in the associated text model to the system clipboard, leaving the contents in the text model. The current selection remains intact. Does nothing for null selections.
    See Also:
    java.awt.Toolkit.getSystemClipboard
    java.awt.datatransfer.Clipboard
    Edited by: Gcampton on Sep 19, 2010 12:31 AM-
    Thanks to everyone for your help.

  • Copy & Past picture by using Gmail on FireFox4

    When I have one picture on clipboard, I can "Ctrl+C" and "Ctrl+V" in Gmail body, then send to my friend on FF4. But After I sent, my friend can't see that picture, even I can't see that picture on my "sent" box.

    Hi Peter,
    I'm a new blackberry user but I'm on gmail and luckily it's working fine for me on my 8800... Just a couple of suggestions for you...
    - Have you changed anything in your gmail account? I added IMAP configuration labs and it broke by whole set-up, I had to remove and add the account on the O2 email site again.
    - Are you importing any other accounts into your gmail? I was originally doing a full import into a new gmail account. While this was happening the connection between gmail and my blackberry service would completely break and I would get the "action required - your blackberry is not receiving email" message.
    - Have you thought about getting the gmail app running on the 8800? I'm not sure if there is enough memory on these little things for it, but it might solve the problem?
    Good luck - hope you're able to get it running again.
    J

  • Crashing issue+ copy/ paste issue

    Dear all, I am facing two serious bug issues:
    1) on many www pages I am facing serious issue (e.g. www.makezine.com , but also on almost all others I was browsing). After approx 20 sec to several minutes firefox browser close itself and home android page appear. There is no error message at all
    2) once I copy any text outside firefox browser, then I not end it to any text field on Web page opened under firefox browser, there is no way to paste it
    Can you please fix these bugs? My smartphone is samsung galaxy s5, android v 4.2 (kitkat)
    Thanks.

    Hi olsi:
    * 2. steps to reproduce crash problem as per your screenshots
    ** i) highlight text "display the word 'paste'..."
    ** ii) copy the text
    ** iii) long press on 'Aaa' and then 'Aaa" is selected
    ** iv) tap on combined clipboard copy/paste icon and '''the text 'Aaa' is copied instead the desired behaviour which is to paste "display the word 'paste'..."'''
    * 3. to fix this, the workaround I believe is to do the following instead of 2 iv):
    ** iv) tap on the checkmark icon first to make sure 'Aaa' is not selected and then long press and use the combined clipboard copy/paste icon to paste (or on some devices a Paste icon instead of the combined clipboard copy/paste icon will be shown and you can use this Paste icon). I found this workaround here: https://bugzilla.mozilla.org/show_bug.cgi?id=1086933#c7:
    <blockquote>
    "The "Paste" popup is finicky in the URLBar. Because you had a selection already, we show the ActionBar. If you would have cleared the URLBar selection and then long-pressed, you would have seen the "Paste" popup."
    </blockquote>
    '''Again olsi thanks for your patience and please let us know if the workaround 3 iv) works'''

  • Copy & Paste from Illustrator to InDesign CS4

    Hi,
    I am aware that there are issues when copying/pasting from Illustrator to InDesign, in particular:
    http://help.adobe.com/en_US/InDesign/6.0/WSa285fff53dea4f8617383751001ea8cb3f-6bdda.html
    I have the following problems:
    1- I copy and paste text from Illustrator to InDesign on the same platform and some (not all) of the text is converted to outline in InDesign. The same font is available to both applications. Why this behaviour?
    2- I copy and paste objects containing text from Illustrator to InDesign and some of the objects appear to have moved respective positions when pasted into InDesign. Is this to be expected?
    Are there solutions to these problems? Note that if I expand everything in Illustrator prior to copying and pasting into InDesign, none of these issues occur, but everything is obviously in outline form, with the limitations it entails.
    My clipboard settings are as indicated in the link above, but I have tried other settings with no more luck.
    (Important: Before pasting a graphic, make sure that Illustrator is configured to copy as AICB (see Illustrator Help). In InDesign, make sure that Prefer PDF When Pasting isn’t selected in the Clipboard Handling preferences. If these options aren’t set properly, the Illustrator graphic cannot be edited in InDesign.)
    It is not practical for me to create an Illustrator file for each of the Illustrator graphics and import those files via Place into InDesign. I must use Copy/Paste.
    I use CS4.
    Thanks.

    You can copy/paste from Illy to ID by selecting the text with the type tool in Illy and then pasting it into ID. You will not be able to maintain the formatting. If you want to maintain the appearance the text will be converted to outlines.
    If you need to get anything other than very simple objects from Illy to ID then you should save as AI and use the file > place command to place those objects as linked graphics into ID.
    Your closing statement is irrelevant. Whether you like it or not, this is the way it is.
    Bob

  • Rdesktop and copy/paste on remote machine

    hello,
    Connecting to win 2003 server from my arch.
    Just noticed i can't copy/paste anymore when using rdesktop (had 1.5.0, tried both 1.6.0 and cvs).
    I copy something, and then want to paste it, nothing happens. Right click gives me grayed out paste options.
    Works fine with windows rdp.
    Asked a friend who alse has rdesktop (says 1.5.0) and for him it works fine.
    So it obviously is something with my setup.
    I could swear it worked fine before.
    Regular -Syu user here
    so god knows when this happend and what's the reason.
    Anyone encountered similar issue?
    many thanks

    _saiko wrote:
    hello,
    Connecting to win 2003 server from my arch.
    Just noticed i can't copy/paste anymore when using rdesktop (had 1.5.0, tried both 1.6.0 and cvs).
    I copy something, and then want to paste it, nothing happens. Right click gives me grayed out paste options.
    Works fine with windows rdp.
    Asked a friend who alse has rdesktop (says 1.5.0) and for him it works fine.
    So it obviously is something with my setup.
    I could swear it worked fine before.
    Regular -Syu user here
    so god knows when this happend and what's the reason.
    Anyone encountered similar issue?
    many thanks
    $ rdesktop --help
    '-r clipboard:[off|PRIMARYCLIPBOARD|CLIPBOARD]': enable clipboard
    redirection.
    'PRIMARYCLIPBOARD' looks at both PRIMARY and CLIPBOARD
    when sending data to server.
    'CLIPBOARD' looks at only CLIPBOARD.
    Maybe 1.6.0 turned it off by default?

  • Copy/pasting date dimension to different project

    Hi all,
    We need to copy the date dimension from one project to another. Normally copy/paste can be used, but... not on the date dimension! I tried export/import with mdl but that imports it back to the same project?!
    Thanks,
    Ed

    Hi Ed,
    look at this thread (steps for importing MDL to different project name)
    Re: How to Import Metadata into another projec
    Regards,
    Oleg

  • Copy/paste of links

    Hi, I'm using DPS via Creative Cloud and actually building an APP/E.Mag.
    I constructed a navigation that open/closes via the pic toggle effect. within this navigation menu i have several submenus in text form, a hyperlink with navto:// functionality leads then to the respective article nsde the folio.
    I copy/pasted this navigation into all articles so it will appear everywhere. Now the problem: I can open/close the navigation everywhere. but the links for navigation only work on the first article where I constructed it. Does this mean I have to rebuild the hole submenus in every article from scratch? And why does this not work so that I can understand the reason? Any idea about how I can make this with low effort?

    I believe this is something similar to this question: http://forums.adobe.com/message/4775774#4775774 - posted by me, and never got answered.
    It happens to me whenever I use copy/paste, and also using the content collector tool, to place objects with nested overlays and links. They all change to a different name, or get blank.

  • When I close firefox "everything " is cleared! EXCEPT when I open it again and anything i have copied to the clipboard (paste icon) remains lit... I believe this can be a security breach because I clear everything when closing firefox !!

    I have my settings to clear everything when I close firefox ver 3.6.13. If I copy something to the clipboard, the Paste icon lights up so I can paste the text... which is normal.
    The problem is when I close the browser and everything is suppose to clear (history, etc) the PASTE Icon still lights up for me to paste again.
    This can be a security breach because I want everything cleared when closing the browser !!!
    The only way I can rid myself of this problem is to restart the computer... which clears the clipboard of the operatinging... which is absolutely normal as well.
    I should not have to restart the computer each time.
    Try It !!! type text in any box... then paste it by using the PASTE Icon
    CLEAR all your history, everything ... then close firefox
    Reopen the browser... and the PASTE Icon will light up

    I only had a few addons installed, I disabled Zone Alarm toolbar, View Source Chart 3.01. I also had 5 separate java console updates/addons, and I uninstalled all but the latest java console 6.0.21. All I have now is Roboform 6.9.98, Firebug 1.5.4, Java console 6.0.21, Java quick starter 1.0. So far, so good, the problem has not occurred today. I hope this is it, I will be more sure after a few days problem free. Thanks for the info.

  • Can you add cut copy and paste icons to mail toolbar?

    Can you add a cut, copy and paste icons to the mail toolbar in macmail?

    I guess that these were considered such fundamental operations, each with an already existing variety of operations (mouse, keyboard, right-click, ctrl+c etc) that the Thunderbird devs didn't choose to replicate them again. Similarly, keyboard selection is relied upon a great deal in Thunderbird, rather than adding all the ugly (IMHO) checkboxes that now counterintuitively litter all Windows Explorer displays.
    So, if the devs expected you to use ctrl+right+shift to select the current text word by word, then ctrl+c to copy it, ctrl+x to cut it and ctrl+v to paste it would be quite natural, since your hands are already at the keyboard. Similarly, if you prefer to select by mouse, a right-click also offers options to copy, cut and paste, and there is also the possibility to drag selected text, serving cut and paste in one action. So it could be argued that there is no need for buttons.
    There used to be additional button add-ons for Thunderbird, but those that I know about don't appear to be under active maintenance and don't currently work with TB 31.0.
    You could build your own using a Custom Buttons add-on, but it isn't easy to find the appropriate function call to attach to your home-made buttons. :-(
    https://addons.mozilla.org/en-US/thunderbird/addon/custom-buttons/
    Here's the code you need if you try this add-on:
    cut: goDoCommand("cmd_cut")
    copy: goDoCommand("cmd_copy")
    paste: goDoCommand("cmd_paste")
    (taken from: http://kb.mozillazine.org/Keyconfig_extension:_Thunderbird )
    The tedious bit is finding suitable icons; the defaults are pretty but unhelpful coloured stars.

  • Wrong Icon Appears & Copy/Pastes Different Icon

    Kind of a strange problem.
    I've had my Blackbook for a couple of months, and all of a sudden today I noticed that a file I created using TextEdit had changed its icon to that of the application PhotoBooth. "Weird" think I, so I attempt to change it back by opening a text file somewhere else on my computer and copying its icon in 'Get Info' and then pasting it into the 'Get Info' of the text file with the weird PhotoBooth icon - except it pastes the wrong icon. Now I have the little house icon that is the same as the user. ***? There doesn't seem to be a way to revert back to the original icon, and now every subsequent text file I create has the little house icon.
    I'm wondering if maybe the graphic set for the icons has been corrupted or messed up. How can I get them back to normal? Anyone else experienced this problem?

    Kind of a strange problem.
    I've had my Blackbook for a couple of months, and all
    of a sudden today I noticed that a file I created
    using TextEdit had changed its icon to that of the
    application PhotoBooth. "Weird" think I, so I
    attempt to change it back by opening a text file
    somewhere else on my computer and copying its icon in
    'Get Info' and then pasting it into the 'Get Info' of
    the text file with the weird PhotoBooth icon - except
    it pastes the wrong icon. Now I have the little
    house icon that is the same as the user. ***? There
    doesn't seem to be a way to revert back to the
    original icon, and now every subsequent text file I
    create has the little house icon.
    I'm wondering if maybe the graphic set for the icons
    has been corrupted or messed up. How can I get them
    back to normal? Anyone else experienced this problem?
    Have you tried deleting the image while in "Get Info?" This has always reverted the image to the original default icon image for me.

  • Using Default Cut/Copy/Paste Actions

    After reading through the posts here, it seems that a lot of people use the method in the tutorial to implement cut/copy/paste in menus and toolbars.(http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html)
    I tried this, and it works, but the toolbar and menu entries are set to "cut-to-clipboard", etc. I have tried applying setName, but it doesn't seem to help. I want to be able to show just "Cut" with the appropriate icon.
    Anyone know what I'm missing?
    adam

    cutAction.putValue( Action.NAME, "Cut" );

  • HT201401 Yesterday when I turned on my iPad there was icon that ask do I want to upgrade IOS  well I didn't know what that was so I said yes . Well every since my iPad gas gone crazy . When I go to a send button it keeps showing the copy and paste icon ov

    Yesterday when I turned on my iPad there was icon that ask do I want to upgrade IOS  well I didn't know what that was so I said yes . Well every since my iPad gas gone crazy . When I go to a send button it keeps showing the copy and paste icon over the button . Today I was sending a phone load to friend . It was a $3.85 load . But button kept showing that stupid copy and paste icon so I kept pushing the button . Well I ended up sending $3.85 three times . How do I get the upgrades out or how do I fix my iPad ?

    What does this have to do with iPhones much less using them in an Enterprise environment?
    Try posting to the correct forum.

  • How do I move a file from a memory stick to a an external drive using a mac (copy paste doesnt work)

    How do I move a file from one memory stick to another using mac pro? copy paste doesnt work

    Have you tried simply dragging the file from one stick to the other? Do you know the format of the memory sticks (Macs can't write to those formatted as NTFS without the use of third-party software)?
    Clinton

  • Can you copy/paste files from the Finder to Mail in Lion, or drag them onto the Mail icon in the Dock to create a new message and attach the files to it?

    Message title says it: Can you copy/paste files from the Finder to Mail in Lion, or drag them onto the Mail icon in the Dock to create a new message and attach the files to it?
    I can't find anything in the Knowledge Base that says these two options no longer work or still do.
    I do not have a system capable of running Lion, but I need to know the answer nonetheless.

    Gee, I don't know: "paste attachments mail Lion"? ;-)
    One further question, if I may: in Panther (which is where I've aggregated nearly 7 years of mail), if you copy more than one file in the Finder, switch to Mail, and paste the files into a new message, only the file names paste in. If you copy one file and paste it into a Mail message, you get the file, not just the name. Is that still true, or has that (IMHO) bug been fixed since 10.3.9?

Maybe you are looking for

  • FaceTime Doesn't work after Mavericks Update.

    Ever since I updated my Macbook Pro to OSX Mavericks my FaceTime hasn't worked. Everytime I try to call FaceTime just says "FaceTime Failed" please help!!!

  • Import material - Vendor returned(Indian scenario)

    Dear all, I have searched forum for returning imported material with no solution discussed in any of threads. It would be nice if any one writes a blog for above subject in indian scenario it will be useful for everyone. What will be standard procedu

  • Is it possible to install Leopard this way?

    I have a Powermac G4 and the DVD drive is shot on it. I only have an external USB DVD drive and just read that it needs to be installed with a Firewire external drive if I go that route. My G4 has 2 Hard Drives in it. Is it possible to somehow copy t

  • Changing expired password on a cbckend database from a frontend database

    I have a split database with an Oracle backend (BE) and MS Access frontend (FE). My question is how to reset an expired password on the BE from the FE. If I log on to the backend via sqlplus an error ORA-28001 (Password expired) occurs and the system

  • HT1320 This game cannot be launched error!

    I was listening to March of Mephisto last night on my iPod Classic and I decided to play a game of solitair(the game has been on my iPod since I bought it). I'll often listen to music while playing solitair and so when I selected the game the error c