<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>insightmedia &#187; Applescript</title>
	<atom:link href="http://insightmed.eu/blog/category/programming-scripting/applescript/feed" rel="self" type="application/rss+xml" />
	<link>http://insightmed.eu/blog</link>
	<description>be the change you want to see in the world</description>
	<lastBuildDate>Fri, 18 May 2012 17:24:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Dynamic method calling from applescript</title>
		<link>http://insightmed.eu/blog/programming-scripting/dynamic-method-calling-applescript_2012_03.html</link>
		<comments>http://insightmed.eu/blog/programming-scripting/dynamic-method-calling-applescript_2012_03.html#comments</comments>
		<pubDate>Mon, 26 Mar 2012 13:59:01 +0000</pubDate>
		<dc:creator>dan.hawk</dc:creator>
				<category><![CDATA[Applescript]]></category>
		<category><![CDATA[Programming / Scripting]]></category>
		<category><![CDATA[applescript call]]></category>
		<category><![CDATA[applescript call function string]]></category>
		<category><![CDATA[applescript dynamic]]></category>
		<category><![CDATA[applescript dynamic invoke]]></category>

		<guid isPermaLink="false">http://insightmed.eu/blog/?p=222</guid>
		<description><![CDATA[Applescript comes handy sometimes when you need to do some automation job quick within the MAC OS. Though it lacks many of the features offered by the modern languages, you can sometimes simulate them doing some dirty tricks . One of them is dynamic calling of the methods of a particular script. let&#8217;s take the [...]]]></description>
			<content:encoded><![CDATA[<p>Applescript comes handy sometimes when you need to do some automation job quick within the MAC OS. Though it lacks many of the features offered by the modern languages, you can sometimes simulate them doing some dirty tricks <img src='http://insightmed.eu/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . One of them is dynamic calling of the methods of a particular script. let&#8217;s take the case where you want for example to store some options for your script in a separate file though it might look like a fancy way of storing options. so it will look something like</p>
<pre class="brush:javascript">

--script_options.scpt
on AppleOptions()
  return some options
end AppleOptions

on GrapesOptions()
  return some options
end GrapesOptions

....

on Options()
  --this should be a default option
  return some sort of options
end Options
</pre>
<p>Now if the calling of these options depends on some context that changes every time you run your script, you can still call your methods without knowing beforehand what&#8217;s going to be called, like this:</p>
<pre class="brush:javascript">
--main.scpt
set theFruit to some_value_that_came_from_current_context
set selScpt to path_to_the_options_script_file
set selScpt to load script selScpt
set scptOpt to Options() of selScpt
try
set _scptOpt to run script ("on run (inArgs)" &amp; return &amp; "set theCaller to item 1 of inArgs" &amp; return &amp; "tell (item 1 of inArgs) to " &amp; theFruit &amp; "Options()" &amp; return &amp; "end run") with parameters {selScpt}
--optionally check for empty list or string returned in the try block
end try
if (_scptOpt is not "" and _scptOpt is not {}) then
--display dialog "ok"
set scptOpt to _scptOpt
end if
</pre>
<p>Calling the above script with theFruit set as &#8220;Apple&#8221; (no case checking in the above script though) will call your imported script&#8217;s AppleOptions() or if not found will get the default Options method.</p>
]]></content:encoded>
			<wfw:commentRss>http://insightmed.eu/blog/programming-scripting/dynamic-method-calling-applescript_2012_03.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[rb] Removing textframe linkage with applescript</title>
		<link>http://insightmed.eu/blog/programming-scripting/rb-removing-textframe-linkage-with-applescript_2010_12.html</link>
		<comments>http://insightmed.eu/blog/programming-scripting/rb-removing-textframe-linkage-with-applescript_2010_12.html#comments</comments>
		<pubDate>Mon, 13 Dec 2010 08:21:42 +0000</pubDate>
		<dc:creator>dan.hawk</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Applescript]]></category>
		<category><![CDATA[Programming / Scripting]]></category>
		<category><![CDATA[batch remove text frame indesign]]></category>
		<category><![CDATA[batch text frame split indesign]]></category>
		<category><![CDATA[remove linkage indesign]]></category>

		<guid isPermaLink="false">http://insightmed.eu/blog/?p=114</guid>
		<description><![CDATA[You may sometimes need to be able to remove linkage between text frames in a particular document in Indesign. this script might come to the rescue: tell application "Adobe InDesign CS2" set theObjs to selection if theObjs is equal to {} then set theObjs to every text frame of document 1 end if tell document [...]]]></description>
			<content:encoded><![CDATA[<p>You may sometimes need to be able to remove linkage between text frames in a particular document in Indesign. this script might come to the rescue:</p>
<pre class="brush:javascript">
tell application "Adobe InDesign CS2"
	set theObjs to selection

	if theObjs is equal to {} then
		set theObjs to every text frame of document 1
	end if
	tell document 1 to set thebaseframe to make new text frame

	repeat with tos in theObjs
		if (class of tos as string) = "text frame" then
			if end text frame of tos is not tos then
				set next text frame of tos to next text frame of thebaseframe
				set previous text frame of tos to previous text frame of thebaseframe
				set autoflow thread orphaned of tos to true
			end if
		end if
	end repeat
	tell document 1 to delete thebaseframe
end tell
</pre>
]]></content:encoded>
			<wfw:commentRss>http://insightmed.eu/blog/programming-scripting/rb-removing-textframe-linkage-with-applescript_2010_12.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extending illustrator capabilities with applescript</title>
		<link>http://insightmed.eu/blog/programming-scripting/extending-illustrator-capabilities-with-applescript_2010_12.html</link>
		<comments>http://insightmed.eu/blog/programming-scripting/extending-illustrator-capabilities-with-applescript_2010_12.html#comments</comments>
		<pubDate>Mon, 13 Dec 2010 08:19:48 +0000</pubDate>
		<dc:creator>dan.hawk</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Applescript]]></category>
		<category><![CDATA[Programming / Scripting]]></category>
		<category><![CDATA[applescript illustrator]]></category>
		<category><![CDATA[illustrator select script]]></category>
		<category><![CDATA[selection applescript illustrator]]></category>

		<guid isPermaLink="false">http://insightmed.eu/blog/?p=112</guid>
		<description><![CDATA[While Illustrator offers a range of selection options that most of the time are enough for a particular scope, you might sometimes need to deal with a lot of stuff that come from other programs. This tiny script scrap might  come to the rescue in many occasions: tell application "Adobe Illustrator" set sel to selection [...]]]></description>
			<content:encoded><![CDATA[<p>While Illustrator offers a range of selection options that most of the time are enough for a particular scope, you might sometimes need to deal with a lot of stuff that come from other programs. This tiny script scrap might  come to the rescue in many occasions:</p>
<pre class="brush:javascript">
tell application "Adobe Illustrator"
	set sel to selection
	set target to item 1 of sel
	set cls to class of target

	set objs to every page item of document 1

	repeat with o in objs
		if (class of o is equal to cls) then
			set selected of o to true
		end if
	end repeat

end tell
</pre>
]]></content:encoded>
			<wfw:commentRss>http://insightmed.eu/blog/programming-scripting/extending-illustrator-capabilities-with-applescript_2010_12.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Start/stop printer queue with applescript</title>
		<link>http://insightmed.eu/blog/programming-scripting/startstop-printer-queue-with-applescript_2010_11.html</link>
		<comments>http://insightmed.eu/blog/programming-scripting/startstop-printer-queue-with-applescript_2010_11.html#comments</comments>
		<pubDate>Tue, 23 Nov 2010 08:11:28 +0000</pubDate>
		<dc:creator>dan.hawk</dc:creator>
				<category><![CDATA[Applescript]]></category>
		<category><![CDATA[Programming / Scripting]]></category>
		<category><![CDATA[print applescript]]></category>
		<category><![CDATA[printer applescript]]></category>
		<category><![CDATA[start print applescript]]></category>

		<guid isPermaLink="false">http://insightmed.eu/blog/?p=60</guid>
		<description><![CDATA[This little applescript script will toggle the enabled/disabled status of your printer: --be aware of the fact that HP LaserJet 5100 Series for example has the queue name HP_LaserJet_5100_Series(spaces replaced with _) property lp_queue_name : "printer name" on run set isDisabled to do shell script ("lpstat -t &#124; grep '" &#38; lp_queue_name &#38; " disabled'") [...]]]></description>
			<content:encoded><![CDATA[<p>This little applescript script will toggle the enabled/disabled status of your printer:</p>
<pre class="brush:php">
--be aware of the fact that HP LaserJet 5100 Series for example has the queue name HP_LaserJet_5100_Series(spaces replaced with _)
property lp_queue_name : "printer name"
on run
set isDisabled to do shell script ("lpstat -t | grep '" &amp; lp_queue_name &amp; " disabled'")
if isDisabled is not equal to "" then
do shell script ("/usr/bin/enable " &amp; lp_queue_name &amp; "; lprm -P \"" &amp; lp_queue_name &amp; "\" -E")
else
do shell script ("/usr/bin/disable " &amp; lp_queue_name &amp; "; lprm -P \"" &amp; lp_queue_name &amp; "\" -E")
end if
end run
</pre>
]]></content:encoded>
			<wfw:commentRss>http://insightmed.eu/blog/programming-scripting/startstop-printer-queue-with-applescript_2010_11.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

