August 7, 2008

Get free publicity – help with a press release or case study

Filed under: General — Marcus Tettmar @ 1:38 pm

We’re currently putting together a press release which will outline how different customers of our software are saving money through software automation.

If you are interested in being featured please let me know. We’ll need a short quote and we will provide a link back to your site. We would need savings translated to monetary terms (e.g. hours saved * average hourly chargeout/labour costs).

The aim of the press release is to demonstrate the kind of savings/efficiency gains companies can make through software automation. Something everyone can benefit from under the current economic climate!

I’m also looking for more case study participants. If you’d like to get some free publicity in your industry publications and showcase your company and demonstrate how you’ve benefited from Macro Scheduler, let me know and, if suitable, I’ll send you a list of questions to get things started.

Some examples:
http://www.mjtnet.com/case-studies/FSBAltusCaseStudy.pdf
http://www.mjtnet.com/case-studies/IowaLaserCaseStudy.pdf

July 31, 2008

Extract Filename and Folder from Path

Filed under: Scripting — Marcus Tettmar @ 1:34 pm

Here’s a quick way to extract just the filename from a full path:

Let>file_path=C:\Program files\Skype\Phone\Skype.exe

//get the file name on its own
Separate>file_path,\,parts
Let>exe_name=parts_%parts_count%

//now get just the folder path
MidStr>file_path,1,{length(%file_path%)-length(%exe_name%)},folder_only

This uses Separate to explode the path into an array using the ‘\’ character as the delimiter. We’ve called the array “parts”. “parts_count” contains the number of elements created. So parts_%parts_count% is the last element, which happens to be the filename.

Now, if we want just the folder path, use MidStr to extract length of file_path minus length of exe_name.

NB: For some reason the curly brackets in the last line of code above are causing the text to output on the next line. That should all be one line. Click on “view plain” to see the raw code if you want to copy it to Macro Scheduler.

Sneak Preview: Code Folding and Bookmarks in Macro Scheduler v11

Filed under: Announcements — Marcus Tettmar @ 1:29 pm

Here’s a video of work in progress. It shows Code Folding and Bookmarks working in the new macro editor of Macro Scheduler v11 which we are currently working on.

Note this is work in progress and the video shows an early development version. All the usual caveats apply – appearances may differ to the final release. Planned release date? Probably January.

July 24, 2008

Quoting Quotes

Filed under: Scripting — Marcus Tettmar @ 1:44 pm

VBScript and Complex Expressions use the ” (double quote) character to delimit strings. Native MacroScript code doesn’t need delimited strings. But if you need to use Complex Expressions or VBScript you need to remember that strings must be delimited in quotes.

One implication of this is that if the string already has a ” character within it you will get a syntax error, because the parser thinks this marks the end of the string.

To avoid this you need to add another quote, and you can use StringReplace to replace any occurences of the ” character with a second one before passing the string to VBScript or a Complex Expression:

//example input string:
Let>mystring=your name is "Sally"

//Double quote before using string in complex expression
StringReplace>mystring,","",mystring_2
If>{%mystring_2% <> ""}
  //Do something
Endif

Without that StringReplace call to double quote the quote characters, the complex If line would produce a syntax error.

The same goes for VBScript:

//example input string:
Let>mystring=your name is "Sally"

VBSTART
VBEND

StringReplace>mystring,","",mystring_2
VBEval>MsgBox("%mystring_2%"),nul

Note that the VBEval statement evaluates a pure VBScript expression. Since VBScript strings must be in quotes we surround the variable mystring_2 with them, and need to use % symbols to tell Macro Scheduler to use the value of mystring_2. See my last post for tips on when and where to use % symbols.

On a similar note, CR LF pairs (Carriage Return and Line Feed) in strings passed to VBScript will produce errors since they are hard line breaks and cause string termination problems. We can avoid this by replacing the real CR and LF characters with the VBScript placeholders:

StringReplace>myString,CRLF," & vbCRLF & ",myString

The quotes terminate and start the string again, splitting it where the CRLF was, and replacing the hard CRLF with the VBScript vbCRLF variable. There’s also vbCR and vbLF variables for carriage returns (CR) and line feeds (LF) on their own.

July 4, 2008

Using Variables and When to use Percent Symbols (%variable%)

Filed under: Scripting — Marcus Tettmar @ 9:38 am

By default in Macro Scheduler you do not have to do anything special to refer to a variable. The following will create a variable called Name:

Let>Name=Freddy

Name is now assigned the value of Freddy.

Referring to Variables:

The following will display a message box containing the word “Freddy”:

MessageModal>Name

Macro Scheduler knows that Name is a variable and finds its value. You do not need to tell it that Name is a variable. If Name did not exist as a variable the message box would simply display the word “Name”.

If you prefer you can tell Macro Scheduler that Name is a variable like so:

MessageModal>%Name%

But, by default (see below to see how to change this behaviour), there’s really no need since Name appears on its own.

However, supposing you wanted a message box that said “My Name is Freddy” and you wanted to use the variable “Name”. In this case you need to tell Macro Scheduler that Name is a variable, like so:

MessageModal>My Name is %Name%

Hopefully the reason is clear. If we did not put % symbols around the second “Name” the message box would simply display “My Name is Name”. Equally if Macro Scheduler tried to interpret every word as a variable we’d end up with “My Freddy is Freddy”.

Rule of thumb: % symbols really only need to be used when a variable appears within another string. When used on their own they are not needed.

Creating/Modifying Variables:

% symbols mean find the value of this variable. So when creating or modifying variables do not use them. E.g., the following assigns the value Freddy to the variable “Name”

Let>Name=Freddy

If you were to include Name in % symbols then you’d be saying “Assign Freddy to the value of Name”. This could get confusing. Consider the following code:

Let>Name=Sally
Let>%Name%=Freddy

Here we’d end up with two variables, one called Name assigned the value of Sally, and another called Sally assigned the value of Freddy. Now this can be quite powerful and there may be times you want to do this, but for most of us, it is usually not what we want.

Rule of thumb: Do not use % symbols when assigning to variables. This includes variables returned by other commands as well as variables on the left of the equals sign in Let commands.

There’s an interesting forum topic on this subject here.

Exceptions:

One time we DO want to use % symbols on the left side of a Let command is when we are creating/modifying array type variables and we are using an array counter. E.g.:

Let>x=0
Repeat>x
  Let>x=x+1
  Random>9,var
  Let>Array[%x%]=var
Until>x=10

Here x is the loop counter. We are creating an array of 10 random values. In this case we want the value of x inside the array name and end up with variables Array[1], Array[2], Array[3], …. Array[10]. This is one case where we want a variable inside a variable.

Explicit Variable Resolution:

Real programmers prefer to tell the programming language when a value is a literal and when it is a variable, and as you get more advanced you may find the need to do that. You can tell Macro Scheduler to only resolve variables that are contained in % symbols and leave everything else as literals by setting VAREXPLICIT to 1:

Let>VAREXPLICIT=1

With this setting the following code will display the word “Name” in the message box:

Let>VAREXPLICIT=1
Let>Name=Fred
MessageModal>Name

Unlike before where we’d see “Fred” in the message box. Now to see the value of the Name variable we’d have to do:

MessageModal>%Name%

Note that when assigning to variables the variable name still appears on its own. Nothing changes in regards to creating or assigning to variables; only when referring to their values. The rules above still apply.

For more information see the following topics in the help file:
* User Defined Variables
* Explicit Variable Resolution
* Ignoring Spaces

May 29, 2008

TrustWatch?

Filed under: General — Marcus Tettmar @ 7:00 pm

Received an email today from a longstanding customer who is using Comcast as his ISP. Today he tried to access www.mjtnet.com and received this message:

WARNING!
This site is rated potentially unsafe by TrustWatch!

You have been redirected to this page as a service of Comcast High-Speed Internet, which includes the Comcast Toolbar. TrustWatch, a critically acclaimed, industry-leading website verification service, has restricted access to the site www.mjtnet.com for your protection. Accessing this site could put you at risk for identity theft or other financial fraud.

What the!? Identity theft? Financial fraud? Where ON EARTH do they get that idea? Who do these people think they are?

So I googled TrustWatch and found their website. I clicked on their About Trustwatch page to find a phone number. I figured I’d give them a call. I did. I got this recorded message:

The number you have dialed has been disconnected

Doesn’t exactly engender trust, does it, TrustWatch?

Update: I tried emailing them via the email address listed on their site – [email protected] – and it bounced saying an SMTP connection could not be established.

Update 2: Seems someone else had a similar experience trying to contact TrustWatch

May 23, 2008

Macro Scheduler 10.1.15 is 40 Times Faster!

Filed under: Announcements, Automation, Scripting — Marcus Tettmar @ 8:08 am

With the latest release (10.1.15) we worked on optimizing the way variables are stored internally and were able to dramatically improve performance. Dick Lockey did some tests and writes that the latest version is 40 times faster than earlier versions!

If you’re working with scripts that create and process a large number of variables – say a script which reads and processes a large number of fields from a database – you’ll want to make sure you’re using the latest release, because your scripts will be noticeably faster with this version.

Macro Scheduler History

May 19, 2008

In the News: Internal Efficiency Improves Customer Service

Filed under: General — Marcus Tettmar @ 8:29 am

Internal Efficiency Improves Customer Service

Internal Efficiency Improves Customer Service
"Initially the IT division was on a theoretical ‘25th floor’ and everyone was taking the stairs," says Garry Petzold, the chief IT officer at First State of Altus, Okla. "To better serve our customer base, while also meeting the needs of our bank’s technology infrastructure, I started researching solutions that would automate business processes and improve workflow. More…

May 7, 2008

Attaching to an existing Internet Explorer instance

Filed under: Automation, Scripting — Marcus Tettmar @ 9:57 am

There are various scripts on the forums demonstrating how to automate Internet Explorer via VBScript and IE’s Document Object Model. Such as this one: Automate web forms with IE

These require that the script creates the Internet Explorer instance via a CreateObject call. The script then has access to the IE object and can access its methods and properties in order to automate navigation, clicking on links, filling forms and extracting data from the page, etc.

A question that has come up a few times is “How do I connect to an already running copy of IE, one that the script didn’t start?”. This is what the GetObject function is designed for, but Internet Explorer doesn’t support it.

Well I recently discovered a solution. The following script has a subroutine called GetIE which will find a running copy of IE and set the global IE object variable to that copy. This can then be used in other functions to control that copy of IE:

VBSTART

Dim IE

'Attaches to an existing instance of IE with matching URL
Sub GetIE(URL)
  Dim objInstances, objIE
  Set objInstances = CreateObject("Shell.Application").windows
  If objInstances.Count > 0 Then '/// make sure we have instances open.
    For Each objIE In objInstances
	  If InStr(objIE.LocationURL,URL) > 0 then
	    Set IE = objIE
	  End if
    Next
  End if
End Sub

'fills a form field and optionally submits form
Sub WebFormFill(fieldname,fieldvalue,submit)
  Dim FormNr
  Dim ItemNr
  Dim TheForm

  if IE.Document.All.Tags("FORM").Length = 0 then
    MsgBox("No form found in page")
  else
    for FormNr = 0 to IE.Document.Forms.Length - 1
      Set TheForm = IE.Document.Forms(FormNr)
      for ItemNr = 0 to TheForm.Elements.Length - 1
        if TheForm.Elements(ItemNr).Name = fieldname then
          TheForm.Elements(ItemNr).Value = fieldvalue
          If submit=1 then
            TheForm.submit
          end if
          exit for
        end if
      next
    next
  end if
End Sub

'Navigates IE to specified URL
Sub Navigate(URL)
  IE.Navigate URL
  do while IE.Busy
  loop
End Sub

'clicks specified link
Sub ClickLink(linktext)
  Dim anchors
  Dim ItemNr

  Set anchors = IE.document.getElementsbyTagname("a")
  For ItemNr = 0 to anchors.length - 1
    If anchors.Item(ItemNr).innertext = linktext Then
	  anchors.Item(ItemNr).click
	End If
  next

  do while IE.Busy
  loop
End Sub

'This function extracts text from a specific tag by name and index
'e.g. TABLE,0 (1st Table element) or P,1 (2nd Paragraph element)
'set all to 1 to extract all HTML, 0 for only inside text without HTML
Function ExtractTag(TagName,Num,all)
  dim t
  set t = IE.document.getElementsbyTagname(Tagname)
  if all=1 then
    ExtractTag = t.Item(Num).outerHTML
  else
    ExtractTag = t.Item(Num).innerText
  end if
End Function

VBEND

//Find existing IE window
VBRun>GetIE,www.google.com

//enter search query and submit
VBRun>WebFormFill,q,windows macro,1

//Click a link
VBRun>ClickLink,Advanced Search

//extract
VBEval>ExtractTag("td",5,0),tagText
MessageModal>tagText

The implementation of GetIE shown here accepts a string. GetIE then looks for a copy of IE whose location URL contains that string. So it allows you to find a copy of IE based on the URL it is currently at.

This example attaches to a copy of IE currently open at www.google.com. So to run this example first open IE and go to www.google.com. Then run the script and it will enter a search term, click the Advanced Search link and then extract some text from a TD tag.

May 1, 2008

Great Marketing Vid

Filed under: General — Marcus Tettmar @ 10:41 am

I saw a link to this great video on a forum this morning. Great marketing. Not unique – remember the Honda advert? – but still very impressive and it is clearly working because I’m linking to it here:

http://www.clustarack.co.uk/

There’s also a great “behind the scenes” video here, explaining how they did it:

http://www.clustarack.co.uk/video.html

Just had to share. Enjoy.