Place random image in Messages with Applescript - TextExpander

I've been using Apple computers since '84 but I've never used Appplescript and was hoping for some help.
I'd like to be able to place a random image in Messages with an Applescript through TextExpander. When I type my snippet into Messages  the Finder will open a random image from a folder using something like this:
tell application "Finder"
set randomImage to some file of folder "Mac HD:Users:me:photos:chat pics"
get randomImage
open randomImage
end tell
If I replace "Finder" with "Messages" it doesn't work. Do I need to combine 2 Applescripts to make this happen?
TIA

I tried using the following code, but it�din�t work.
<%@ page import="java.io.*" %>
<%
// File (or directory) to be moved
File file = new File("banner2.bmp");
// Destination directory
File dir = new File("banner");
// Move file to new directory
boolean success = file.renameTo(new File(dir, file.getName()));
if (!success) {
System.out.println("File was not successfully moved");
  // File was not successfully moved
else{
System.out.println("File was successfully moved");
%>Andreas

Similar Messages

  • Download image from URL with applescript

    I want to download an image from an website (and internal IP address) using applescript,
    now I have found a script that works (Download jpeg image to folder with AppleScript from URL).
    But, the web page requires a username and password...
    When I convert the downloaded JPEG into a HTML by simply changing the extension, quick look displays the webpage's 401 unauthorized error page...
    Does someone know how to make the applescript input the username and password?

    The answer depends on how the authentication is managed.
    There are two common ways of implementing authentication in web browsers and knowing which one is used here is essential to scripting the request. One is also significantly harder than the other.
    The first (easy) way is that the username and password can be submitted with the request. This is the original model and is easy to script - if you're using the curl model then it's just a matter of adding the -user switch to the command line:
           -u, --user <user:password>
                  Specify the user name and password to use for server authentica-
                  tion. Overrides -n, --netrc and --netrc-optional.
    This model is a little less secure, though, but might still be used on internal sites since it's easy to implement.
    The other option is that the site uses cookies - you log in via a web form and the server gives your cookie which you then send with subsequent requests and are used to validate your access. This is a more secure, but is harder to implement because there is a multi-step process - login via the web form, capture the cookie, submit the cookie with the download request.
    If you're not familiar with the different methods it can sometimes be hard to tell which one you need, and since it's an internal site there's no way anyone else can check... so you'll need to describe how you login to the site (or are prompted for authentication) before anyone can provide a direct answer.

  • How to process received images in iChat/Messages with Applescript

    Hello!
    I want to process all received photos or videos with Applescript.
    I try this:
    using terms from application "Messages"
              on message received theMessage from theBuddy for theChat
                        if the length of theMessage is 0 then
      -- it means I received a picture or video file, but I can't get the file with Applescript, because theMessage is an empty string and not a file
                                  set theMessage to "<lost photo or video content>"
                        else
      -- it's OK, I just got a text message and I can now save it or display or do something else with it
                        end if
              end message received
    end using terms from
    But if I receive a photo, theMessage is empty.
    The event handlers "on completed file transfer" and "received file transfer invitation" don't work in this case, probably because it is not a file tranfer, but sort of an inline picture.
    I use OS X 10.8.
    Can somebody help me?

    I have a similar question as well. I tried this for you and nothing happened.
    on received file transfer invitation theFileTransfer
    end received file transfer invitation
    I think "completed file transfer" is regarding to the file being transfered to Apple's Server from your computer when a file is sent, but I'm not sure about "received file transfer invitation." Regarding it being an inline file, maybe try using the attachment class.
    attachment n [inh. rich text] : Represents an inline text attachment. This class is used mainly for make commands.
    elements
    contained by rich text, characters, paragraphs, words, attribute runs.
    properties
    file (file, r/o) : The path to the file for the attachment  syn file name

  • How to place multiple images in batch with drop shadow effects on room backgrounds at the same position?

    I want to place multiple images of hand paintings with drop shadow effects on room backgrounds to make them look as if the paintings are hanged on the room walls. I know how to do it one by one, but that takes time and I want to do it in batch at once.
    I am quite a beginner for adobe photoshop CS6. I belive such an automated task is possible through 'Automated Batch' function and/or 'Create Droplet' function. Kindly share your expert opinion.

    If you want to go with Batch I would recommend creating an Action of more or less these steps:
    • set the resolution to the same as the background image’s
    • change the image from Background Layer to regular Layer if necessary
    • convert it to a Smart Object
    • add a Drop Shadow Layer Style to the image (do not use Global Angle)
    • place the background image (File > Place …)
    • move it behind the image layer
    • Image > Reveal All
    • make Selection from that layer’s transparency (cmd-click its icon in the Layers Panel) and use Image > Crop
    • select and transform the image layer to fit the intended position
    This would naturally work out best if the images had the same size and proportions.
    For the reflection on the floor duplicate the image, flip it vertically, move it in position and reduce its opacity to maybe 10%.
    Realistically you may have to hide it partially behind the pillows, a Vector Mask would be an option.

  • Intermittent "Unsupported image format" message with either CR2 or DNG

    I am seeing "Unsupported image format" messages once files created by a Canon EOS 1Ds Mark iii (+stored in Canon's CR2 file format or when the same file is converted to Adobe's DNG file format+) have been imported into Aperture.
    Some files will import and be viewable. However, most of the time the files are not viewable. This occurs even after updating Aperture to 1.5.6.
    Is anyone else seeing problems with CR2 or DNG files created by Canon EOS 1Ds Mark iii?
    Has anyone see a solution?

    I think Support is confused with the Canon camera models.
    10.5.1 supports 1D Mk III, but only 1Ds Mk II.
    (http://docs.info.apple.com/article.html?artnum=306835
    http://www.apple.com/aperture/raw/cameras.html)
    I don't believe that 10.4.11 supports anything that 10.5.1 doesn't support. In fact, the docs at http://docs.info.apple.com/article.html?artnum=306297 say "Adds RAW image decoding support for the following cameras: Panasonic Lumix DMC-FZ50, Leica V-Lux 1, Olympus E-400, Olympus EVOLT E410, Olympus EVOLT E510, Canon EOS 40D" (the 1D Mk III came in the 10.4.10 update.)

  • Read email message with AppleScript

    Hi!
    I just used this tip to remotely sleep my MacBook Pro:
    http://www.tuaw.com/2008/04/07/applescript-control-your-mac-with-an-e-mail/
    Now I would like that when the message comes with the subject as System and the text as Read an applescript would read what I wrote after that.
    Example:
    From: Me
    Subject: System
    Text: Sleep
    -> The computer runs applescript sleep and sleeps (so far it's working)
    From: Me
    Subject: System
    Text: Read
    -> The computer runs applescript read (that's the problem)
    How do I point the AppleScript to the received message and make it start reading?
    Is there a way to also unlock the screen (screensaver uses password)?
    Tank-you in advance for any help!

    The trick here (and the part that TUAW doesn't cover in that article) is that when a Mail rule triggers an AppleScript it passes a list of relevant messages to the script.
    Once you have that it's easy to act upon the message content.
    So instead of the simple shutdown script you write something more like:
    using terms from application "Mail"
     on perform mail action with messages theSelectedMessages for rule theRule
      repeat with eachMessage in theSelectedMessages
       -- Process the current message
       -- YOUR CODE HERE
      end repeat
     end perform mail action with messages
    end using terms from

  • Move images to album with Applescript

    Hello,
    I am writing an applescript to make new albums and move all image versions of a given project to that album.
      tell my_project to set my_album to (make new album with properties {name:my_project_name})
      tell my_project to move every image version of my_project to my_album
    The new album is created but the images are not moved.
    tell my_project to move every image version of my_project to album my_album
    doesn´t work either.
    How can i move the images

    I tried your script, and it works on my Mac  when I write it like this:
    When I tested the script below, all selected images had been added to the album "testAlbum":
    Sorry, I cannot copy and paste the code here -- the editor messes it up:
    tell application "Aperture"
      set imageSel to (get selection)
      if imageSel is {} then
      error "Please select an image."
      else
      repeat with i from 1 to count of imageSel
      move item i of imageSel to the album "testAlbum"
      end repeat
      -- return the album "testAlbum"
      end if
    end tell

  • How to move Mail.app messages with AppleScript

    I have the following AppleScrip to move all Mail messages from one folder to another folder:
    on run {input, parameters}
              tell application "Mail"
                        repeat with theMessage in {messages in mailbox "Later" of account "[email protected]"}
                                  set theMailbox to mailbox "INBOX" of account "[email protected]"
      move theMessage to theMailbox
                        end repeat
              end tell
              return input
    end run
    When I run the script, it gives an error message:
    Syntax Error. Mail got an error: Can't make {message id xxx} of mailbox "Later" of account "[email protected]" into type scpcifier.
    What do I have to change to make this script work?

    What you are trying to do, move mail messages older than some time to a different folder, isn't really something that should be down by a rule. Rules are meant to examine messages as they arreive and to prefrom some action based on the mesage.
    You would do better to make this a straight AppleScript that you would then run as needed or triggered by something like iCal on a daily basis.

  • Placing FXG images and working with symbols

    Has anyone been able to place fxg images in illustrator using applescript or actionscript? We spent a ton of time trying to troubleshoot it today and counldnt figure out why, but we couldnt seem to place them on a page. That and symbol scripting has been pretty tough to find any reference or examples of scripts. Thanks

    Thanks for the direction but that didnt seem to solve the problem for me.Whenever I make a FSG it has a sidecar image folder becuase we use a lot of rasters with our art. Mostly tiffs. Whenever we place it using your code or applescript, we get an error:  It give a couple errors in a ropw: one in the AI app saying error saying it cannot find a missing link and on in the javascript or applescript saying:
    Adobe Illustrator got an error: JavaScript execution error. Error 9080: Unable to set placed item's file, is the file path provided valid? Or try to use the raster item instead.
    Line: 7
    ->  iplaced.file = fileRef; // add actual image/**/
    Seems like a bug. I thought about trying to figure out how to either drag and drop a whole ton of them from bridge then they may be able to be assigned as symbol items but Im not sure how I could import all as individual symbols with filenames for names or even better how I can resolve this issue. Its a apin dealing with EPS files and this FXG format really seems to do everything we want.
    Any ideas/help would be appreciated.

  • When opening a folder with "items as icons" view, a millisecond fast random image appears in place

    Hi,
    since I updated to Yosemite (but cannot assure it's related or started exactly that moment) I've been experienced a weird issue.
    When I open a folder to navigate it, and it's set on "show items as icons", I see all the icons, for just less than a second, replaced by random images.
    It's like if while the proper folder/file icon it's loading, that space is temporarily occupied by the impression of another one (or parts of it), coming from my computer. Sometimes is a photo, sometimes another folder icon not related, sometime is the icon of a software.
    The picture then goes away (it stays less than a second) and the icon for the file/folder is then the appropriate one.
    I have a Macbook Pro 15-inc, mid 2010.
    Is it a known issue? If yes, how can I solve, if possible, this?
    Hope can be helpful to others too.
    Many Thanks

    First off, I do not recommend looking at your time machine while it is running.  You can tell if it is running by making sure its menubar icon is shown in Apple menu -> System Preferences -> Time Machine.  If the icon is moving, it is running.   You can manually backup, which I recommend over automatic backup, as automatic backup can get in your way.   Spotlight, if it is indexing (check the menu in the upper right that looks like a magnifying glass), will also slow matters down, and adding things you don't want Spotlight to search to your Apple menu -> System Preferences -> Spotlight -> Privacy pane will help.  Note this affects areas you can search in Time Machine as well.  If searching content of files is of little interest to you, I find Find Any File much quicker for finding by file name.   Backup when you aren't doing anything else, as otherwise, you may find yourself backing up files that haven't had the opportunity to close.
      Time Machine also works best if your destination drive is at least twice as capacious as your source drive.   Otherwise it is spending a lot of time trying to find places for the archived files, and barely is more archival than a simple clone.

  • Display problems in Mail messages with image attachment

    Issue: Seeing intermittent display problems in Mail messages with image attachments
    Annoyance level: minor, but Apple techs need to pass it along
    Details: Regardless of mail client sending to iPhone (Outlook, OWA, Yahoo, Gmail) there are intermittent and what appear to be random occurrances of the pic being half rendered and/or the pic never loading (followed by message saying it can't be retrieved from server). In some instances the picture then appears fully rendered without a problem. Note: Image sizes varied from 14KB to 450KB

    Hi,
    I'm not familiar with C#, but if possible try the following:
    1. Removing all thead and tbody tags from the body of the message.
    2. Changing all inline CSS to embedded CSS.
    I've seen a user said the message stopped showing up after making the changes.
    If the issue persists, please note, since Outlook 2007, Outlook opens the HTML Email and converts it to Microsoft Word format before displaying it to the user. What happens during this process is that many CSS attributes and HTML support is completely removed.
    Some of the most notable absences are background-image, and padding and margin support. Hardly can we do much about this, so the message "If there are problems with how this email is displayed, click here to view it in a web browser" is actually
    a good workaround when we face this problem.
    Regards,
    Melon Chen
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Is there a way to edit IPTC data of an image with AppleScript?

    Hi,
    I'm looking for a way to batch-edit the IPTC data from images. Is that somehow possible with Applescript? If so, could someone point me to a direction?
    (I fond a script working wit Graphic Converter in another thread, but that didn't work.)
    Thanks,
    p.

    Frank, maybe you could give me a hand here. I'm building the basic script cycling through the dropped files. But I don't know how to best implement the terminal command.
    In each cycle, I would set the file path as a variable and then compose the terminal command in order to execute it with "do script".
    But  "set x to path of eachFile" doesn't work: <<class ppth>> of alias "(path shows here)" could not be read. Any ideas how to do that better?
    on open theFiles
      repeat with eachFile in theFiles
                        set x to path of eachFile
                        tell application "Terminal"
                         activate
                        do script "hello" (Exiftool command will be here)
                        close window 1
                        end tell
              end repeat
    end open

  • Problem connecting wirelessly from iMac to NETGEAR router, get invalid password message with WPA and WPA-2 encryption in place but if I remove them, so no security, can connect without a problem. Help!!

    Problem connecting wirelessly from iMac to NETGEAR router, get invalid password message with WPA and WPA-2 encryption in place but if I remove them, so no security, can connect without a problem. Help!!

    Thank you for your suggestion but I have already had a couple of phone sessions with NETGEAR support and they don't see any problems with the router settings etc. They referred me to Apple support, who helped me discover that it is possible to communicate with the router but only if I turn off the encryption/security software, which I don't want to do. The frustrating thing is that I can connect wirelessly from a laptop running Windows 7 and two Anroid smart phones, with WPA-2 in place, without a problem. Do you have any other ideas?

  • I want to place an image in my InDesign document that can work with an address like this (\Resources\Thumb) rather than this (C:\Users\JSmith\Desktop\InDesign thumbnail Test\001\Resources\Thumb) is this possible?

    I want to place an image in my InDesign document that can work with an address like this (\Resources\Thumb) rather than this (C:\Users\JSmith\Desktop\InDesign thumbnail Test\001\Resources\Thumb) is this possible? In a nutshell I want to point the link to an image in a directory that uses just part of the address.

    I know this is something you can do in Maya with linked files. I guess InDesign just isn't there yet.
    MW Design -  Yeah I think "Relative paths" is the right term! I want to create a Layout with an image in the center of the page - and then duplicate my folder structure with that file. With that, I want to replace the Linked image file with a diferent image file of the same name. In effect having multiple files of the same layout with different images.  I hope that made sense.  

  • Can I place an image in the Note section of Contact book . I use a MacBook Pro with Yosemite 10.10 . I am NOT talking about using an image to identify the contact, just an image that contains some information relevant to the contact. I have tr

    I want to place an image in the Note section of my Contact book . I use a MacBook Pro with Yosemite 10.10 . I am NOT talking about using an image to identify the contact, just an image that contains some information relevant to the contact. I have tried copying and pasting, dragging and dropping.

    From reading Vista forums support for SSD is one of the things Vista SP2 and Windows 7 hope (need) to improve upon. I was in a similar discussion once befoe on SSDs:
    http://discussions.apple.com/thread.jspa?messageID=8482110
    http://news.cnet.com/8301-13924_3-10026010-64.html
    http://www.intel.com/design/flash/nand/mainstream/index.htm
    http://www.google.com/search?hl=en&rls=com.microsoft%3Aen-US&q=IntelSSDVista
    I don't think it is EFI issue, but with XP and drivers, lack, and wonder if you can try with Vista?
    http://arstechnica.com/news.ars/post/20080908-intel-tosses-hat-into-ssd-ring-wit h-80gb-launch.html
    That won't solve performance issues, but should work.
    http://www.reghardware.co.uk/2008/07/22/sandiskssd_vistabeef/
    "My guess is that [Samsung and Microsoft] are maybe working on the OS recognizing an SSD with a 4K-byte sector size instead of a hard disk drive with a 512-byte sector size," Wong said.
    Sun is already working with Samsung to bulk up SSD support on the ZFS (Zettabyte File System), which is included in the Solaris OS, and will also be supported in Apple's upcoming Mac OS X 10.6, codenamed Snow Leopard. Sun is adding capabilities to boost the durability and performance of SSDs on ZFS-based operating systems. For example, Sun may add defragmentation capabilities for SSDs, which organizes data in a particular order to enable quicker data access.
    SSDs were not considered ideal for defragmentation because of limited read-and-write capabilities, Wong said. However, Samsung and Sun in July jointly announced an 8G-byte SSD that bumped up durability from 100,000 read-and-write cycles to 500,000. That brings defragmentation in SSDs closer to reality, which could improve its caching and provide quicker access to data. Sun plans to put SSDs into storage products later this year.
    http://www.itworld.com/operating-systems/54115/samsung-microsoft-talks-speed-ssd s-vista

Maybe you are looking for