Let’s say you use a piece of software which is horribly designed (or maybe you just don’t know how to use it properly) and you need to click a button thousands of times.

See specifics below if your are curious of my particular predicament!

Instead of clicking your mouse button like a crazy person - you can automate this task using software such as AutoHotKey. Using this software, it allows you to create a keyboard shortcut that lets you do a number of things without human intervention. This is handy for just about any sort of automated tasks where you find yourself clicking alot.

These instructions are for getting your mouse to click at a particular point on your screen a number of times.

Install AutoHotKey

First step of course is to install AutoHotKey.

Figure out where you need to click

Launch the included program AutoIt3 Window Spy. This will start reporting a bunch of information to you including Window Title and Class, Mouse Position, and other information that is useful if you are creating a more complicated AutoHotKey script.

Point the mouse to the Window where you want to click a bunch of times, at the place you wish to click. Make sure the window is active - this is important as we want to be specific as to where we click. Write down the coordinate for the “In Active Window”.

Create the Script

When you first run AutoHotKey (AHK from now on) it will ask you if you want to create a sample script in My Documents. Go ahead and do this.

At the bottom of this screen, add the following line:

!g::Click x,y,n

Where x = X coordinate, y = Y coordinate, and n = the number of times you want to click. For example in my use I used !g::Click 334,333,3000 which clicks in the active window at 334,333 exactly 3000 times.

!g means that the key combination will be Alt-G

Save this file and then Run AHK again. This will load it into memory.

Activate the window you wish to click in - then press Alt-G (at the same time)

Clicks away….

Your PC will click however many times in the active window at the specified location. Now your mouse will not wear down from the clicking and your time will also be saved!

Warning: Rant: This is why I needed to do this. The ever-fabulous Adobe Photoshop Elements does not have a great system to change your disk file structure. So when I wanted to change my photos directory from having lots of directories like 2006-01-23-10234323 into subdirectories like 2006/2006-01-23-10234323, it does not provide an easy way to do this. I wish it had advanced folder management like the MP3 Library Manager Media Monkey does - it allows you to rebuild your folders based on date, album, title, and just about every other piece of data imaginable. So when I did this manually and then wanted to “Reconnect” my photos to the correct location on the disk - Photoshop Elements has a horrible reconnect dialog that makes you click “Reconnect” on every picture you want to reconnect. I couldn’t find a way around this.

Developing web apps cross platform can be a pain sometimes, as the drivers used in Windows are typically not available (by default anyway) in linux. For example, if you are using perl based software in linux, and you need to connect to a Windows database (for example, MSDE 2000 or SQL Server)

There are two essential pieces of open source software you will need to use. The first one is UnixODBC [http://www.unixodbc.org]. This software provides the software to create an ODBC connection. Secondly, you will need the driver to connect to your Windows data source. This driver is provided by FreeTDS [http://www.freetds.org].

After installing this software according to their respective websites, if you are using perl you need to also install the module “DBD::ODBC”.

perl -MCPAN -e 'install DBD::ODBC'

You can now set up datasources in your configuration files. In my case, it would be located in /usr/local/etc/odbc.ini, but you can find the location of your driver file using the command
odbcinst -j
In addition to setting up your connection here, you can create a “DSN-less” connection using a connection string. Depending on how your system is set up, you may need to supply the connection password in your connection string anyway.

I’m not going to go over the coding of the database connection, for better instructions on how to use the UnixODBC software see their website:

The software I am using as a particular example is Lyris Technologies ListManager. You can synchronize your mailing lists with your database. Depending on your database software your needs will change, so you will need to talk to your software provider for specific information. The information I am providing below is for iMIS software from Advanced Solutions International (ASI).

For the connection string in ListManager, you will use the following syntax:
DRIVER=FreeTDS;SERVER=10.0.0.X;UID=dbusername;PWD=dbpassword;DATABASE=dbname;TDS_Version=8.0;Port=1433;

dbusername = database username, must have dbreader access to your database
dbpassword = password to match username
dbname = actual database name

Make sure your SERVER IP is correct, and the port for MSDE 2000 is 1433 by default. (As a gotcha, make sure any firewall installed allows connections between your servers and ports).

This allows your linux server to connect to your windows server running the database.

Additionally, you’ll need to provide the query string. I’ve found that Listmanager’s tolerance is not very good when dealing with SQL queries, for example it does not accept JOINs. You need to use an alternative method of joining tables. Refer to the Listmanager documentation to see what variables you can pull into their databases.

Below is the SQL statement for 2 different mailing lists.

Selecting a particular Committee or Section:
SELECT Name.EMAIL AS EmailAddr_, Name.FULL_NAME AS FullName_, Name.ID AS Additional_, 'H' AS MailFormat_
FROM Name, Activity, Product
WHERE Activity.ID = Name.ID AND Activity.PRODUCT_CODE = Product.PRODUCT_CODE AND Product.PRODUCT_MINOR ='TEC'

In this case, ‘TEC’ is the code used in iMIS for the committee. You use the WHERE clause to specify joins. I do not think this is the best way, but it works in this case.

To select all Active Members:
SELECT Name.EMAIL as EmailAddr_, Name.FULL_NAME as FullName_, Name.ID as Additional_, 'H' AS MailFormat_
FROM Name
WHERE ((Name.MEMBER_TYPE)='REG' Or (Name.MEMBER_TYPE)='AFF' Or (Name.MEMBER_TYPE)='HON' Or (Name.MEMBER_TYPE)='SEN') AND ((Name.STATUS)='A')

As you can see, it is not exactly simple but it is easy enough to do once you have the right software. Once your software is talking to your databases, it makes things a lot easier!

  • Welcome to systemBash, a technology and system administration blog by David Drager. If you enjoy this sort of content, can can subscribe to the RSS using the link to the right.