AutoHotkey

From NoskeWiki
Jump to navigation Jump to search

About

Autohotkey is AWESOME!

Autohotkey (AHK) is a free, open source macro and automation software which allows users to automate repetitive tasks and modify the Windows user interface - allowing you to:


  • Automate almost anything by sending keystrokes and mouse clicks.
  • Create hotkeys for keyboard, joystick, and mouse.
  • Remap keys
    • NOTE: One application of this is it lets you expand abbreviations as you type them - EG: typing "btw" can automatically produce "by the way".
  • Read screen pixels, run loops, and wait for window events
    • NOTE: This means you can write scripts to help you in computer games (which is called 'botting')!
  • Create custom user interfaces (menu bars, buttons, text boxes etc).


It comes with its own:

  • Macro's recorder (so you don't have to write it all)
  • Script editor (although mostly you will use notepad)
  • GUI builder

I use autohotkey whenever I have something repeatitive to get done. I highly recommend having a play with it! The language is not hard to learn.


Code Snippets

Autoclicker

I modified this from here... after you start it you must press [Ctr]+[Alt]+[Z]... then once the clicks have started use [CapsLock] to pause and start the clicks - when paused the icon should be red.

msgbox, Press [Ctr]+[Alt]+[Z] to begin, `n`nPress [CapsLock] to start/pause

!^z::
Gui, Add, Text, section, Number of clicks:
Gui, Add, Text, , Interval (ms):
Gui, Add, Text, , Button ("left" or "right"):
Gui, Add, Text, , Delay (s):
Gui, Add, Edit, vClicks ys w100, 10000
Gui, Add, Edit, vInterval w100, 1000
Gui, Add, Edit, vMouseButton w80, left
Gui, Add, Edit, vDelay w80, 5
Gui, Add, Button, default, Ok	
Gui, Show,, AutoClicker
return

GuiClose:
ExitApp

ButtonOk:
Gui, Submit
if(Delay>0)
{
  DelayMS := Delay * 1000
  msgbox, %Clicks% %MouseButton% clicks will start in %Delay% seconds`n`nUse [CapsLock] to start/pause
  sleep %DelayMS%
}

loop, %Clicks%
{
  MouseClick, %MouseButton%
  sleep, %Interval%
}

CapsLock::
pause


Similar Programs...

A VERY similar program is AutoIt. This is made by *mostly* the same people, is also free, and has almost identical function. The main difference are:

  • It uses a Visual Basic-like language... making it slightly more powerful, but almost means more code.
  • Has a nicer text editor (with syntax highlighting) & comes with good examples, but doesn't have an script recorder OR a gui builder.

I use mostly AHK, but mostly because I started AHK, and like that it has an auto recorder feature. Fortunately there are tools to convert between the different scripting languages.


Links