Pages

Saturday, February 27, 2010

The Ultimate Computer Utility

Learning to program even a little is the ultimate computer utility.  I've been reminded of that many times recently. Just a few days ago a it occurred to me the right way to finally right the clipboard enhancing tool I've been dreaming of for years.  I'm calling it "DeepClip" I plan over the weekend to post it here with complete source code and hopefully a full line by line walk through of how it works.

Some friends of mine at work have been asking for me to come up with some more AutoIt tutorials. I think "DeepClip" will end up being the first of them.

But for now I thought I would post a super simple little 10 line snippet that was for a game I was playing last week where clicking quickly was needed.

The statement numbers aren't part of the code
1. Sleep(2000) 
2. HotKeySet("{esc}", "_exit")

3. While 1
        MouseClick("Left")
    WEnd

4. Func _exit()
         Exit
    EndFunc

1. First I needed a way to run this script then get to the window with the game in it before it started clicking madly.

2. HotKeySet() is a built in function in AutoIt function that registers a hotkey with windows and binds that to a function. The list of hotkeys is in the AutoIt help file.

3. A basic loop type called while, when a while loop starts it checks the argument to the right of the "while". As long as that statment returns "True" meaning a non-zero number it continues. While 1 is a way to loop forever. While looping forever we want to click the left mouse button. Then WEnd ends the while statement.

4. Here we setup the exit function we bound to the escape key since we wont be able to click our way out of this script we need a way to get out easily.
    Anyhow there you go this is the sort of thing AutoIt does in just a few lines very well that other languages would have to mill around a bit longer to accomplish.

    You can download AutoIt from their download page located here. Its a great starter language and (despite what others may say) a great language for medium to large windows utilities.

    No comments:

    Post a Comment