Autohotkey Getting Started Tutorial (1) HelloWorld and hotkeys

I. Introduction

Complete Guide to the Internet Autohotkey is too small, many newcomers have to learn in front of the help documentation. But help is just a document classified many commands, steep jumps, beginner or need to learn step by step. To do this, prepare yourself to write part tutorial, initiate, hoping to help you programming enthusiasts.
About software installation, basic operation of the editor options, such as the code runs omitted here, directly into the programming topic.

Second, hello world

code show as below

Msgbox, HelloWorld

Results are as follows
Here Insert Picture Description
effect MsgBox command here is a specified text in a small window.

Third, shortcuts and hot string

As Autohotkey literal meaning, it is a very powerful hotkey automation software, which uses some key or some other trigger string instruction.

1, hotkey (shortcut key)

^j::
   Send, My First Script
Return

^ Refers to the Ctrl key; ^ J means to press Ctrl + j keys; :: used to separate hotkey triggered; Send command here is the second row function triggered Ctrl + j; Send command to send key sequence, where the transmission line of text "My First Script"; Return code block represent the hotkey end, if only one line of code can be omitted.
Press Ctrl + j on the blank Notepad, the results shown below
Here Insert Picture Description
with similar ^ represents the Ctrl, many special keys on the keyboard are represented by special symbols used in the table below hotkey modifiers, particularly the documentation can be found, but note these keys must be in combination with other keys (without using a combination of &) to indicate by their special symbol. The following example, the hotkey Ctrl but not ^.

^::
   Send, My First Script
Return
symbol Explanation
# Widows key
! Alt key
^ Ctrl key
+ Shift key
< The pair left the keys in, such as <! Alt key to the left of the keyboard
> A pair of keys on the left that, as>! Is the right Alt key keyboard

When using a single special keys, special modifiers in the following table

symbol Explanation
LWin Widows left key
Ruins The right Windows key
Control (or Ctrl) Ctrl key
LControl (or LCtrl) The left Ctrl key
RControl (or RCtrl) The right Ctrl key
Alt Alt key
sistently Left Alt key
raltar The right Alt key
Shift Shift key
RShift The right Shift key
LShift Left Shift key
Space space bar
Tab Tab key
Enter(或Return) enter
Escape(或Esc) Esc
The Backspace (or BS) Backspace
F1 Function keys, function keys other similar
Numpad0 0 keypad, numeric keypad similar to other

& Hotkey combination is connected through two key definition, the following examples, and press the keypad 1 0 triggering.

Numpad0 & Numpad1::
	MsgBox You pressed Numpad1 while holding down Numpad0.
Return

2, heat string
that is a character string used for other functions, the following examples

::ftw::Free the whales

Thermal :: string requires two strings ftw sandwich. Ftw When you enter on the keyboard, and then pressing the terminal symbol, it will be converted into ftw Free the whales. Terminator may enter, space, Tab like.
If the input does not want to directly trigger button terminator effect, the following syntax may be used

:*:ftw::Free the whales

3, Send command
here briefly Send command. Send button command is mainly used to send a particular program.
And hotkeys similar, Send command also has some special keys, but be careful not to confuse, similar to most of the special keys and hot keys, just need to wrap braces. Section below

symbol Explanation
# Widows key
! Alt key
^ Ctrl key
+ Shift key

The Send! A is transmitted Alt + a, Send! + A is transmitted Alt + Shift + a. If you need to send! Braces are needed, such as Send {!} A to transmit! A. Note that, in addition to the special keys on the table can also be employed in the form of braces, such as {Alt}, {Shift}, {Ctrl} and the like.
Want means to hold down or release a key, this key can be enclosed in braces, but with the word UP or DOWN.

Send, ^s                     ; 都表示发送 CTRL+s 键击
Send, {ctrl down}s{ctrl up}  ; 都表示发送 CTRL+s 键击
Send, {ctrl down}c{ctrl up}
Send, {b down}{b up}
Send, {Tab down}{Tab up}
Send, {Up down}  ; 按下向上键
Sleep, 1000      ; 保持1秒
Send, {Up up}    ; 然后松开向上键

AltTab and ShiftAltTab are two special commands that only the hotkey to be identified in the same row.

LAlt & j::AltTab
LAlt & k::ShiftAltTab

4, Run command to
the command execution program or open a Web site. The following example

Run, https://autohotkey.com
Run, C:\Some_Program\Program.exe

Some programs do not need the full path, such as the Windows standard procedure

Run, notepad.exe
Run, msPaint.exe

5. Notes
Finally, a brief mention Autohotkey comment function. NOTE There are two ways to
(1) use a semicolon to comment script

Run Notepad  ;这是和命令在同一行的注释

(2) with / * and * / comment block of code symbol

/*
MsgBox, 这行被注释掉了
MsgBox, 这行也被注释掉了 
*/

6, a few examples

::/mail::[email protected]

Input / mail and press Enter automatically converted to "[email protected]"

::/gs::
clipboard = 煎蛋娱乐有限公司 ; clipboard指剪切板,将汉字赋给剪切板
Send ^v
return

Input / gs and press Enter automatically converted to "omelette Entertainment Co., Ltd."

::/dd::
d = %A_YYYY%-%A_MM%-%A_DD% ;获得系统时间比如今天的时间:2018-12-21
clipboard = %d%
Send ^v
return

Input / dd and press Enter are automatically converted to today's date, such as "2018-12-21"

Guess you like

Origin blog.csdn.net/falomsc/article/details/85109238