skip to content

 Web design 

Database-driven systems

Easy-to-maintain web sites


 



PC Programming

My primary focus is web programming using PHP but occasionally, I need to write a program to run under Windows. I've been using different versions of Basic for years so for me it's second nature to use Basic when I need to write a program for the desktop. There are some really great versions of Basic so don't let the language name fool you. I recommend AutoIt for any situation that requires some automation using a PC program.

Autoit
This language has a lot of facilities for automation. Among other things, it is very good for screen scraping and form filling.

  • It has functions that use Internet Explorer to access Internet pages, scrape content, fill fields, click buttons to navigate to other pages and so forth. It can do virtually anything that a human can do navigating the internet. It has another UDF (User Developed Function) that uses FireFox but it isn't quite as developed as the one for IE.
  • It can start and control other Windows programs.
  • It can read create and update Excel and Word documents.
  • It has many other built-in and User Developed Functions that cover a wide range of functions. It also has the ability to access native Windows functions.
  • It has the full range of capabilities to build sophisticated Windows programs.
  • The language is pretty uncomplicated and easy to learn and use.
  • The syntax is quite similar to PHP so it is pretty easy for a PHP programmer to get used to. 
  • It can produce a (32 or 64 bit) compiled program that doesn't require a runtime module to be installed and doesn't require any registry entries. Since the runtime is basically built into the compiled module, the executeable can be a bit large (300k+).
  • It's free!


Autoit complements PHP well because it can handle the Windows desktop work that can't be done with PHP. Even though they work in different environments, they can communicate. An Autoit program can open an Internet Explorer window, navigate to a specific (PHP) program, provide it wih data and receive data from it. Thus, it is possible for an Autoit program to act as the client for a (PHP) program running on a server. The interface isn't an API or Jason or anything fancy. In fact, the server program probably won't have an API defined. Autoit is able to extract the infomation from the screen output produced by the server-based program.

It is also worth noting that the server program could be written in ASP or Python or any other language. The screen output (and input) provides the interface. The language used doesn't make any difference. This is especially useful when dealing with ASP applications. In my experience, server-based screen-scraping can't cope with ASP applications and their embedded Javascript. I have successfully navigated through an ASP application and extracted information from it using Autoit. I tried a number of other approaches to do this but I was usuccessful.

Autoit can even act as a facilitator to connect two online applications. I did this in one case where I had to move a file from one server to another. I used Autoit to log in to the first application and navigate to a page where I was able to download a file. Instead of downloading to the PC, I passed the file name and location to the application on my server and it read the file directly from the other server.

So, what does an Autoit application look like? Starting with the simplest example, here is the classic "Hello World": 

 

1
   msgbox (0,"Sample","Hello World")

 How do we open a browser window and navigate to a particular page?

 

1
2
3
4
5
6
7
8
9
#include <IE.au3>
 
$root_url = "http://google.com"
 
 _IEErrorNotify ()
$oIE = _IECreate()
_IENavigate($oIE, $root_url)
 
 

 You can download Autoit at: 

http://www.autoitscript.com/site/autoit/

 
   

Powered by Website Baker,
Design by Innovations Design based on a template by gavjof