^j::
is the hotkey. ^
means Ctrl, j
is the letter J. Anything to the left of ::
are the keys you need to press.Send, My First Script
is how you send keystrokes. Send
is the command, anything after the comma (,) will be typed.return
. This will become your best friend. It literally stops code from going any further, to the lines below. This will prevent many issues when you start having a lot of stuff in your scripts.::
. And the content needs to go below, followed by a return
.Symbol | Description |
---|---|
# | Win (Windows logo key) |
! | Alt |
^ | Control |
+ | Shift |
& | An ampersand may be used between any two keys or mouse buttons to combine them into a custom hotkey. |
&
between them. In the example below, you would hold down Numpad0 then press Numpad1 or Numpad2 to trigger one of the hotkeys:Symbol | Description |
---|---|
! | Sends the Alt key. For example, Send, This is text!a would send the keys 'This is text' and then press Alt+A. Note: !A produces a different effect in some programs than !a . This is because !A presses Alt+Shift+A and !a presses Alt+A. If in doubt, use lowercase. |
+ | Sends the Shift key. For example, Send, +abC would send the text 'AbC', and Send, !+a would press Alt+Shift+A. |
^ | Sends the Control (Ctrl) key. For example, Send, ^!a would press Ctrl+Alt+A, and Send, ^{Home} would send Ctrl+Home. Note: ^A produces a different effect in some programs than ^a . This is because ^A presses Ctrl+Shift+A and ^a presses Ctrl+A. If in doubt, use lowercase. |
# | Sends the Win key (the key with the Windows logo) therefore Send #e would hold down the Win key and then press the letter 'e'. |
{Enter}
and {Space}
.{!}
means 'exclamation point' and not 'press the Alt key'. So please remember to check the table on the Send page and make sure you have your brackets in the right places. For example:.
(period) in curly brackets. Also, with the Send commands you are able to send more than one letter, number or symbol at a time. So no need for a bunch of Send commands with one letter each. For example:%Var%
, and that any text and numbers do not need to be in quotation marks, such as This is some text
. Additionally, you cannot do math in the parameters, unlike functions.%
, but that will not be covered.MyVar
to store the return value of the function that is to the right of the :=
operator. See Functions for more details.{
and }
). They group a section of code together so that AutoHotkey knows it's one big family and that it needs to stay together. They are most often used with functions and control flow statements such as If and Loop. Without them, only the first line in the block is called.=
).:
before the =
. Any text needs to be in quotes.:=
+=
-=
.=
etc. are called assignment operators and always require an expression.StringLen, OutputVar, InputVar
Var = 123abc
if Var1 < %Var2%
'one'
is stored in object key 1
(aka index 1), and the value 17
is stored in object key 4
(aka index 4).'Yellow'
is stored in the object key 'Color'
. Also, the value 3
is stored in the object key 'Price'
.:=
.'Color'
, which is (unsurprisingly) the key Color
. You will get a message box with the word 'Yellow', because that is what we set the key Color
to in the previous section.'
, also known as an empty string. This doesn't remove the key, but it will make the value appear identical to an unset value. It is possible to tell that the key still exists by using the HasKey method, and it will still come up in a For loop.MyObject[AnyKey]
will be stored in RemovedValue.[
and ]
) surrounding code in the yellow syntax box at the top of almost all pages. Anything inside of these brackets are OPTIONAL. Meaning the stuff inside can be left out if you don't need them. When writing your code, it is very important to NOT type the square brackets in your code.WinTitle, WinText
, it would look like this and cause issues: