MACSCRPT Archives

May 2009

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Paul Skinner <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Fri, 22 May 2009 14:26:26 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (59 lines)
Marc,

	Something like...

on idle
	set CB to the contents of (the clipboard)
	set AppleScript's text item delimiters to return
	set flag to text item 1 of CB
	if flag is in {"hscript", "flag2"} then
		actOnFlag(CB)
		return 5
	else
		return 5
	end if
end idle

on actOnFlag(CB)
	set AppleScript's text item delimiters to return
	set {flag, cmd} to text items of CB
	if flag is "hscript" then
		tell application "Safari"
			activate
			open location cmd
		end tell
		set the clipboard to cmd
	else
		if flag is "flag2" then
			do shell script cmd
		end if
	end if
end actOnFlag


Paul


On May 22, 2009, at 10:01 AM, Marc Bossiere wrote:

> Thank you for that. I didn't know about the "return 5" bit.
>
> But more than putting TO the OS X clipboard, I'm confused trying to  
> get FROM
> it. Like if I send a two line clipboard, such as:
> hscript
> www.google.com
> and what I want is for Applescript to act if it sees my "hscript"  
> flag is
> the first line (indicating I want it to do something with this  
> clipboard).
>
> I would like it to do the following:
> - see the flag
> - take the URL and open it with a browser
> - clear the flag part of the clipboard (so it won't repeat itself)
>
> Later on I could create other types of flags for other things (like  
> sending
> simple Applescripts from the emulator)

ATOM RSS1 RSS2