Open .textClippings larger?

I would like my .textClippings to open larger than the default – width 312 height 238.
I can write the droplet but I don’t know how to tell the Finder to open the .textClippings to 500 x 400.

Thanks for any help!

Tom

Browser: Safari 525.27.1
Operating System: Mac OS X (10.5)

Hey,
use the spacebar (quickview in Leopard), instead to open it via the “Finder”;
or try to add your clippings to a Database, like “Evernote”. (see the link)
This one is a great solution to store everything around notes, images and so forth from web or offline.

http://evernote.com/about/download/

Thanks for your reply, Joy… but your suggestions are not what I’m looking for. :smiley:

Regards,

Tom

I have never played much with clippings, but I came up with something. It requires that the clipping actually be open, so there is some noticeable activity on the screen. If the clipping was not open to begin with, it is closed after adjusting its size. It should be straight forward to integrate it into a droplet.

on run
	path to desktop as Unicode text
	result & "a clipping file.textClipping"
	--alias result
	--tell application "Finder" to get item result
	setClippingWindowSize(result, 500, 400)
end run

to setClippingWindowSize(clippingSrc, newWidth, newHeight)
	-- clippingSrc can be an alias, an HFS-style path, or a Finder clipping object
	
	-- Convert the clippingSrc into clippingItem.
	using terms from application "Finder"
		set clippingClass to clipping
	end using terms from
	if class of clippingSrc is clippingClass then
		set clippingItem to clippingSrc
	else
		tell application "Finder" to set clippingItem to clipping clippingSrc
	end if
	
	-- Save a list of the IDs of currently open windows.
	tell application "Finder" to set originallyOpenFinderWindowIDs to id of every window
	
	-- Get the clipping's window.
	open clippingItem
	tell application "Finder" to set clippingWindow to first window
	if name of clippingWindow is not equal to displayed name of clippingItem then error "The first Finder window is not the expected clipping window!" -- make sure we have the right window (guard against user interference); this could still be fooled by a clipping with the same name from a different folder
	
	-- Note if the clipping's window was already open. Exercise for the reader: extend this code to preserve the minimization state of the window if it was already open
	set clippingWindowWasAlreadyOpen to id of clippingWindow is in originallyOpenFinderWindowIDs
	
	-- Get and adjust the bounds of the clipping's window.
	set {x, y, xx, yy} to bounds of clippingWindow
	set bounds of clippingWindow to {x, y, x + newWidth, y + newHeight}
	set |return| to bounds of clippingWindow
	
	-- Close the window if it was not open to begin with.
	if not clippingWindowWasAlreadyOpen then close clippingWindow
	
	-- Yield some possibly useful return value.
	|return|
end setClippingWindowSize

Hi Chris, Thanks for posting all that code. I’ll compile it as a droplet tomorrow.

btw, It’s almost – W a y t o o l o n g, d u d e. :cool: http://bbs.macscripter.net/viewtopic.php?id=26856

Cheers, :lol:

Tom

Browser: Safari 525.27.1
Operating System: Mac OS X (10.5)

This works in Jaguar and Tiger. I think it should also be good in Leopard. It resizes the clipping windows wherever they happen to open. :

on open theseItems
	repeat with thisItem in theseItems
		if (file type of (info for thisItem) is "clpt") then
			tell application "Finder"
				open thisItem
				set {x, y} to position of front clipping window
				set bounds of front clipping window to {x, y, x + 500, y + 400}
			end tell
		end if
	end repeat
end open

You could also cascade the windows from a fixed start coordinate:

on open theseItems
	set {x, y} to {52, 102} -- Adjust to taste.
	repeat with thisItem in theseItems
		if (file type of (info for thisItem) is "clpt") then
			tell application "Finder"
				open thisItem
				set {x, y} to {x + 18, y + 18}
				set bounds of front clipping window to {x, y, x + 500, y + 400}
			end tell
		end if
	end repeat
end open

Hi Nigel, Sorry for the late reply - just got home for the day. I compiled your two scripts on my Tiger drive and received the following errors:
The first script produced this error…
Can’t get «class posn» of «class lwnd» 1 of application “Finder”.

The second script produced this error…
Can’t set bounds of «class lwnd» 1 of application “Finder” to {70, 120, 570, 520}.

Your help is very much appreciated.

Tom

On my system, I compiled this code to translate the raw codes:

«class lwnd» -- not changed when compiling
«class posn» -- not changed when compiling
using terms from application "Finder"
	«class lwnd» -- changed to "clipping window" when compiled
	«class posn» -- changed to "position" when compiled
end using terms from

So, as you might guess, «class lwnd» is the raw code for Finder’s clipping window term and «class posn» is the raw code for Finder’s position term.

When I saw clipping window in Finder’s dictionary on my Tiger machine, I tried to use it (i.e. tell app “Finder” to get first clipping window), but it was never productive (error number -1728, “Finder got an error: Can’t get clipping window 1.”). Here are some demonstrative results from when I had the following windows open in Finder: one normal files/folders window, the Preferences window, one Get Info window, and one text clipping window.

tell application "Finder"
	class of every window --> {preferences window, information window, Finder window, window} -- the last is the window for an open text clipping
	get every clipping window --> {}
end tell

Based on that, I assumed that clipping window was not really useful on my machine (and other Tiger machines?), so I used plain window (though I would have used clipping window if it had worked on my machine!). My Finder did produce position properties for its window objects, but I stuck with bounds (one small advantage is that it is a standard term that is compilable without Finder’s terms).

Maybe to run it on Tiger, the code that uses the term clipping window must be compiled on Jaguar (since those were the two system on which Nigel indicated it works, even though it fails to work when compiled on two other Tiger systems). If so, I would be (very) mildly interested to know which raw code Jaguar uses for clipping window (I usually use AEPrint of from the List and Record Tools OSAX to indirectly dig up raw codes). Presumably Tiger’s Finder supports Jaguar’s raw code for clipping window, but Tiger’s dictionary specifies translation of clipping window into a different raw code (one that presumably Tiger and later releases recognize). I have heard of these changes for forward and backward compatibility before, but never run into them (probably because I usually only work with Tiger machines). Panther is also lurking in between Jaguar and Tiger, but it is probably not worth adding to the mix.

Model: iBook G4 933
AppleScript: 1.10.7
Browser: Safari Version 3.2.1 (4525.27.1)
Operating System: Mac OS X (10.4)

Chris, Thanks for all your help and the explanation.
Much appreciated!

Tom

I must apologise for posting that turkey and for the false assertion that it works in Tiger. I didn’t actually test it on my Tiger machine. It’s a perfectly good script and works brilliantly in Jaguar, and the Tiger dictionary lists all the necessary terminology, so I saw no reason why it shouldn’t work there too. (My G5 currently has to be in a different room from the phone socket, so testing scripts on it before posting with the PowerBook is a bit of a performance.)

The class code for ‘clipping window’ is «class lwnd» on both systems.

I’m posting a query to the AppleScript-Users list to see if anyone there has any idea why it’s stopped working.