<?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>Marcus' Macro Blog &#187; Scripting</title>
	<atom:link href="http://www.mjtnet.com/blog/category/scripting/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mjtnet.com/blog</link>
	<description>Mostly tips, tutorials, articles and news about Macro Scheduler &#38; Windows Automation</description>
	<lastBuildDate>Wed, 08 Sep 2010 15:03:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Trigger Scripts</title>
		<link>http://www.mjtnet.com/blog/2010/09/08/trigger-scripts/</link>
		<comments>http://www.mjtnet.com/blog/2010/09/08/trigger-scripts/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 15:03:02 +0000</pubDate>
		<dc:creator>Marcus Tettmar</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.mjtnet.com/blog/?p=1272</guid>
		<description><![CDATA[Macro Scheduler has a number of scheduling features to allow you to specify when a macro should fire.  One of these is mechanisms is called a Trigger.  There are several trigger types:

Window Event
File Event
Folder Event
Custom Event

A Window Event can be set to fire when a specified window appears or disappears.  Similarly file [...]


Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2008/12/15/mass-import-of-scripts-and-groups-to-v11/' rel='bookmark' title='Permanent Link: Mass Import of Scripts and Groups to v11'>Mass Import of Scripts and Groups to v11</a></li><li><a href='http://www.mjtnet.com/blog/2007/05/18/first-winner-of-scripts-tips-competition/' rel='bookmark' title='Permanent Link: First Winner of Scripts &#038; Tips Competition'>First Winner of Scripts &#038; Tips Competition</a></li><li><a href='http://www.mjtnet.com/blog/2008/03/11/embedding-files-in-macro-scheduler-scripts/' rel='bookmark' title='Permanent Link: Embedding Files in Macro Scheduler Scripts'>Embedding Files in Macro Scheduler Scripts</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Macro Scheduler has a number of scheduling features to allow you to specify when a macro should fire.  One of these is mechanisms is called a Trigger.  There are several trigger types:</p>
<ul>
<li>Window Event</li>
<li>File Event</li>
<li>Folder Event</li>
<li>Custom Event</li>
</ul>
<p>A Window Event can be set to fire when a specified window appears or disappears.  Similarly file events can be set to fire the macro when the specified file exists or ceases to exist.  Folder events offer much the same (a folder exists or ceases to exist) but also a little more.  A Folder event can also be configured which will fire the macro when a new file appears in the folder, or a file is removed from the folder.</p>
<p><strong>New File Triggers</strong></p>
<p>With a &#8220;New File in Folder&#8221; trigger the macro will fire whenever a new file appears in the folder, regardless of what that file is called.  This can be very useful and is often used to detect incoming files for further processing.  In a situation like this we would need to detect that a new file has appeared and then do something with it.  Using the New File in Folder trigger will cause the macro to run, but then we need the macro to determine what that file is called.  We can do that with a VBScript function which returns the newest file in a folder:</p>
<pre name="code" class="macroscript">VBSTART
Function NewestFile(Folder)
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(Folder)
dPrevDate = "0"
For Each oFile In oFolder.Files
  If DateDiff("s", dPrevDate, oFile.DateLastModified) > 0 Then
    sNewestFile = oFile.Path
    dPrevDate = oFile.DateLastModified
  End If
Next
NewestFile = sNewestFile
End Function
VBEND</pre>
<p>We can then call it like this:</p>
<pre name="code" class="macroscript">VBEval>NewestFile("c:\downloads"),filename</pre>
<p>This will return in filename the path of the newest file in the given folder.  So if our macro is fired by a new file appearing in a folder it can then run this code to get that file&#8217;s path and do something with it.</p>
<p><strong>Custom Triggers</strong></p>
<p>Custom triggers allow you to create any kind of trigger you can think of by executing Macro Scheduler code.  Maybe you want to monitor the contents of a text file or an INI file entry, a registry entry or the size of a specific file.  If you can code the check in Macro Scheduler you can create a trigger out of it.</p>
<p>Custom triggers work by linking to a script (.scp) file which contain two subroutines.  One subroutine is called Trigger and the other Reset.  Initially the Trigger subroutine is called repeatedly until it sets MACRO_RESULT to TRUE.  Thereupon Macro Scheduler calls the Reset routine instead until it too sets MACRO_RESULT to TRUE and the cycle then continues.</p>
<p>By way of an example lets say we want to trigger a macro based on the value of an INI file entry.  Let&#8217;s say our INI file looks like this:</p>
<blockquote><p>[MyStuff]<br />
Color=red</p></blockquote>
<p>Let&#8217;s say we want to trigger a macro to run when the Color entry in the INI file gets set to &#8220;blue&#8221;.  Here&#8217;s our trigger script:</p>
<pre name="code" class="macroscript">SRT>Trigger
  ReadIniFile>d:\files\myini.ini,MyStuff,Color,gColor
  If>gColor=blue
    Let>MACRO_RESULT=TRUE
  Endif
END>Trigger

SRT>Reset
  ReadIniFile>d:\files\myini.ini,MyStuff,Color,gColor
  If>gColor<>blue
    Let>MACRO_RESULT=TRUE
  Endif
END>Reset</pre>
<p>So here the Trigger routine which is executed continually by the scheduler will return TRUE only if Color in the INI file becomes equal to &#8220;blue&#8221;.  Thereupon the Reset routine will be executed which will reset the trigger when Color is no longer &#8220;blue&#8221;.  After that the Trigger routine is executed again.</p>
<p>Since Trigger routines are run frequently on a very tight interval they should be kept as small as possible and should not be long running.  Don&#8217;t make Trigger scripts that perform too much complicated processing or include delays as this could cause resource issues.  Sometimes, for more complicated &#8220;triggers&#8221; or monitoring scripts you may be better off creating a looping macro or repeating macro.  E.g. if you wanted to poll a POP3 server for an email message containing specific content this is a more time consuming process subject to network delays so would probably not be a good candidate for a Custom Trigger.  Instead create a macro which checks the email every few minutes, or one that loops continuously.</p>
<p><a class="tt-small" href="http://twitter.com/home/?status=Trigger+Scripts+http://mjtnet.com/u7706" title="Post to Twitter (http://mjtnet.com/u7706)"><img class="nothumb" src="http://www.mjtnet.com/blog/wp-content/plugins/tweet-this/tweet-this-small.png" alt="[Post to Twitter]" /> Tweet This</a></p>

<p>Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2008/12/15/mass-import-of-scripts-and-groups-to-v11/' rel='bookmark' title='Permanent Link: Mass Import of Scripts and Groups to v11'>Mass Import of Scripts and Groups to v11</a></li><li><a href='http://www.mjtnet.com/blog/2007/05/18/first-winner-of-scripts-tips-competition/' rel='bookmark' title='Permanent Link: First Winner of Scripts &#038; Tips Competition'>First Winner of Scripts &#038; Tips Competition</a></li><li><a href='http://www.mjtnet.com/blog/2008/03/11/embedding-files-in-macro-scheduler-scripts/' rel='bookmark' title='Permanent Link: Embedding Files in Macro Scheduler Scripts'>Embedding Files in Macro Scheduler Scripts</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mjtnet.com/blog/2010/09/08/trigger-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t Overwhelm your Target!</title>
		<link>http://www.mjtnet.com/blog/2010/08/24/dont-overwhelm-your-target/</link>
		<comments>http://www.mjtnet.com/blog/2010/08/24/dont-overwhelm-your-target/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 16:24:01 +0000</pubDate>
		<dc:creator>Marcus Tettmar</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.mjtnet.com/blog/?p=1263</guid>
		<description><![CDATA[When sending keystrokes to other applications remember that Macro Scheduler works much faster than a human being can type.  Many applications do form field verification or background processing on the fly as the text is received.  And most applications were designed on the assumption that a human being would be operating them.  [...]


Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2006/01/16/keyboard-shortcuts/' rel='bookmark' title='Permanent Link: Keyboard Shortcuts'>Keyboard Shortcuts</a></li><li><a href='http://www.mjtnet.com/blog/2008/10/27/top-tips-for-reliable-macros/' rel='bookmark' title='Permanent Link: Top Tips for Reliable Macros'>Top Tips for Reliable Macros</a></li><li><a href='http://www.mjtnet.com/blog/2006/01/17/how-to-start-writing-an-automation-script/' rel='bookmark' title='Permanent Link: How to Start Writing an Automation Script'>How to Start Writing an Automation Script</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>When sending keystrokes to other applications remember that Macro Scheduler works much faster than a human being can type.  Many applications do form field verification or background processing on the fly as the text is received.  And most applications were designed on the assumption that a human being would be operating them.  It may not have occurred to the developers that a robot might try to send a stream of text to the UI at the rate of 5000 characters a second!</p>
<p>With some applications if you try to send too many characters at once you may find that some of those characters fail to show up, or the string is truncated.  </p>
<p>The solution should be obvious by now.  That is to slow down the key send rate.  You can do this easily by setting the SK_DELAY parameter which introduces a specified millisecond delay between each character.</p>
<pre name="code" class="macroscript">Let>SK_DELAY=20
Send>long_string</pre>
<p>Of course you could break the long string down into smaller chunks and insert a delay between them:</p>
<pre name="code" class="macroscript">Send>part_1
Wait>0.3
Send>part_2
Wait>0.2
Send>part_3</pre>
<p>But SK_DELAY is simpler and easier if you can&#8217;t control the length of the data easily.</p>
<p>A related issue I see every now and then is when &#8220;tabbing&#8221; from one field to another on a form.  Pressing the tab key moves the focus to the next field, so we use this while sending data into a form.  Sometimes we&#8217;ll encounter an application which needs a bit of time after a field has been focused before it can accept data, or the other way around.  So sending Tab immediately after/before sending the data with no delay fails to work.  Adding in a small delay between sending the data and the Tab solves it:</p>
<pre name="code" class="macroscript">Send>field_data
Wait>0.3
Press Tab

Wait>0.3
Send>next_field
Wait>0.3
Press Tab

etc</pre>
<p>Similarly when we need to tab through lots of fields at once without sending data we may try to save ourselves coding time by writing:</p>
<pre name="code" class="macroscript">Press Tab * 10</pre>
<p>But if the app needs time to react between each tab we may have to split that out into separate tabs with delays between them or replace with a repeat/until loop:</p>
<pre name="code" class="macroscript">Let>tabs=0
Repeat>tabs
  Press Tab
  Wait>0.2
  Let>tabs=tabs+1
Until>tabs=10</pre>
<p>As I&#8217;ve said many times before the most common causes of things not working as expected are either timing or focus.  Macros run way faster than a human can type which is often beneficial but if things aren&#8217;t quite right start off by slowing the macro down a bit.  You can always speed it up later!</p>
<p><a class="tt-small" href="http://twitter.com/home/?status=Don%26%238217%3Bt+Overwhelm+your+Target%21+http://mjtnet.com/u7541" title="Post to Twitter (http://mjtnet.com/u7541)"><img class="nothumb" src="http://www.mjtnet.com/blog/wp-content/plugins/tweet-this/tweet-this-small.png" alt="[Post to Twitter]" /> Tweet This</a></p>

<p>Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2006/01/16/keyboard-shortcuts/' rel='bookmark' title='Permanent Link: Keyboard Shortcuts'>Keyboard Shortcuts</a></li><li><a href='http://www.mjtnet.com/blog/2008/10/27/top-tips-for-reliable-macros/' rel='bookmark' title='Permanent Link: Top Tips for Reliable Macros'>Top Tips for Reliable Macros</a></li><li><a href='http://www.mjtnet.com/blog/2006/01/17/how-to-start-writing-an-automation-script/' rel='bookmark' title='Permanent Link: How to Start Writing an Automation Script'>How to Start Writing an Automation Script</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mjtnet.com/blog/2010/08/24/dont-overwhelm-your-target/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Launching URLs in Default Browser (and a small bug!)</title>
		<link>http://www.mjtnet.com/blog/2010/07/14/launching-urls-in-default-browser-and-a-small-bug/</link>
		<comments>http://www.mjtnet.com/blog/2010/07/14/launching-urls-in-default-browser-and-a-small-bug/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 10:06:10 +0000</pubDate>
		<dc:creator>Marcus Tettmar</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.mjtnet.com/blog/?p=1253</guid>
		<description><![CDATA[A quick and easy way to launch a URL in the default web browser is just to use the ExecuteFile command:
ExecuteFile>http://www.mjtnet.com/
However, I have recently discovered that ExecuteFile is currently limited to a command line length of MAX_PATH (260 chars) and that if more than 260 chars are passed it will cause Macro Scheduler to crash. [...]


Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2010/03/04/choose-your-web-browser/' rel='bookmark' title='Permanent Link: Choose Your Web Browser'>Choose Your Web Browser</a></li><li><a href='http://www.mjtnet.com/blog/2010/06/23/associating-a-file-extension-with-a-compiled-macro/' rel='bookmark' title='Permanent Link: Associating a File Extension with a Compiled Macro'>Associating a File Extension with a Compiled Macro</a></li><li><a href='http://www.mjtnet.com/blog/2007/08/07/keep-it-simple-shortcuts-and-applications/' rel='bookmark' title='Permanent Link: Keep it Simple &#8211; Shortcuts and Applications'>Keep it Simple &#8211; Shortcuts and Applications</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>A quick and easy way to launch a URL in the default web browser is just to use the ExecuteFile command:</p>
<p>ExecuteFile>http://www.mjtnet.com/</p>
<p>However, I have recently discovered that ExecuteFile is currently limited to a command line length of MAX_PATH (260 chars) and that if more than 260 chars are passed it will cause Macro Scheduler to crash.  This is a bug that we&#8217;ll get fixed in the next update (increase the limit if possible AND prevent a crash if more chars than can be handled are passed).</p>
<p>Another way to launch a URL in the default browser is to use the Run command.  First you need to determine the path to the default browser which you can do by querying the registry:</p>
<pre name="code" class="macroscript">Let>url=http://www.mjtnet.com/

//get path of default browser ...
RegistryReadKey>HKEY_CLASSES_ROOT,htmlfile\shell\open\command,,browserEXE

Run>%browserEXE% %url%</pre>
<p><a class="tt-small" href="http://twitter.com/home/?status=Launching+URLs+in+Default+Browser+%28and+a+small+bug%21%29+http://mjtnet.com/u7329" title="Post to Twitter (http://mjtnet.com/u7329)"><img class="nothumb" src="http://www.mjtnet.com/blog/wp-content/plugins/tweet-this/tweet-this-small.png" alt="[Post to Twitter]" /> Tweet This</a></p>

<p>Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2010/03/04/choose-your-web-browser/' rel='bookmark' title='Permanent Link: Choose Your Web Browser'>Choose Your Web Browser</a></li><li><a href='http://www.mjtnet.com/blog/2010/06/23/associating-a-file-extension-with-a-compiled-macro/' rel='bookmark' title='Permanent Link: Associating a File Extension with a Compiled Macro'>Associating a File Extension with a Compiled Macro</a></li><li><a href='http://www.mjtnet.com/blog/2007/08/07/keep-it-simple-shortcuts-and-applications/' rel='bookmark' title='Permanent Link: Keep it Simple &#8211; Shortcuts and Applications'>Keep it Simple &#8211; Shortcuts and Applications</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mjtnet.com/blog/2010/07/14/launching-urls-in-default-browser-and-a-small-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Associating a File Extension with a Compiled Macro</title>
		<link>http://www.mjtnet.com/blog/2010/06/23/associating-a-file-extension-with-a-compiled-macro/</link>
		<comments>http://www.mjtnet.com/blog/2010/06/23/associating-a-file-extension-with-a-compiled-macro/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 10:14:46 +0000</pubDate>
		<dc:creator>Marcus Tettmar</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.mjtnet.com/blog/?p=1237</guid>
		<description><![CDATA[I have a few scripts which perform actions on files.  Rather than have the script ask me what file to use, it is easier to associate the file type with the script so that I can just double click on the file (or right click and choose &#8220;Open with&#8221;) in Windows Explorer.
For this to [...]


Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2006/11/09/code-signing-compiled-macros/' rel='bookmark' title='Permanent Link: Code Signing Compiled Macros'>Code Signing Compiled Macros</a></li><li><a href='http://www.mjtnet.com/blog/2009/11/05/how-to-sort-a-csv-file/' rel='bookmark' title='Permanent Link: How to Sort a CSV File'>How to Sort a CSV File</a></li><li><a href='http://www.mjtnet.com/blog/2006/02/16/scripting-file-upload-boxes/' rel='bookmark' title='Permanent Link: Scripting File Upload Boxes'>Scripting File Upload Boxes</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>I have a few scripts which perform actions on files.  Rather than have the script ask me what file to use, it is easier to associate the file type with the script so that I can just double click on the file (or right click and choose &#8220;Open with&#8221;) in Windows Explorer.</p>
<p>For this to work the script must first accept a file on the command line.  Here&#8217;s a really simple script which reads the content of a file passed into the script with the &#8220;thefile&#8221; command line parameter:</p>
<pre name="code" class="macroscript">ReadFile>%thefile%,fdata
MessageModal>fdata</pre>
<p>If you were to compile this script and then pass thefile on the command line it would read in the file content and display it in a message box:</p>
<blockquote><p>c:\path\myexe.exe /thefile=c:\somefile.mjt</p></blockquote>
<p>Now, if we create a file association for .mjt files we would only need to double click on the .mjt file to have it open in the exe.</p>
<p>The easiest way to create a file association for a file that does not already have one is to just double click on the file in Windows Explorer.  Then when asked choose to select from a list of installed programs and on the next dialog click on the &#8220;Browse&#8221; button to locate your executable.</p>
<p>If the file extension is already associated with other applications then right click on the file and choose &#8220;Open With&#8221; and then &#8220;Choose program&#8230;&#8221;, then UNCHECK &#8220;Always use the selected program to open this kind of file&#8221; and click on &#8220;Browse&#8221; to locate your executable.</p>
<p>Initially this won&#8217;t quite work.  We need to make a small change, as this creates a mapping in the registry which looks like this:</p>
<blockquote><p>&#8220;c:\path\myexe.exe&#8221; &#8220;%1&#8243;</p></blockquote>
<p>We want to change it to:</p>
<blockquote><p>&#8220;c:\path\myexe.exe&#8221; /thefile=&#8221;%1&#8243;</p></blockquote>
<p>So after creating the file association via Windows Explorer we need to make a small registry change:</p>
<p>1. Fire up RegEdit.exe (Start/Run and then type regedit.exe)<br />
2. Open HKEY_CLASSES_ROOT<br />
3. Search for your exe name to find the &#8220;c:\path\myexe.exe&#8221; &#8220;%1&#8243; entry<br />
4. Make the change as above, changing the &#8220;%1&#8243; to /thefile=&#8221;%1&#8243;</p>
<p>Now, when you double click the file (or right click/Open with) it will launch your exe, with the filename passed to it in the &#8220;thefile&#8221; parameter.  </p>
<p>You could actually code the script in such a way that you don&#8217;t need to do the registry change.  You could parse the COMMAND_LINE system variable to get the file from the command line, without requiring a custom parameter name.  This is discussed in this <a href="http://www.mjtnet.com/usergroup/viewtopic.php?t=5951">forum post</a> which talks about being able to drag and drop a file onto a script.  </p>
<p>If you want to create the file association programmatically, take a look at what registry entries are created by Windows when you do it manually.  Then you can use the registry functions to achieve the same.  E.g. this script associates .why files with the &#8220;c:\where\why.exe&#8221; executable expecting the file in a parameter called &#8220;thefile&#8221;:</p>
<pre name="code" class="macroscript">RegistryWriteKey>HKEY_CLASSES_ROOT,.why,,why_auto_file
RegistryWriteKey>HKEY_CLASSES_ROOT,why_auto_file\shell\open\command,,"c:\where\why.exe" /thefile="%1"</pre>
<p><a class="tt-small" href="http://twitter.com/home/?status=Associating+a+File+Extension+with+a+Compiled+Macro+http://mjtnet.com/u7171" title="Post to Twitter (http://mjtnet.com/u7171)"><img class="nothumb" src="http://www.mjtnet.com/blog/wp-content/plugins/tweet-this/tweet-this-small.png" alt="[Post to Twitter]" /> Tweet This</a></p>

<p>Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2006/11/09/code-signing-compiled-macros/' rel='bookmark' title='Permanent Link: Code Signing Compiled Macros'>Code Signing Compiled Macros</a></li><li><a href='http://www.mjtnet.com/blog/2009/11/05/how-to-sort-a-csv-file/' rel='bookmark' title='Permanent Link: How to Sort a CSV File'>How to Sort a CSV File</a></li><li><a href='http://www.mjtnet.com/blog/2006/02/16/scripting-file-upload-boxes/' rel='bookmark' title='Permanent Link: Scripting File Upload Boxes'>Scripting File Upload Boxes</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mjtnet.com/blog/2010/06/23/associating-a-file-extension-with-a-compiled-macro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tweetlib: A DLL Plugin for Tweeting Status Updates via oAuth</title>
		<link>http://www.mjtnet.com/blog/2010/05/25/tweetlib-a-dll-plugin-for-tweeting-status-updates-via-oauth/</link>
		<comments>http://www.mjtnet.com/blog/2010/05/25/tweetlib-a-dll-plugin-for-tweeting-status-updates-via-oauth/#comments</comments>
		<pubDate>Tue, 25 May 2010 16:23:44 +0000</pubDate>
		<dc:creator>Marcus Tettmar</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[Automation]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Web/Tech]]></category>

		<guid isPermaLink="false">http://www.mjtnet.com/blog/?p=1221</guid>
		<description><![CDATA[As noted yesterday I have been waiting on Twitter to provide xAuth access.  They declined, saying it was not appropriate.  I&#8217;m not really sure why.  
No matter, I decided to make a small DLL to simplify Tweeting from Macro Scheduler.  It uses the full oAuth interface.
Implementing oAuth in Macro Scheduler code [...]


Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2010/05/24/tweeting-from-macro-scheduler-without-the-api/' rel='bookmark' title='Permanent Link: Tweeting from Macro Scheduler Without the API'>Tweeting from Macro Scheduler Without the API</a></li><li><a href='http://www.mjtnet.com/blog/2008/10/21/beta-updates/' rel='bookmark' title='Permanent Link: Beta Updates'>Beta Updates</a></li><li><a href='http://www.mjtnet.com/blog/2008/12/17/webrecorder-and-workflow-designer-updates/' rel='bookmark' title='Permanent Link: WebRecorder and Workflow Designer Updates'>WebRecorder and Workflow Designer Updates</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>As noted yesterday I have been waiting on <a href="http://www.twitter.com/">Twitter</a> to provide xAuth access.  They declined, saying it was not appropriate.  I&#8217;m not really sure why.  </p>
<p>No matter, I decided to make a small DLL to simplify Tweeting from <a href="http://www.mjtnet.com/macro_scheduler.htm">Macro Scheduler</a>.  It uses the full oAuth interface.</p>
<p>Implementing oAuth in Macro Scheduler code would require lots of VBScript code and would be very complicated (although doable in theory).  So instead I decided to create a DLL which you can use in Macro Scheduler to tweet in one line of code.</p>
<p>You can <a href="http://www.mjtnet.com/software/tweetlib.zip">download it here</a>.</p>
<p>And then to post a status update all you need to do is something like this:</p>
<pre name="code" class="macroscript">Let>message=Hello from Macro Scheduler
LibFunc>%SCRIPT_DIR%\tweetlib.dll,UpdateStatus,r,message,buff,1024</pre>
<p>Note that the first time you call UpdateStatus you will be asked to log into Twitter and click &#8220;Allow&#8221; to authorise Macro Scheduler to access your account.  You will then be given a PIN to enter.  You only need to do this once.  If you ever need to revoke access and start over call the RemoveCredentials function.  Your Twitter username and password are NOT stored anywhere.  This uses the oAuth authorisation scheme which provides an access token.  It is the access token which is stored and this only allows Macro Scheduler to access the API for your account.</p>
<p>The return buffer will contain the XML of the status update operation if successful or an error message if not.  </p>
<p>See readme.txt and sample .scp in the zip file.  Enjoy.</p>
<p><a class="tt-small" href="http://twitter.com/home/?status=Tweetlib%3A+A+DLL+Plugin+for+Tweeting+Status+Updates+via+oAuth+http://mjtnet.com/u6913" title="Post to Twitter (http://mjtnet.com/u6913)"><img class="nothumb" src="http://www.mjtnet.com/blog/wp-content/plugins/tweet-this/tweet-this-small.png" alt="[Post to Twitter]" /> Tweet This</a></p>

<p>Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2010/05/24/tweeting-from-macro-scheduler-without-the-api/' rel='bookmark' title='Permanent Link: Tweeting from Macro Scheduler Without the API'>Tweeting from Macro Scheduler Without the API</a></li><li><a href='http://www.mjtnet.com/blog/2008/10/21/beta-updates/' rel='bookmark' title='Permanent Link: Beta Updates'>Beta Updates</a></li><li><a href='http://www.mjtnet.com/blog/2008/12/17/webrecorder-and-workflow-designer-updates/' rel='bookmark' title='Permanent Link: WebRecorder and Workflow Designer Updates'>WebRecorder and Workflow Designer Updates</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mjtnet.com/blog/2010/05/25/tweetlib-a-dll-plugin-for-tweeting-status-updates-via-oauth/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Tweeting from Macro Scheduler Without the API</title>
		<link>http://www.mjtnet.com/blog/2010/05/24/tweeting-from-macro-scheduler-without-the-api/</link>
		<comments>http://www.mjtnet.com/blog/2010/05/24/tweeting-from-macro-scheduler-without-the-api/#comments</comments>
		<pubDate>Mon, 24 May 2010 13:51:02 +0000</pubDate>
		<dc:creator>Marcus Tettmar</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Web/Tech]]></category>

		<guid isPermaLink="false">http://www.mjtnet.com/blog/?p=1213</guid>
		<description><![CDATA[A while back I posted an article showing how to Tweet via Twitter&#8217;s API.  It uses basic authentication which Twitter plan to turn off in the near future. The alternative, oAuth is awkward for desktop based apps, but xAuth is now available and should be doable in Macro Scheduler.  I have requested xAuth [...]


Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2010/05/25/tweetlib-a-dll-plugin-for-tweeting-status-updates-via-oauth/' rel='bookmark' title='Permanent Link: Tweetlib: A DLL Plugin for Tweeting Status Updates via oAuth'>Tweetlib: A DLL Plugin for Tweeting Status Updates via oAuth</a></li><li><a href='http://www.mjtnet.com/blog/2009/04/20/twittering-from-macro-scheduler-with-the-twitter-api/' rel='bookmark' title='Permanent Link: Twittering from Macro Scheduler with the Twitter API'>Twittering from Macro Scheduler with the Twitter API</a></li><li><a href='http://www.mjtnet.com/blog/2007/10/12/macro-scheduler-92-released/' rel='bookmark' title='Permanent Link: Macro Scheduler 9.2 Released'>Macro Scheduler 9.2 Released</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>A while back <a href="http://www.mjtnet.com/blog/2009/04/20/twittering-from-macro-scheduler-with-the-twitter-api/">I posted an article showing how to Tweet</a> via <a href="http://www.twitter.com">Twitter</a>&#8217;s API.  It uses basic authentication which Twitter plan to turn off in the near future. The alternative, oAuth is awkward for desktop based apps, but xAuth is now available and should be doable in Macro Scheduler.  I have requested xAuth access from Twitter and, assuming it&#8217;s doable, will try and provide an example once I&#8217;ve received it and tried it out.</p>
<p>In the mean time it occurred to me that we don&#8217;t really need an API if all we want to do is send a status update.  We can do that easily using Macro Scheduler and WebRecorder functions by controlling an instance of Internet Explorer, which can be done in the background. </p>
<p>Below is a script which demonstrates this.  It offers a function called LoginToTwitter which need only be called once per session, and an UpdateStatus function to update your status.  Just set your Twitter username and password in the first two lines and you should be all set.</p>
<pre name="code" class="macroscript">Let>TW_USERNAME=XXXXX
Let>TW_PASSWORD=XXXXX

//only need do this once per session
GoSub>LoginToTwitter

GoSub>UpdateStatus,This is a test

GoSub>UpdateStatus,This is a test 2

GoSub>LogOut

// END

//*** SUBROUTINES ***//
SRT>LoadWR
  //load the WebRecorder runtime
  LibLoad>IEAuto.dll,hIE
  If>hIE=0
    MessageModal>Could not load IEAuto.dll, make sure it is in the path or edit the LibLoad line.
    Exit>0
  EndIf
END>LoadWR

SRT>LoginToTwitter
  GoSub>LoadWR
  //open IE
  LibFunc>hIE,CreateIE,ieTwitter,0
  LibFunc>hIE,ShowIE,res,ieTwitter,1

  //log in to Twitter
  LibFunc>hIE,Navigate,r,ieTwitter,http://twitter.com/login
  LibFunc>hIE,WaitIE,r,ieTwitter
  LibFunc>hIE,FormFill,r,ieTwitter,,,session[username_or_email],TW_USERNAME,0
  LibFunc>hIE,FormFill,r,ieTwitter,,,session[password],TW_PASSWORD,submit

  LibFunc>hIE,WaitIE,r,ieTwitter
  Wait>1
  LibFunc>hIE,WaitIE,r,ieTwitter
  Wait>1
END>LoginToTwitter

SRT>UpdateStatus
  LibFunc>hIE,FormFill,r,ieTwitter,,,status,UpdateStatus_VAR_1,submit
  LibFunc>hIE,WaitIE,r,ieTwitter
  Wait>1
END>UpdateStatus

SRT>LogOut
  LibFunc>hIE,KillIE,r,ieTwitter
END>LogOut</pre>
<p>You need the IEAuto.DLL library which is installed with <a href="http://www.mjtnet.com/webrecorder.htm">WebRecorder</a>.  </p>
<p>For a bit of fun the following code copies the currently highlighted text to the clipboard and tweets it.  So assigned to a hot key it can be used to tweet any text from any application.   </p>
<pre name="code" class="macroscript">Press CTRL
Send>c
Release CTRL
WaitClipBoard
GetClipBoard>theText
GoSub>UpdateStatus,theText</pre>
<p>The real challenge is finding something useful to do with it! <img src='http://www.mjtnet.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><a class="tt-small" href="http://twitter.com/home/?status=Tweeting+from+Macro+Scheduler+Without+the+API+http://mjtnet.com/u6875" title="Post to Twitter (http://mjtnet.com/u6875)"><img class="nothumb" src="http://www.mjtnet.com/blog/wp-content/plugins/tweet-this/tweet-this-small.png" alt="[Post to Twitter]" /> Tweet This</a></p>

<p>Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2010/05/25/tweetlib-a-dll-plugin-for-tweeting-status-updates-via-oauth/' rel='bookmark' title='Permanent Link: Tweetlib: A DLL Plugin for Tweeting Status Updates via oAuth'>Tweetlib: A DLL Plugin for Tweeting Status Updates via oAuth</a></li><li><a href='http://www.mjtnet.com/blog/2009/04/20/twittering-from-macro-scheduler-with-the-twitter-api/' rel='bookmark' title='Permanent Link: Twittering from Macro Scheduler with the Twitter API'>Twittering from Macro Scheduler with the Twitter API</a></li><li><a href='http://www.mjtnet.com/blog/2007/10/12/macro-scheduler-92-released/' rel='bookmark' title='Permanent Link: Macro Scheduler 9.2 Released'>Macro Scheduler 9.2 Released</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mjtnet.com/blog/2010/05/24/tweeting-from-macro-scheduler-without-the-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weekly Forum Round-up</title>
		<link>http://www.mjtnet.com/blog/2010/05/21/weekly-forum-round-up/</link>
		<comments>http://www.mjtnet.com/blog/2010/05/21/weekly-forum-round-up/#comments</comments>
		<pubDate>Fri, 21 May 2010 10:34:04 +0000</pubDate>
		<dc:creator>Marcus Tettmar</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.mjtnet.com/blog/?p=1209</guid>
		<description><![CDATA[I thought I might start a weekly round up of some of the Macro Scheduler forum posts that caught my eye during the week.  Not everyone gets a chance to browse the forums all the time, so it might help to link to some here.  Then those that subscribe to the blog via [...]


Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2008/03/21/round-up-of-learning-resources/' rel='bookmark' title='Permanent Link: Round-up of Learning Resources'>Round-up of Learning Resources</a></li><li><a href='http://www.mjtnet.com/blog/2007/05/03/celebrations-all-round/' rel='bookmark' title='Permanent Link: Celebrations All Round'>Celebrations All Round</a></li><li><a href='http://www.mjtnet.com/blog/2009/01/21/free-t-shirts-for-forum-points/' rel='bookmark' title='Permanent Link: Free T-Shirts for Forum Points'>Free T-Shirts for Forum Points</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>I thought I might start a weekly round up of some of the <a href="http://www.mjtnet.com/usergroup/">Macro Scheduler forum</a> posts that caught my eye during the week.  Not everyone gets a chance to browse the forums all the time, so it might help to link to some here.  Then those that subscribe to the blog via RSS/Email will see them and they&#8217;ll also show up in Macro Scheduler&#8217;s News Feed window.</p>
<p>The forums are quite active but I won&#8217;t link to every little discussion or request for support &#8211; just those that demonstrate a new feature, or work as a &#8220;how to&#8221; or anything else that I think could be useful.  We&#8217;ll see how it goes.</p>
<p>So here&#8217;s my list for week ending 21st May 2010:</p>
<p><a href="http://www.mjtnet.com/usergroup/viewtopic.php?t=6188">How to trim spaces from the ends of, or within, a string</a></p>
<p><a href="http://www.mjtnet.com/usergroup/viewtopic.php?t=6187">A Progress Bar Demo using Macro Scheduler 12</a></p>
<p><a href="http://www.mjtnet.com/usergroup/viewtopic.php?t=6062">How to make a custom dialog minimize to the task bar</a></p>
<p><a href="http://www.mjtnet.com/usergroup/viewtopic.php?t=6199">Putting a status bar with multiple panels on a custom dialog</a></p>
<p><a href="http://www.mjtnet.com/usergroup/viewtopic.php?t=6186">Finding a drive based on its label (volume name)</a></p>
<p><a href="http://www.mjtnet.com/usergroup/viewtopic.php?t=6200">Getting the HTML source of a page using WebRecorder</a></p>
<p><a href="http://www.mjtnet.com/usergroup/viewtopic.php?t=6065">Running Automated Testing scripts in the background via VMWare</a></p>
<p><a class="tt-small" href="http://twitter.com/home/?status=Weekly+Forum+Round-up+http://mjtnet.com/u6776" title="Post to Twitter (http://mjtnet.com/u6776)"><img class="nothumb" src="http://www.mjtnet.com/blog/wp-content/plugins/tweet-this/tweet-this-small.png" alt="[Post to Twitter]" /> Tweet This</a></p>

<p>Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2008/03/21/round-up-of-learning-resources/' rel='bookmark' title='Permanent Link: Round-up of Learning Resources'>Round-up of Learning Resources</a></li><li><a href='http://www.mjtnet.com/blog/2007/05/03/celebrations-all-round/' rel='bookmark' title='Permanent Link: Celebrations All Round'>Celebrations All Round</a></li><li><a href='http://www.mjtnet.com/blog/2009/01/21/free-t-shirts-for-forum-points/' rel='bookmark' title='Permanent Link: Free T-Shirts for Forum Points'>Free T-Shirts for Forum Points</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mjtnet.com/blog/2010/05/21/weekly-forum-round-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run All Macros in a Folder/Group</title>
		<link>http://www.mjtnet.com/blog/2010/05/07/run-all-macros-in-a-foldergroup/</link>
		<comments>http://www.mjtnet.com/blog/2010/05/07/run-all-macros-in-a-foldergroup/#comments</comments>
		<pubDate>Fri, 07 May 2010 15:26:17 +0000</pubDate>
		<dc:creator>Marcus Tettmar</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.mjtnet.com/blog/?p=1172</guid>
		<description><![CDATA[Someone asked me today how to run all macros found in a folder.  This simple script will run all macros it finds in its own folder in turn:
GetFileList>%SCRIPT_DIR%\*.scp,MacroFiles
Separate>MacroFiles,;,Macros
If>Macros_count>0
  Let>k=0
  Repeat>k
    Let>k=k+1
    Let>this_macro=Macros_%k%
    If>this_macroSCRIPT_FILE
      Macro>this_macro
    Endif
 [...]


Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2008/07/31/extract-filename-and-folder-from-path/' rel='bookmark' title='Permanent Link: Extract Filename and Folder from Path'>Extract Filename and Folder from Path</a></li><li><a href='http://www.mjtnet.com/blog/2010/05/20/sharing-and-synchronizing-macros/' rel='bookmark' title='Permanent Link: Sharing and Synchronizing Macros'>Sharing and Synchronizing Macros</a></li><li><a href='http://www.mjtnet.com/blog/2010/01/29/running-macro-scheduler-macros-over-the-web-via-php/' rel='bookmark' title='Permanent Link: Running Macro Scheduler Macros over the Web Via PHP'>Running Macro Scheduler Macros over the Web Via PHP</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Someone asked me today how to run all macros found in a folder.  This simple script will run all macros it finds in its own folder in turn:</p>
<pre name="code" class="macroscript">GetFileList>%SCRIPT_DIR%\*.scp,MacroFiles
Separate>MacroFiles,;,Macros
If>Macros_count>0
  Let>k=0
  Repeat>k
    Let>k=k+1
    Let>this_macro=Macros_%k%
    If>this_macro<>SCRIPT_FILE
      Macro>this_macro
    Endif
  Until>k=Macros_count
Endif</pre>
<p>Note the check to make sure it doesn&#8217;t run itself!  </p>
<p>This could be useful where you want a quick way to schedule a series of macros.  Schedule this script and then all you need to do to add another to the schedule is to drop it into the same folder (or macro group).</p>
<p>For a bit more control consider naming each macro with a numeric prefix and then sort the array to determine the order in which they are run.  Version 12 (currently in beta) has a built in ArraySort function.  Or use <a href="http://www.mjtnet.com/blog/2009/10/29/quick-sort-routine/">this QuickSort algorithm</a>.</p>
<p><a class="tt-small" href="http://twitter.com/home/?status=Run+All+Macros+in+a+Folder%2FGroup+http://mjtnet.com/u6135" title="Post to Twitter (http://mjtnet.com/u6135)"><img class="nothumb" src="http://www.mjtnet.com/blog/wp-content/plugins/tweet-this/tweet-this-small.png" alt="[Post to Twitter]" /> Tweet This</a></p>

<p>Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2008/07/31/extract-filename-and-folder-from-path/' rel='bookmark' title='Permanent Link: Extract Filename and Folder from Path'>Extract Filename and Folder from Path</a></li><li><a href='http://www.mjtnet.com/blog/2010/05/20/sharing-and-synchronizing-macros/' rel='bookmark' title='Permanent Link: Sharing and Synchronizing Macros'>Sharing and Synchronizing Macros</a></li><li><a href='http://www.mjtnet.com/blog/2010/01/29/running-macro-scheduler-macros-over-the-web-via-php/' rel='bookmark' title='Permanent Link: Running Macro Scheduler Macros over the Web Via PHP'>Running Macro Scheduler Macros over the Web Via PHP</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mjtnet.com/blog/2010/05/07/run-all-macros-in-a-foldergroup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Screen Magnifier In Only 34 Lines of Code</title>
		<link>http://www.mjtnet.com/blog/2010/03/08/screen-magnifier-in-only-34-lines-of-code/</link>
		<comments>http://www.mjtnet.com/blog/2010/03/08/screen-magnifier-in-only-34-lines-of-code/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 09:46:11 +0000</pubDate>
		<dc:creator>Marcus Tettmar</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.mjtnet.com/blog/?p=1119</guid>
		<description><![CDATA[Check out this screen magnifier, written by Dick Lockey in only 34 lines of Macro Scheduler code.   Paste it into a macro, hit run and then as you move the mouse around your screen you&#8217;ll see a 5x magnification of the cursor area.
Dialog>Dialog1
   Caption=5X Magnify
   Width=800
   Height=500
  [...]


Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2007/12/12/capturing-screen-text/' rel='bookmark' title='Permanent Link: Capturing Screen Text'>Capturing Screen Text</a></li><li><a href='http://www.mjtnet.com/blog/2009/01/23/screen-scraping-with-macro-scheduler/' rel='bookmark' title='Permanent Link: Screen Scraping with Macro Scheduler'>Screen Scraping with Macro Scheduler</a></li><li><a href='http://www.mjtnet.com/blog/2008/03/07/error-code-utility/' rel='bookmark' title='Permanent Link: Error Code Utility'>Error Code Utility</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Check out this screen magnifier, written by <a href="http://www.mjtnet.com/usergroup/profile.php?mode=viewprofile&#038;u=492">Dick Lockey</a> in only 34 lines of <a href="http://www.mjtnet.com/macro_scheduler.htm">Macro Scheduler</a> code.   Paste it into a macro, hit run and then as you move the mouse around your screen you&#8217;ll see a 5x magnification of the cursor area.</p>
<pre class="macroscript" name="code">Dialog>Dialog1
   Caption=5X Magnify
   Width=800
   Height=500
   Top=500
   Left=48
EndDialog>Dialog1
Show>Dialog1
  LibFunc>user32,GetDC,HDC1,Dialog1.handle
  LibFunc>user32,GetDC,HDC3,0

Label>Loop
  GetDialogAction>Dialog1,res1
  If>res1=2
    Exit>0
  EndIf
  GetCursorPos>CurX,CurY
  Sub>CurX,80
  Sub>CurY,50
  Wait>0.01
  LibFunc>Gdi32,StretchBlt,SBres,HDC1,0,0,800,500,HDC3,CURX,CURY,160,100,13369376
  GoSub>DrawLine,Dialog1.handle,1,0,390,250,410,250
  GoSub>DrawLine,Dialog1.handle,1,0,400,240,400,260
Goto>Loop

SRT>DrawLine
  LibFunc>user32,GetDC,HDC,%DrawLine_var_1%
  LibFunc>gdi32,CreatePen,Penres,0,%DrawLine_var_2%,%DrawLine_var_3%
  LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
  Libfunc>gdi32,MoveToEx,mtres,HDC,%DrawLine_var_4%,%DrawLine_var_5%,0
  LibFunc>gdi32,LineTo,ltres,hdc,%DrawLine_var_6%,%DrawLine_var_7%
  LibFunc>gdi32,DeleteObject,DOres,Penres
  LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawLine</pre>
<p>Yes, <a href="http://www.mjtnet.com/usergroup/viewtopic.php?p=26753">as Dick Says</a>, you get one of these with Windows.  But it&#8217;s kind of cool to see you can do the same thing with Macro Scheduler, and the code might come in handy elsewhere.  </p>
<p>Enjoy.</p>
<p><a class="tt-small" href="http://twitter.com/home/?status=Screen+Magnifier+In+Only+34+Lines+of+Code+http://mjtnet.com/u5500" title="Post to Twitter (http://mjtnet.com/u5500)"><img class="nothumb" src="http://www.mjtnet.com/blog/wp-content/plugins/tweet-this/tweet-this-small.png" alt="[Post to Twitter]" /> Tweet This</a></p>

<p>Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2007/12/12/capturing-screen-text/' rel='bookmark' title='Permanent Link: Capturing Screen Text'>Capturing Screen Text</a></li><li><a href='http://www.mjtnet.com/blog/2009/01/23/screen-scraping-with-macro-scheduler/' rel='bookmark' title='Permanent Link: Screen Scraping with Macro Scheduler'>Screen Scraping with Macro Scheduler</a></li><li><a href='http://www.mjtnet.com/blog/2008/03/07/error-code-utility/' rel='bookmark' title='Permanent Link: Error Code Utility'>Error Code Utility</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mjtnet.com/blog/2010/03/08/screen-magnifier-in-only-34-lines-of-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert raw VBScript .vbs files to Macro Scheduler Scripts</title>
		<link>http://www.mjtnet.com/blog/2010/03/01/convert-raw-vbscript-vbs-files-to-macro-scheduler-scripts/</link>
		<comments>http://www.mjtnet.com/blog/2010/03/01/convert-raw-vbscript-vbs-files-to-macro-scheduler-scripts/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 14:34:39 +0000</pubDate>
		<dc:creator>Marcus Tettmar</dc:creator>
				<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.mjtnet.com/blog/?p=1087</guid>
		<description><![CDATA[As you probably know Macro Scheduler scripts can include Microsoft VBScript.  Not only can you CALL VBScript code you can also pass values into it and retrieve values out of it (I&#8217;ve seen many competitors claim you can use VBScript in their macros when what they really mean is you can only call external [...]


Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2008/03/11/embedding-files-in-macro-scheduler-scripts/' rel='bookmark' title='Permanent Link: Embedding Files in Macro Scheduler Scripts'>Embedding Files in Macro Scheduler Scripts</a></li><li><a href='http://www.mjtnet.com/blog/2009/06/04/calling-macro-scheduler-scripts-from-vbvba/' rel='bookmark' title='Permanent Link: Calling Macro Scheduler Scripts from VB/VBA'>Calling Macro Scheduler Scripts from VB/VBA</a></li><li><a href='http://www.mjtnet.com/blog/2008/04/28/converting-office-vba-to-vbscript/' rel='bookmark' title='Permanent Link: Converting Office VBA to VBScript'>Converting Office VBA to VBScript</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>As you probably know Macro Scheduler scripts can include Microsoft VBScript.  Not only can you CALL VBScript code you can also pass values into it and retrieve values out of it (I&#8217;ve seen many competitors claim you can use VBScript in their macros when what they really mean is you can only call external VBScripts and not get results and data back).</p>
<p>This means you can take VBScript code and embed it into your macros.  However, you may need to make some small modifications to VBScript code samples you find out there in the wild, and I&#8217;m often being asked how to do this.</p>
<p>Usually the only changes necessary involve the fact that many sample scripts are designed to run as standalone .VBS files and make use of the WScript object.  This object is instantiated automatically by the Windows Scripting Host and offers methods like &#8220;Echo&#8221; and &#8220;Sleep&#8221; which you&#8217;ll often see in sample scripts.  But in the case of Macro Scheduler VBScript is being hosted by Macro Scheduler, not the Windows Scripting Host, so WScript is not available.</p>
<p>Therefore anything starting with WScript will need to be removed or replaced with something else.</p>
<p>The most common one is WScript.Echo.  This simply displays a message.  When the VBS file is run on the command line the message is output to the command line.  Otherwise it appears in a pop up message box.  Most of the time in sample scripts it is just there as an example, so you can see the code working.  You&#8217;d probably end up not wanting the script popping lots of message boxes anyway.  But if you do you could replace it with MsgBox.</p>
<p>So, remove references to WScript and you should find you&#8217;re good to go.</p>
<p><em>Update: Macro Scheduler 12 (currently in beta) ships with a built-in WScript object which implements the Echo and Sleep functions.  This means that Wscript.Echo and WScript.Sleep functions will continue to work and will not need to be removed to make the .vbs work in Macro Scheduler.</em></p>
<p><a class="tt-small" href="http://twitter.com/home/?status=Convert+raw+VBScript+.vbs+files+to+Macro+Scheduler+Scripts+http://mjtnet.com/u5304" title="Post to Twitter (http://mjtnet.com/u5304)"><img class="nothumb" src="http://www.mjtnet.com/blog/wp-content/plugins/tweet-this/tweet-this-small.png" alt="[Post to Twitter]" /> Tweet This</a></p>

<p>Related posts:<ol><li><a href='http://www.mjtnet.com/blog/2008/03/11/embedding-files-in-macro-scheduler-scripts/' rel='bookmark' title='Permanent Link: Embedding Files in Macro Scheduler Scripts'>Embedding Files in Macro Scheduler Scripts</a></li><li><a href='http://www.mjtnet.com/blog/2009/06/04/calling-macro-scheduler-scripts-from-vbvba/' rel='bookmark' title='Permanent Link: Calling Macro Scheduler Scripts from VB/VBA'>Calling Macro Scheduler Scripts from VB/VBA</a></li><li><a href='http://www.mjtnet.com/blog/2008/04/28/converting-office-vba-to-vbscript/' rel='bookmark' title='Permanent Link: Converting Office VBA to VBScript'>Converting Office VBA to VBScript</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.mjtnet.com/blog/2010/03/01/convert-raw-vbscript-vbs-files-to-macro-scheduler-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
