• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Screencapture
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Screencapture


  • Subject: Re: Screencapture
  • From: Andreas Kiel <email@hidden>
  • Date: Sat, 08 Mar 2014 14:45:53 +0100

Thanks both Shane and Stan.

The script from Hiroto is doing exactly what I need.
I need to change it  a bit – will take a bit of time since I don't know anything about Ruby.

To understand the background:
I got an old ASS app which uses GUI scripting for an external app. Using that latter I can retrieve a the position and dimensions of a "splitbox" inside the other app.
The goal is to insert the screenshot into a text document including some other text data.

Again thanks for all your help!!!

Andreas

On Mar 7, 2014, at 11:34 PM, Shane Stanley wrote:

On 8 Mar 2014, at 6:52 am, Stan Cleveland <email@hidden> wrote:

perhaps Hiroto's code could provide some clues for an ASObjC version? 

Alas, no, in that those APIs aren't available to ASObjC.

It may be doing exactly what Shane suggested--capturing the entire screen, then cropping it.

No, it's getting just the desired portion. Not that cropping is very difficult:

use framework "Foundation"
use framework "AppKit"

on cropTo:{x1, y1, x2, y2} fromPath:inputPath toPath:outputPath
set newWidth to x2 - x1
set newHeight to y2 - y1
set theImage to current application's NSImage's alloc()'s initWithContentsOfFile:inputPath
set theSize to (theImage's |size|()) as record
set oldHeight to height of theSize
-- transpose y value for Cocoa coordintates
set y1 to oldHeight - newHeight - y1
set newRect to {{x:x1, y:y1}, {width:newWidth, height:newHeight}}
theImage's lockFocus()
set theRep to current application's NSBitmapImageRep's alloc()'s initWithFocusedViewRect:newRect
theImage's unlockFocus()
set theData to theRep's representationUsingType:(current application's NSPNGFileType) |properties|:{NSImageGamma:1.0}
theData's writeToFile:outputPath atomically:true
end cropTo:fromPath:toPath:

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>
Do not post admin requests to the list. They will be ignored. applescriptobjc-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Screencapture (From: Andreas Kiel <email@hidden>)
 >Re: Screencapture (From: Stan Cleveland <email@hidden>)
 >Re: Screencapture (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Screencapture
  • Next by Date: how to test bundle versions string?
  • Previous by thread: Re: Screencapture
  • Next by thread: how to test bundle versions string?
  • Index(es):
    • Date
    • Thread