Empty file generator.

Portable Freeware is an excellent site for downloading programs that will run portably from a USB thumb drive. If you download from that site as often as I do, no doubt you’ve seen instructions to create an empty file in the application’s folder so the application can save its settings to that file. This is often a tedious process as the only way I know of to do this is to drop to a command prompt and changing to the program’s folder so I can create the empty file using COPY CON. I decided to create an AutoIt script that makes this task much easier.

#FileZero.au3

$dir = FileSelectFolder(“Browse for folder.”, “”)
$fil=StringTrimLeft ($dir,3)
$file=inputbox (“FileZero”, “Enter filename or leave blank for ” & $fil & “.ini”)
if $file=”” Then
$file=$fil & “.ini”
endif
$writem = FileOpen($dir & “\” & $file, 2)
FileWrite($writem, “”)
FileClose($writem)
MsgBox(4096, “FileZero”, “Wrote ” & $file)

Here’s an AutoHotkey version of this same script.

#filezero.ahk

FileSelectFolder, dir, , 3
StringTrimLeft fil, dir, 3
InputBox file, FileZero, Enter filename or leave blank for %fil%.ini
if file =
file = %fil%.ini
FileAppend ,, %dir%\%file%
MsgBox Wrote %file%

When you run this script, you’ll start by browsing the folder tree to the folder where you want to create the empty file. By default, the empty file will have the name of the folder along with an INI extension.
For example, if you downloaded TinyTask, the mouse and keyboard macro recorder, you most likely saved that file to a folder called TinyTask. By default, the script will create an empty file called TinyTask.ini, which is what the program needs to save its settings portably.
In making this script, I had µTorrent in mind, which requires an empty file called settings.dat for it to run portably. I set up the script so you can specify the exact name of the empty file to create, or you can just leave the input window blank to have it create the INI file with the folder’s name as the file name. From there the script will create the empty file, ready for your portable application for computing on the go.
This script works best with simple folder structures, such as C:\TINYTASK, so it should work as planned with your thumb drive’s equally simple folder structure. The script went haywire when I tried navigating to one of the folders under “C:\Program Files”. It reported that it wrote the INI file but I could never find it. I’m not concerned with fixing that problem as there’s really no need to create empty files under Program Files.

A cover letter generator script.

One of the more time-consuming aspects of applying for a job online is the constant tweaking of your cover letter so it matches the job you’re applying for. I’ve come up with an AutoIt script to automate this tedious task. I call this script typer.au3.

$a=inputBox (“Typer”, “Job applied for:”)
Msgbox (48, “Typer”,”You have 3 seconds…”,3)
Send (“ATTENTION:  Personnel Manager{ENTER}{ENTER}”)
Send (“Good day.  My name is [Your Name].  I am an experienced [Desired Position].  Please accept the enclosed resume for consideration for the ” & $a & ” Position with your company.  Please contact me at [Home Phone]  or by e-mail at [E-mail Address] at your earliest convenience to set up an interview.  Thank you for your consideration.{ENTER}{ENTER}”)
Send (“Best Regards,{ENTER}{ENTER}”)
Send (“[Your Name]{ENTER}”)
Send (“[Desired Position] Professional”)

Before running this script, replace the red text above with information specific to you and the job you’re looking for.
When you run this script, you will be asked for the job title you’re applying for, such as “Support Technician” or “Bathroom Attendant”.
The script now has all the information it needs to type your cover letter for you. All you have to do is to click the text box on the web page where you want your cover letter to be type, and you have 3 seconds to do it before it starts typing. You can change the delay value to a larger number if you so desire.

The vault game from Tunnels of Doom.

One of my all-time favorite games is Tunnels of Doom, the classic fantasy game for the Texas Instruments TI99/4A computer. The object is to rescue the king and his rainbow orb of power from the monsters who have kidnapped him and locked him in one of the two vaults.
When you reach a vault, you have to guess its combination, which is a 3-digit number consisting of individual digits between 1 and 3. As you enter your guess, the game tells you how many digits in your guess are correct and whether the combination is higher or lower than your guess. With some thinking you can easily deduce the combination. I decided to make an AutoIt script to replicate this unique number guessing game. It works pretty well, too.

$cor=0$g=0

$a=random (1,3,1)$b=random (1,3,1)$c=random (1,3,1)$d=$a & $b & $c

while $g  $d

$g=inputbox ("Vault", "Last guess: " & $g & @CRLF & @CRLF & "Combination?")

if $g="giveup" ThenMsgbox (48, "Vault", "The combination was " & $d) Exitendif

$guess=StringSplit ($g,"",1)

if $guess[1]>3 or $guess[2]>3 or $guess[3]>3 ThenMsgBox (16, "Vault", "Number should be between 1 and 3")endif

if $g>$d then$resp="lower"Else$resp="higher"endif 

if $guess[1]=$a Then$cor=$cor+1endif 

if $guess[2]=$b Then$cor=$cor+1endif 

if $guess[3]=$c Then$cor=$cor+1endif 

if $cor<3 then msgbox (64, "Vault",  "Your guess: " & $g & @CRLF & @CRLF & _$cor & " digits right" & @CRLF & "Combination is " & $resp) endif  $cor=0 wend  Msgbox (48, "Vault", "You got the combination!")

The hard part was figuring how to split your guess into 3 individual digits. The SpringSplit function achieves this nicely.
Unlike the Tunnels of Doom version, you won’t get mortally wounded if you enter too many guesses. I’ve also worked in a “giveup” command you can enter if you do in fact give up trying to guess the combination. Other than that, this script faithfully reproduces the vault game in Tunnels of Doom. Enjoy!

Robotape.

Tomorrow I’m leaving on a well-deserved vacation. While I’m gone someone will cover for me and handle my job duties, one of which involves changing the backup tapes on the servers and erasing them. I decided to make this job easier for my co-workers by writing an AutoIt script that actually moves the moves the mouse itself and clicks the options to automate this tedious procedure.
If you’re running Symantec Backup Exec for Windows Servers 12.5 and have your desktop resolution set at 1280 x 1024, this script should work for you as well.

sleep (2000)
winactivate (“Symantec Backup Exec”)

; clear the alert windows
mousemove (879, 296,100)
for $g = 1 to 10
Mouseclick (“left”)
sleep (2000)
next

; move the mouse to Devices
Mousemove (571, 95,100)
MouseClick (“left”)

; scroll to top of devices
mousemove (181, 115,100)
Mousedown (“left”)
sleep (10000)
Mouseup (“left”)

; Inventory the Tape
sleep (1000)
Mousemove (54, 362,100)
MouseClick (“Left”)
Mousemove (818, 748,100)
MouseClick (“Left”)
Mousemove (639, 532,100)
MouseClick (“Left”)
Sleep (5000)

;Wait for Erase options to be active
$checksum = PixelChecksum(20, 378, 140, 424)
While $checksum = PixelChecksum(20, 378, 140, 424)
Sleep(100)
WEnd

;Erase the Tape
Mousemove (70, 411,100)
MouseClick (“Left”)
Mousemove (642, 563,100)
MouseClick (“Left”)
Mousemove (642, 549,100)
MouseClick (“Left”)
Mousemove (818, 749,100)
MouseClick (“Left”)
Mousemove (637, 532,100)
MouseClick (“Left”)
Mousemove (326, 95,100)
MouseClick (“Left”)

When this script is run, it starts by clearing all the alert windows generated during the backup. These alert windows display the status of the backup and any errors that were encountered. It clicks OK to close these windows 10 times, in case one server has more windows to clear.
Then the script moves the mouse to the Devices menu and scrolls to the top of its menu in case it’s not at the top already. Next it clicks the Inventory menu item and clicks OK on the windows that open to confirm you are about to run the Inventory on the tape in the drive.
Here the script will pause until the options to erase the tape are active. It will then move the mouse to click the option to do a full erase, click OK on the windows that open to submit the erase job and finish by clicking on the Job Monitor so you can verify that the erase tape operation is running.
This script has been tested and it works fine on all three of our servers. I hope it serves you well.

A simple keygen script.

Over the years I’ve purchased numerous shareware programs over the Internet. After making my payment I would get an e-mail containing a registration code needed to unlock the full version of the software I just purchased. I got a bit curious how this process works so I did a little experiment in AutoIt to try making my own serial key generator. Be advised this script does not generate any real serial codes, so if you came here looking for something to unlock your software without paying for it, please look elsewhere. I do not condone this kind of software piracy. Having said that, here’s my keygen script, albeit a simple one.

dim $x, $a
$n=inputbox (“Keygen”, “Enter your name.”)
$l=stringlen($n)
Local $a = StringToASCIIArray($n)

for $g=0 to $l-1
$x=$a[$g] + $x
next

msgbox (4096, “Keygen”, “Your code is ” & $x)

All this script does is take the letters of your name, converts them to their ASCII code counterparts and adds the numbers up to generate the final code. I am certain other shareware programs use a far more sophisticated means of calculation.
Then I decided to create a script that acts as a fake shareware program that asks for your name and registration code before running the same calculation on your name to determine whether you entered the right code. If you entered the right code, you’re in, otherwise you… will be out, as in auf’d. In other words, you will be asked to pack your knives and go.
Here’s the fake shareware script.

dim $x, $a
$n=inputbox (“Registration”, “Please enter your name.”)
$l=stringlen($n)
$c=inputbox (“Registration”, “Please enter your registration code.”)
Local $a = StringToASCIIArray($n)

for $g=0 to $l-1
$x=$a[$g] + $x
next

if $x=$c Then
msgbox (48, “Registration”, “Code accepted! Thank you for registering.”)
Else
msgbox (16, “Registration”, “Sorry, your code was not accepted.”)
endif

Now I have a slightly better idea how shareware programs get unlocked through these magic codes.

A script to make you smile.

This is an AutoIt script I made that counted down the days left in George W. Bush’s term as President. It started as an experiment with some of AutoIt’s commands but soon turned into something that really starts your day on a positive note.

#include
$days = _DateDiff( ‘d’,_NowCalc(),”2009/01/20″)
if $days < 0 Then
MsgBox (4096, “Bush Term Countdown”, “George W. Bush is no longer President.”)
else
MsgBox (4096, “Bush Term Countdown”, $days & ” days left in President Bush’s term”)
endif

A screen capture script.

I got a little frustrated over the lack of a decent screen capture tool that captures a section of the screen directly to a file without any further complications, including those of licensing and leaving remnants behind on the host computer. So I made a screen capture tool of my own using AutoIt. Here’s the source code.

#include
MsgBox (64, “Gotcha”, “Move the mouse to the lower right hand corner of the block.”)
for $g=3 to 1 step -1
Msgbox (0, “Gotcha”, $g,1)
next
$pos = MouseGetPos()
_ScreenCapture_Capture(@MyDocumentsDir & “test.jpg”, 0, 0, $pos[0], $pos[1])
MsgBox (48, “Gotcha”, “Done.”)

When you run this script, you have 3 seconds to move your mouse to the lower right hand corner of the region of the screen you want captured. The upper left hand corner is already preset to coordinates 0,0. At the end of the countdown, the script captures the selected region and saves it to a JPG in your Documents folder.
I know the countdown sequence is a little awkward but AutoIt doesn’t have anything for dragging the mouse to define the region of the screen to be captured, so this is the next best thing. And it works.

A script that reads your mind.

I’ve been so haunted by the Fido mind reading trick that I’ve decided to make my own version in AutoIt. Here’s what I have so far.

dim $d
MsgBox (16, “Mindreader”, “Think of a 3 or 4 digit number.”)
MsgBox (16, “Mindreader”, “Now scramble the digits in that number to form a new number.”)
MsgBox (16, “Mindreader”, “Subtract the two numbers.”)
MsgBox (16, “Mindreader”, “From the resulting number, remove one digit and memorize it.”)
$a=inputbox (“Mindreader”, “Scramble the remaining digits of the number and enter them here.”)
$b=stringlen($a)
$c=stringsplit ($a,””)
for $g=1 to $c[0]
$d=$d+$c[$g]
Next
$e=$d-9
$f=9-$e
MsgBox (16, “Mindreader”, “The missing number was ” & $f)

Much like the Fido puzzle, the script has you think of any 3 or 4 digit number. You then scramble the digits to come up with a second number. After subtracting the two numbers, you remove one digit from the result and enter the remaining digits into the script’s input window. The script then uses some simple math to calculate the missing digit, thus achieving the desired magic effect.
Unlike Fido, however, this script doesn’t quite get it every time but does seem to work on most numbers you can think of. I have a feeling the math programming is going to be a little more complicated than what you see here. The script is still a work in progress but does have a little magic contained within to amaze the mathematically ignorant.

Password paster script.

This is a simple and relatively secure password paster script I made using AutoIt.

$p=InputBox (“Compost”, “Welcome to Compost!”)
if $p=”google” Then
ClipPut (“GOOGLE PASSWORD”)
MsgBox (16, “Compost”, “Out of memory in line 4”)
ClipPut (“”)
elseif $p=”twitter” Then
ClipPut (“TWITTER PASSWORD”)
MsgBox (16, “Compost”, “Syntax error in line 8”)
ClipPut (“”)
elseif $p=”delicious” Then
ClipPut (“DELICIOUS PASSWORD”)
MsgBox (16, “Compost”, “Invalid data in line 12”)
ClipPut (“”)
endif

The script works by displaying a welcome window that asks for some input. In this instance you have a choice of typing “google”, “twitter” or “delicious”. The script then looks up the corresponding password and copies it to memory so you can paste it instantly. It also displays a fake error message that serves as a distraction. As long as you don’t close the fake error window, the password remains in memory and can be pasted as often as needed, but when you do close the window, the password is removed from memory as the script clears the clipboard. That provides some decent level of security as long as you don’t tell of the clever secret hidden within the script.

E-mail via telnet.

Here’s a simple AutoIt script that allows you to check your e-mail via telnet. Before running it, change the first three lines of the script so it has your username, password and your e-mail server’s POP3 address (i.e., pop3.netzero.net)

$user=”you@server.com”
$pass=”your password”
$server=”your server”
run (“telnet ” & $server & ” 110″)
sleep (2000)
send (“user ” & $user & chr(13))
sleep (1000)
send (“pass ” & $pass & chr(13))
sleep (1000)
send (“list ” & chr(13))

When you run the script, it uses the Windows telnet client to log on to your e-mail server on port 110. If you have any new messages waiting, you’ll see a list that looks like this:

In the above example there are three new messages. The sizes of the messages are also shown.
To read the first one, type RETR 1 and the first e-mail will be displayed. To delete it, type DELE 1 and then RETR 2 to retrieve the next e-mail. Finally, type QUIT to exit the telnet session.
The commands you used to retrieve your e-mail via telnet are the same ones your e-mail client uses when it downloads your e-mail. Now you can appreciate all the hard work it does.