-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
1020 lines (933 loc) · 50.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="author" content="tidbit" />
<meta name="description" content="An AutoHotKey tutorial written by tidbit"/>
<meta name="keywords" content="ahk, autohotkey, tutorial, beginners guide"/>
<title>AutoHotkey Beginner Tutorial</title>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
</head>
<body>
<div class="page">
<div id="toc" class="section">
<h3 style="text-align: center;"><a href="#0">Table of Contents</a></h3>
<ol>
<li><a href="#s1" class="toci">The basics</a>
<ol>
<li><a href="#s11" class="toci">Downloading AutoHotkey</a></li>
<li><a href="#s12" class="toci">How to create a script</a></li>
<li><a href="#s13" class="toci">You cannot merge commands</a></li>
<li><a href="#s14" class="toci">Other basic info</a></li>
</ol>
</li>
<li><a href="#s2" class="toci">Hotkeys & Hotstrings</a>
<ol>
<li><a href="#s21" class="toci">Keys and symbols</a></li>
<li><a href="#s22" class="toci">Window specific</a></li>
<li><a href="#s23" class="toci">Multiple hotkeys per file</a></li>
<li><a href="#s24" class="toci">Examples</a></li>
</ol>
</li>
<li><a href="#s3" class="toci">Sending key strokes</a>
<ol>
<li><a href="#s31" class="toci">Games</a></li>
</ol>
</li>
<li><a href="#s4" class="toci">Running programs & website</a></li>
<li><a href="#s5" class="toci">Commands vs. Functions()</a>
<ol>
<li><a href="#s51" class="toci">Code blocks</a></li>
</ol>
</li>
<li>
<a href="#s6" class="toci">Variables</a>
<ol>
<li><a href="#s61" class="toci">When to use percents</a></li>
<li><a href="#s62" class="toci">Getting user input</a></li>
<li><a href="#s63" class="toci">Other Examples?</a></li>
</ol>
</li>
<li>
<a href="#s7" class="toci">Other helpful goodies</a>
<ol>
<li><a href="#s71" class="toci">The mysterious []'s</a></li>
<li><a href="#s72" class="toci">Finding your AHK version</a></li>
<li><a href="#s73" class="toci">Trial and Error</a></li>
<li><a href="#s74" class="toci">Indentation</a></li>
<li><a href="#s75" class="toci">Asking for Help</a></li>
<li><a href="#s76" class="toci">Other links</a></li>
</ol>
</li>
</ol>
</div>
<div id="bodyContent">
<div id="basics" class="section">
<h1>1 - <a id="s1" href="#s1">The Basics</a></h1>
<p class="Note">
Before we begin our journey, let me give some advice.
Throughout this tutorial you will see a lot of text and a
lot of code. For optimal learning power, it is advised
that you read the text and <b>try</b> the code. Then study
the code.
<br />You can copy and paste most examples on this page.
<br />If you get confused, try reading the section again.
</p>
<h2>a. <a id="s11" href="#s11">Downloading and installing AutoHotkey</a></h2>
<p>
Before learning to use AutoHotkey (AHK), you will need
to download it. After downloading it, you may possibly
need install it. But that depends on the version you want.
For this guide we will use the Installer since it is easiest to set up.
</p>
<h2>Text instructions:</h2>
<ol>
<li>Go to the AutoHotkey Homepage.
<a href="http://www.autohotkey.com/" class="url">http://www.autohotkey.com/</a>
</li>
<li>Click Download.
<a href="http://www.autohotkey.com/download/" class="url">http://www.autohotkey.com/download/</a>
</li>
<li>
During installation of AutoHotkey, you will be asked
to choose from UNICODE or ANSI. In short, you would
probably want to choose UNICODE. It has support for
non-English letters and numbers (characters). Keep
going until you see an Install button.
</li>
<li>Once done, great! Continue on to section b.</li>
</ol>
<p class="Note">Video instructions:<br />
Frankie's "Install and Hello World"<br />
<a href="http://www.autohotkey.com/forum/viewtopic.php?t=77674" class="url">http://www.autohotkey.com/forum/viewtopic.php?t=77674</a>
</p>
<h2>b. <a id="s12" href="#s12">How to create a script</a></h2>
<p>
Once you have AutoHotkey installed, you will probably want
it to do stuff. AutoHotkey is not magic, we all wish it
was, but it is not. So we will need to tell it what to do.
This process is called "Scripting".
</p>
<h2>Text instructions:</h2>
<ul>
<li>1. Right-Click on your desktop.</li>
<li>2. Find "New" in the menu.</li>
<li>3. Click "AutoHotkey Script" inside the "New" menu.</li>
<li>4. Give the script a new name. Note: It must end with a .ahk extension. Ex. MyScript.ahk</li>
<li>5. Find the newly created file on your desktop and Right-Click it.</li>
<li>6. Click "Edit Script".</li>
<li>7. A window should have popped up, probably Notepad. If so, SUCCESS!
<hr />
<p>
So now that you have created a script, we need to add
stuff into the file. For a list of all built-in
commands, function and variables,
see <a href="#s5" class="url">section 5</a>.<br />
</p>
<p>
Here is a very basic script containing a Hotkey which types text using the <a href="http://www.autohotkey.com/docs/commands/Send.htm" class="url">Send</a> command when the hotkey is pressed.
</p>
<pre class="MultiCode">
^j::
Send, My First Script
Return
</pre>
<p>
We will get more in-depth later on. Until then, here's an
explanation of the above code.<br />
- The first line. <span class="InlineCode">^j::</span> is
the Hotkey. <span class="InlineCode">^</span> means
<span class="key">CTRL</span>,
<span class="InlineCode">j</span> is the letter
<span class="key">j</span>. anything to the <b>left</b> of
<span class="InlineCode">::</span> are the keys you need to press.<br />
- The second line. <span class="InlineCode">Send, My First Script</span> is how you SEND keystrokes. <span class="InlineCode">SEND</span> is the command, anything after the comma (,) will be typed.<br />
- The third line. <span class="InlineCode">Return</span>. Return 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.
</p>
<hr />
<li>8. Save the File.</li>
<li>9. Double-Click the file/icon in the desktop to run it. Open notepad or (anything you can type in) and press <span class="key">Ctrl</span> and <span class="key">J</span>.</li>
<li>10. Hip Hip Hooray! Your first script is done. Go get some reward snacks then return to reading the rest of this tutorial.</li>
</ul>
<p class="Note">
Video instructions:<br />
Frankie's "Install and Hello World"<br /><a href="http://www.autohotkey.com/forum/viewtopic.php?t=77674" class="url">http://www.autohotkey.com/forum/viewtopic.php?t=77674</a>
</p>
<h2>c. <a id="s13" href="#s13">You cannot merge commands</a></h2>
<p>
When you are making your code, you might have the urge to
put several commands on the same line or inside of each
other, don't. <a href="#s5">In section 5</a> we'll talk about why it
doesn't work as you might expect and what you can do
instead.
</p>
<h2>d. Other basic <a id="s14" href="#s14">info</a></h2>
<div>
How to find the Help File on your computer:<br />
There are a few ways to do this, I'll assume you have it installed to the default locations.<br /><br />
Method 1:
<ol>
<li>Find the Start menu or Start Orb on your screen, usually in the lower left.</li>
<li>Click <b>Programs</b> or <b>All Programs</b>.</li>
<li>Find <b>AutoHotkey</b> in the list.</li>
<li>You should then see <b>AutoHotkey Help File</b>. Click it.</li>
<li>Done!</li>
</ol>
Method 2:
<ol>
<li>Go to your desktop.</li>
<li>Find <b>My Computer</b> or <b>Computer</b>. Open it.</li>
<li>Go into your harddrive that contains <b>AutoHotkey</b>. Probably <b>C:\</b> drive.</li>
<li>Search within all <b>Program Files</b> folders for <b>AutoHotkey</b>.</li>
<li>Look for <b>AutoHotkey.chm</b> or a file that says AutoHotkey and has a yellow question mark on it.</li>
<li>Done!</li>
</ol>
<p class="Note">
Online Links:<br />
<a href="http://www.autohotkey.com/docs/" class="url">Documentation</a><br />
<a href="http://www.autohotkey.com/docs/commands.htm" class="url">Command List</a><br />
<a href="http://www.autohotkey.com/docs/Functions.htm#BuiltIn" class="url">Functions</a><br />
<a href="http://www.autohotkey.com/docs/Variables.htm" class="url">Variables</a></p>
</div>
</div>
<div id="hotkeys_and_hotstrings" class="section">
<h1>2 - <a id="s2" href="#s2">Hotkeys & Hotstrings</a></h1>
<p>
What is a Hotkey? A hotkey is a key that is hot to the touch. ... Just kidding. It is a key or key combination that the person at the keyboard presses to trigger some actions.<br />
What is a Hotstring? Hotstrings are mainly used to expand abbreviations as you type them (auto-replace), they can also be used to launch any scripted action.
</p>
<p>Here is a hotkey:</p>
<pre class="MultiCode">
^j::
Send, My First Script
Return
</pre>
<p>Here is a hotstring:</p>
<pre class="MultiCode">
::ftw::Free the whales
</pre>
<p>The difference between the two examples is that the hotkey will be triggered when you press <span class="key">CTRL & J</span> while the hotstring will convert your typed "ftw" into "Free the whales".</p>
<p>
<i>"So, how exactly does a person such as myself create a hotkey?"</i>
Good question. A hotkey is created by using a single pair of ::'s. The key or key combo needs to go on the <b>left</b> of the <span class="InlineCode">::</span>. And the content needs to go below, followed by a <span class="InlineCode">Return</span>.<br />
</p>
<p class="Note">Note: There are exceptions, but those tend to cause confusion a lot of the time. So it won't be covered in the tutorial, at least, not right now.</p>
<pre class="MultiCode">
esc::
MsgBox Escape!!!!
Return
</pre>
<p>A hotstring has a pair of ::'s on each side of the text you want to trigger the text replacement. While the text to replace your typed text goes on the <b>right</b> of the second pair of ::'s.</p>
<p>Hotstring, as mentioned above, can also launch scripted actions. Thats fancy talk for <i>"do pretty much anything"</i>. Same with hotkeys.</p>
<pre class="MultiCode">
::btw::
MsgBox You typed "btw".
Return
</pre>
<p>
A nice thing to know is that you can have many lines of
code for each hotkey, hotstring, label, and a lot of other
things we haven't talked about yet.
</p>
<pre class="MultiCode">
^j::
MsgBox Wow!
MsgBox this is
Run, Notepad.exe
winactivate, Untitled - Notepad
WinWaitActive, Untitled - Notepad
send, 7 lines{!}{enter}
sendinput, inside the ctrl{+}j hotkey
Return
</pre>
<h2>a. <a id="s21" href="#s21">Keys and their mysterious symbols</a></h2>
<div>
You might be wondering <i>"How the crud am I supposed to know that ^ means CTRL?!"</i>. Well, good question. To help you learn what ^ and other symbols mean, gaze upon this chart:<br />
<table border="1" style="font-size: 12px; color: rgb(0, 0, 0); font-family: Verdana, Arial, Helvetica, sans-serif, 'MS sans serif'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
<tbody>
<tr style="font-size: 12px; ">
<td style="font-size: 12px; ">
<strong>Symbol</strong>
</td>
<td style="font-size: 12px; ">
<strong>Description</strong>
</td>
</tr>
<tr style="font-size: 12px; ">
<td style="font-size: 12px; ">
<strong>#</strong>
</td>
<td style="font-size: 12px; ">
Win (Windows logo key). In v1.0.48.01+, for Windows Vista
and later, hotkeys that include the Windows key (e.g. #a)
will wait for the Windows key to be released before
sending any text containing an "L" keystroke. This
prevents the <em>Send</em> within such a hotkey
from locking the PC. This behavior applies to all
sending modes except
<a href="http://www.autohotkey.com/docs/commands/Send.htm#SendPlayDetail" style="text-decoration: none; color: rgb(170, 0, 170); ">SendPlay</a>
(which doesn't need it) and
<a href="http://www.autohotkey.com/docs/commands/Send.htm#blind" style="text-decoration: none; color: rgb(170, 0, 170); ">blind mode</a>.
</td>
</tr>
<tr style="font-size: 12px; ">
<td style="font-size: 12px; ">
<strong>!</strong>
</td>
<td style="font-size: 12px; ">Alt</td>
</tr>
<tr style="font-size: 12px; ">
<td style="font-size: 12px; ">
<strong>^</strong>
</td>
<td style="font-size: 12px; ">Control</td>
</tr>
<tr style="font-size: 12px; ">
<td style="font-size: 12px; ">
<strong>+</strong>
</td>
<td style="font-size: 12px; ">Shift</td>
</tr>
<tr style="font-size: 12px; ">
<td style="font-size: 12px; ">
<strong>&</strong>
</td>
<td style="font-size: 12px; ">
An ampersand may be used between any two keys or mouse
buttons to combine them into a custom hotkey.
See <a href="http://www.autohotkey.com/docs/Hotkeys.htm#combo" style="text-decoration: none; color: rgb(170, 0, 170); ">below</a>
for details. Such hotkeys are ignored (not activated) on Windows 95/98/Me.
</td>
</tr>
</tbody>
</table>
<p style="margin-top: 0.7em; margin-bottom: 0.7em; color: rgb(0, 0, 0); font-family: Verdana, Arial, Helvetica, sans-serif, 'MS sans serif'; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); ">
<strong>
(See the
<a href="http://www.autohotkey.com/docs/KeyList.htm" style="text-decoration: none; color: rgb(170, 0, 170); ">Key List</a>
for a complete list of keyboard keys and mouse/joystick
buttons)<br />
(For the full list of symbols, see the
<a href="http://www.autohotkey.com/docs/Hotkeys.htm" class="url">Hotkey</a> page)
</strong>
</p>
</div>
<p>
Additionally, here is a list of all/most hotkey names that can be used on the <b>left</b> side of a hotkeys :: symbol:<br /><a href="http://www.autohotkey.com/docs/KeyList.htm" class="url">http://www.autohotkey.com/docs/KeyList.htm</a>
</p>
<p>
You can define a custom combination of two (and only two)
keys (except joystick buttons) by using <b>&</b> between
them. In the below example, you would hold down
<span class="key">Numpad0</span> then press the second
key to trigger the hotkey:
</p>
<pre class="MultiCode">
Numpad0 & Numpad1::
MsgBox You pressed Numpad1 while holding down Numpad0.
Return
Numpad0 & Numpad2::
Run Notepad
Return
</pre>
<p>
But you are now wondering if hotstrings have any cool modifiers since hotkeys do. Yes, they do!<br />
Hotstrings modifiers go between the first set of ::'s. Such as:
</p>
<pre class="MultiCode">
:*:ftw::Free the whales
</pre>
<p class="Note">
For additional hotkey and hotstring modifiers, information and examples, visit:<br />
<a href="http://www.autohotkey.com/docs/Hotkeys.htm" class="url">Hotkeys</a><br />
<a href="http://www.autohotkey.com/docs/Hotstrings.htm" class="url">Hotstrings</a>
</p>
<h2>b. <a id="s22" href="#s22">Window specific hotkeys/hotstrings</a></h2>
<p>Sometime you might want a hotkey or hotstring to only work (or be disabled) in a certain window. To do this, you will need to use either of these fancy commands with a # in-front of them.</p>
<p>#IfWinActive<br />
#IfWinExist</p>
<p>
These special commands (technically called "directives") create context-sensitive hotkeys and hotstrings. Simply specify a windows title. But in some cased you might want to specify an HWND, group, or class. Those are a bit advanced and are covered more in-depth here: <a href="http://www.autohotkey.com/docs/commands/_IfWinActive.htm" class="url">#IfWinActive</a>.
</p>
<pre class="MultiCode">
#IfWinActive Untitled - Notepad
#space::
MsgBox You pressed Win+Spacebar in Notepad.
Return
</pre>
<p>The #IfWin commands are positional: they affect all hotkeys and hotstrings physically beneath them in the script.</p>
<pre class="MultiCode">
; Notepad
#IfWinActive ahk_class Notepad
#space::
MsgBox, You pressed Win+Spacebar in Notepad.
Return
::msg::You typed msg in Notepad
#IfWinActive
; MSPaint
#IfWinActive untitled - Paint
#space::
MsgBox, You pressed Win+Spacebar in MSPaint!
Return
::msg::You typed msg in MSPaint!
#IfWinActive
</pre>
<p>To turn off context sensitivity, specify any #IfWin command but leave all of its parameters blank. For example:</p>
<pre class="MultiCode">
; Notepad
#IfWinActive untitled - Notepad
!q::
MsgBox, You pressed Alt and Q in Notepad.
#IfWinActive
; Any window that isn't Untitled - Notepad
!q::
MsgBox, You pressed Alt and Q in any window.
Return
</pre>
<p>When #IfWin commands are turned off (or never used in a
script), all hotkeys and hotstrings are enabled for all windows.</p>
<p class="Note">For more in-depth information and similar
commands, check out:<br />
<a href="http://www.autohotkey.com/docs/commands/_IfWinActive.htm" class="url">#IfWinActive</a></p>
<h2>c. <a id="s23" href="#s23">Multiple hotkeys/hotstrings per file</a></h2>
<p>This, for some reason crosses some peoples minds. So
I'll set it clear: AutoHotkey has the ability to
have <i>as many</i> hotkeys and hotstrings in 1
file as you want. Whether it's 1, or 3253 (or more).</p>
<pre class="MultiCode">
#i::
run, http://www.google.com/
Return
^p::
run, notepad.exe
Return
~j::
send, ack
Return
::acheiv::achiev
::achievment::achievement
::acquaintence::acquaintance
:*:adquir::acquir
::aquisition::acquisition
::agravat::aggravat
:*:allign::align
::ameria::America
</pre>
<p>The above code is perfectly acceptable. Multiple hotkeys, multple hotstrings. All in one big happy script file.</p>
<h2>d. <a id="s24" href="#s24">Examples</a></h2>
<pre class="MultiCode">::btw::By the way ; Replaces "btw" with "By the way" as soon as you press an <a href="http://www.autohotkey.com/docs/commands/_Hotstring.htm" class="url">EndChar</a>.
:*:btw::By the way ; Replaces "btw" with "By the way" without needing an EndChar
^n:: ; Ctrl & n Hotkey
run, notepad.exe ; Run the program notepad.exe when you press Ctrl & n
Return ; This ends the hotkey. The code below this will not get triggered.
^b:: ; Ctrl & b Hotkey
send, {ctrl down}c{ctrl up} ; Copies the selected text. ^c could be used aswell, but this method is more secure.
SendInput, [b]{ctrl down}v{ctrl up}[/b] ; Wraps the selected text in bbcode (forum) Bold tags.
Return ; This ends the hotkey. The code below this point will not get triggered.
</pre>
<!-- PAGE 2 -->
<!-- PAGE 2 -->
<!-- PAGE 2 -->
</div>
<div id="sending_keystrokes" class="section">
<h1>3 - <a id="s3" href="#s3">Sending key strokes</a></h1>
<p>
So now you decided that you want to send (type) keys to a
program. We can do that. Use the <a href="http://www.autohotkey.com/docs/commands/Send.htm" class="url">Send</a> command. Send literally sends keystrokes, to simulate typing or pressing of keys.<br /><br />
Before we get into things, here are some common issues
that people have:<br />
Just like Hotkeys, Send has special keys too. <a href="http://www.autohotkey.com/docs/commands/Send.htm" class="url">Lots and lots of them.</a><br />
Here are the 4 most common symbols:
</p>
<div>
<hr />
<p style="margin-top: 0.7em; margin-bottom: 0.7em; color: rgb(0, 0, 0); font-family: Verdana, Arial, Helvetica, sans-serif, 'MS sans serif'; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); "><span class="red" style="color: rgb(255, 0, 0); font-weight: bold; ">!</span>: Sends the ALT key. For example, <em>Send This is text!a</em> would send the keys "This is text" and then press ALT+a. <strong>Note</strong>: !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.</p><p style="margin-top: 0.7em; margin-bottom: 0.7em; color: rgb(0, 0, 0); font-family: Verdana, Arial, Helvetica, sans-serif, 'MS sans serif'; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); "><span class="red" style="color: rgb(255, 0, 0); font-weight: bold; ">+</span>: Sends the SHIFT key. For example, <em>Send +abC </em>would send the text "AbC", and <em>Send !+a</em> would press ALT+SHIFT+a.</p><p style="margin-top: 0.7em; margin-bottom: 0.7em; color: rgb(0, 0, 0); font-family: Verdana, Arial, Helvetica, sans-serif, 'MS sans serif'; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); "><span class="red" style="color: rgb(255, 0, 0); font-weight: bold; ">^</span>: Sends the CONTROL (Ctrl) key. For example, <em>Send ^!a</em> would press CTRL+ALT+a, and <em>Send ^{Home}</em> would send CONTROL+HOME. <strong>Note</strong>: ^A produces a different effect in some programs than ^a. This is because ^A presses CONTROL+SHIFT+A and ^a presses CONTROL+a. If in doubt, use lowercase.</p><p style="margin-top: 0.7em; margin-bottom: 0.7em; color: rgb(0, 0, 0); font-family: Verdana, Arial, Helvetica, sans-serif, 'MS sans serif'; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); "><span class="red" style="color: rgb(255, 0, 0); font-weight: bold; ">#</span>: Sends the WIN key (the key with the Windows logo) therefore <em>Send #e</em> would hold down the Windows key and then press the letter "e".</p>
</div>
<p><i><strong>The next couple of paragraphs are talking about the <a href="http://www.autohotkey.com/docs/commands/Send.htm" class="url">table on send page</a>.</strong><br /></i></p>
<p class="Note">
Note:<br />This table <b>does not</b> apply to <a href="http://www.autohotkey.com/docs/Hotkeys.htm" class="url">hotkeys</a>. Meaning, you do not wrap <span class="key">CTRL</span> or <span class="key">ENTER</span> (or any other key) inside {}'s when making a hotkey.
</p><br />
<div>
An example showing what shouldn't be done to a hotkey:
<pre class="MultiCode">
; When making a hotkey...
; WRONG
{LCtrl}::
send, AutoHotkey
Return
; CORRECT
LCtrl::
send, AutoHotkey
Return
</pre>
</div>
<hr />
<div>
<p>The gigantic table above shows pretty much every special key built-in to AHK. Such as: <span class="InlineCode">{enter}</span> and <span class="InlineCode">{space}</span>.<br />
A common issue lots of people have is they assume that the curly brackets are put in the documentation pages just for fun. But in fact <b>they are needed</b>. It's how AHK knows that <span class="InlineCode">{!}</span> means "exclamation point" and not "press the <span class="key">Alt</span> key". So please remember to check the table on the <a href="http://www.autohotkey.com/docs/commands/Send.htm" class="url">send</a> page and make sure you have your brackets in the right places.</p>
<pre class="MultiCode">
; Notice the ! is in {}'s? Thats because if it wasn't, AHK would
; press the ALT key.
send, This text has been typed{!}
</pre>
<pre class="MultiCode">
; Same as above, but with the ENTER key. AHK would type out "enter" if ...
; ... it wasn't wrapped in {}'s.
send, Multiple enter lines have enter been sent. ; WRONG
send, Multiple{enter}lines have{enter}been sent. ; CORRECT
</pre>
<div>
Another common issue is that people think that <b>everything</b> needs
to be wrapped in brackets with the send command. That is FALSE. If
it's not in the chart, it does not need brackets. You do <b>not</b>
need to wrap common letters, numbers or even some symbols (such as .
(period)) in {}'s.<br />
Also, with the Send commands you are able to send more then 1 letter,
number or symbol at a time. So no need for a bunch of Send commands
with 1 letter each.
<pre class="MultiCode">
; Don't wrap words or indivisual letters that are not in the table mentioned above.
send, {a} ; WRONG
send, {b} ; WRONG
send, {c} ; WRONG
send, {a}{b}{c} ; WRONG
send, {abc} ; WRONG
send, abc ; CORRECT
</pre>
</div>
<div>
To hold down or release a key, enclose the key name in brackets and then use the word UP or DOWN.
<pre class="MultiCode">
; This is how you hold 1 key down and press another key (or keys).
; If 1 method doesn't work in your program, please try the other.
send, ^s ; Both of these send CTRL+s
send, {ctrl down}s{ctrl up} ; Both of these send CTRL+s
Send, {ctrl down}c{ctrl up}
Send, {b down}{b up}
Send, {TAB down}{TAB up}
Send, {Up down} ; Press down the up-arrow key.
Sleep, 1000 ; Keep it down for one second.
Send, {Up up} ; Release the up-arrow key.
</pre>
</div>
</div>
<div>
But now you are wondering
<i>"How can I make my really long send commands readable?"</i>.
Easy. Use what is known as a Continuation Section. Simply specify an
opening parenthesis on a new line, then your content, finally a closing
parenthesis on its own line. For more information, read about
<a href="http://www.autohotkey.com/docs/Scripts.htm#continuation" class="url">Continuation Sections</a>.
<pre class="MultiCode">
send,
(
Line 1
Line 2
Apples are a fruit.
)
</pre>
</div>
<p class="Note">
Note: There are several different forms of send. Each has their own special features. If one form of send does not work for your needs, try another type of send. Simply replace the commands name "send" with "sendPlay" or whatever you want.<br />
Here are most ways to send text:<br />
Send<br />
SendRaw<br />
SendInput<br />
SendPlay<br />
SendEvent<br />
For more information on what each one does, <a href="http://www.autohotkey.com/docs/commands/Send.htm" class="url">read this</a>.
</p>
<h2>a. <a id="s31" href="#s31">Games</a> </h2>
<p>
<b><span style="color:red;">This is important!</span></b><br />
A lot of games, especially modern ones, have cheat prevention software.
Things like GameGuard, Hackshield, PunkBuster and several others.
If a game has a cheat prevention system and your hotkeys,
hotstrings and send commands do not work, you are out of luck.<br />
Not only is bypassing these systems in violation of the games policies
and will get you banned, they are complex to work around.
There are methods that can increase the chance of working in some games, but there is no
magical <i>"make it work in my game now!!!"</i> button. so try <b>ALL</b>
of these before giving up.<br />
</p>
<p>
There are also known issues with DirectX. If you are having issues
and you know the game uses DirectX, try the stuff above. You should
also try running the game in Windowed Mode, if possible. That fixes
some DirectX issues.<br />
More DirextX issues may occur when using pixel or image commands.
Colors might turn out black (0x000000) no matter the color you try
to get. That is another tricky thing to fix. Try running in Windowed Mode if you can.
</p>
<p>
There is no single solution to make AutoHotkey work in all programs.
If everything you try fails, it may not be possible to use AutoHotkey for your needs.
</p>
<div>
<hr />
From the <a href="http://www.autohotkey.com/docs/FAQ.htm#games" class="url">FAQ</a> page:<br />
Some games use DirectInput exclusively. As a side-effect, they might ignore all simulated keystrokes and mouse clicks. To work around this, try one of the following (or a combination):
<ul>
<li>Use <a href="http://www.autohotkey.com/docs/commands/Send.htm#SendPlayDetail" class="url">SendPlay</a> via: 1) the SendPlay command; 2) using <a href="http://www.autohotkey.com/docs/commands/SendMode.htm" class="url">SendMode</a> Play; and/or 3) the <a href="http://www.autohotkey.com/docs/Hotstrings.htm#SendMode" class="url">hotstring</a> option SP.</li>
<li>Increase <a href="http://www.autohotkey.com/docs/commands/SetKeyDelay.htm" class="url">SetKeyDelay</a>. For example:</li>
<li><span class="InlineCode">SetKeyDelay, 0, 50</span></li>
<li><span class="InlineCode">SetKeyDelay, 0, 50, Play</span></li>
<li>Try <a href="http://www.autohotkey.com/docs/commands/ControlSend.htm" class="url">ControlSend</a>, which might work in cases where the other Send modes fail.</li>
</ul>
</div>
<!-- PAGE 3 -->
<!-- PAGE 3 -->
<!-- PAGE 3 -->
</div>
<div id="running_programs_and_websites" class="section">
<h1>4 - <a id="s4" href="#s4">Running programs & websites</a></h1>
<div>
To run a program such as <i>Mspaint.exe, Calc.exe, script.ahk</i> or even a folder, you can use the <a href="http://www.autohotkey.com/docs/commands/Run.htm" class="url">Run</a> command. It can even be used to open URLs such as <a href="http://www.autohotkey.com/" class="url">http://www.autohotkey.com/</a> . If your computer is setup to run the type of program you want to run, it's very simple:
<pre class="MultiCode">
; Run a program. Note: most programs will require a FULL file path.
Run, %A_ProgramFiles%\Some_Program\Program.exe
; Run a website
Run, http://www.autohotkey.com
</pre>
</div>
<div>
There are some other advanced features aswell, such as Command-Line parameters and CLSID.<br />
If you want to learn more about that stuff, visit the <a href="http://www.autohotkey.com/docs/commands/Run.htm" class="url">run page</a>.
<br />
Here are a few more samples:
<pre class="MultiCode">
; Several programs do not need a full path, such as Windows-standard programs.
Run, Notepad.exe
Run, MsPaint.exe
; Run the "My Documents" folder using the built-in <a href="http://www.autohotkey.com/docs/Variables.htm#BuiltIn" class="url">AHK variable</a>
Run, %A_MyDocuments%
; Run some websites
Run, http://www.autohotkey.com
Run, http://www.google.com
</pre>
<br />
<p class="Note">For more in-depth information and examples, check out:<br /><a href="http://www.autohotkey.com/docs/commands/Run.htm" class="url">http://www.autohotkey.com/docs/commands/Run.htm</a>.</p>
</div>
<!-- PAGE 4 -->
<!-- PAGE 4 -->
<!-- PAGE 4 -->
</div>
<div id="commands_vs_functions" class="section">
<h1>5 - <a id="s5" href="#s5">Commands</a> vs. Functions()</h1>
<div>
AutoHotkey has two main types of things used by the scripter to create code:<br />
Commands and Functions()<br />
<p class="Note">Helpful links:<br />
A list of all commands: <a href="http://www.autohotkey.com/docs/commands.htm" class="url">commands.htm</a><br />
A list of all built-in functions: <a href="http://www.autohotkey.com/docs/Functions.htm#BuiltIn" class="url">Functions.htm#BuiltIn</a></p>
</div>
<h2>Commands</h2>
<p>
You can tell what a command is by looking at its syntax (the way it looks). Commands do not use parenthesis "()" around the parameters like functions do. So a command would look like this:<br />
<span class="InlineCode">Command, parameter1, parameter2, parameter3</span><br />
<br />When using commands, you cannot squish other commands onto the same line as a previous command (exception: <a href="http://www.autohotkey.com/docs/commands/IfEqual.htm" class="url">ifEqual</a>).<br />
You cannot put commands inside the parameters of other commands.
</p>
<pre class="MultiCode">
Msgbox, Hello Run, Notepad.exe ; Wrong
Msgbox, Hello, Run, Notepad.exe ; Wrong
Msgbox, Hello ; Correct
Run, Notepad.exe
</pre>
Commands also differ from function in that they use "traditional syntax". Meaning: when you use a <span class="InlineCode">variable</span>, you NEED to use %'s around it. <span class="InlineCode">%variable%</span>. Any text and numbers do not need to be in "quotation marks". <span class="InlineCode">This is some text</span>. Additionally, you cannot do math in the parameters, unlike functions().
<p class="Note">
You can do math in parameters if you force an expression with a single <span class="InlineCode">%</span>, but that will not be covered.
</p>
<h2>Functions</h2>
<div>
As stated above, functions are different because they use parenthesis. A typical function looks like:<br />
<span class="InlineCode">Function(parameter1, parameter2, parameter3)</span><br /><br />
Functions have a few main differences:
<ol>
<li>
You can do math in them.<br />
-- <span class="InlineCode">SubStr(37*12, 1, 2)</span><br />
-- <span class="InlineCode">SubStr(A_Hour-12, 2)</span>
</li>
<li>
Variables do not need to be wrapped in percent signs.<br />
-- <span class="InlineCode">SubStr(A_Now, 7, 2)</span>
</li>
<li>
Functions can go inside of functions.<br />
-- <span class="InlineCode">SubStr(A_AHKPath, inStr(A_AHKPath, "AutoHotkey"))</span>
</li>
<li>
Text needs to be wrapped in quotes.<br />
-- <span class="InlineCode">SubStr("I'm scripting, awesome!", 16)</span>
</li>
</ol>
Functions usually return a value differently than a command does. Commands need an <i>OutputVariable</i> parameter, functions do not. The most common way to assign a variable to the value of a function is like so:<br />
<span class="InlineCode"><span style="color:#ff4400"><b>MyVariable</b></span>:=Function(Parameters)</span>
<pre class="MultiCode">
<span style="color:#ff4400"><b>MyVariable</b></span>:=SubStr("I'm scripting, awesome!", 16)
</pre>
<p class="Note">This isn't the only way, but it's the most common. You are assigning <span class="InlineCode">MyVariable</span> to the value of the function (in this case, <span class="InlineCode">SubStr(...)</span>) that is to the right of the :=.<br />
<a href="http://www.autohotkey.com/docs/Functions.htm" class="url">More about Functions</a></p>
</div>
<div>
In short:
<pre class="MultiCode">
; These are commands
Msgbox, This is some text.
StringReplace, Output, Input, AutoHotKey, AutoHotkey, ALL
SendIput, This is awesome{!}{!}{!}
; These are Functions
SubStr("I'm scripting, awesome!", 16)
FileExist(VariableContainingPath)
Output:=SubStr("I'm scripting, awesome!", 16)
</pre>
</div>
<h2>a. <a id="s51" href="#s51">Code blocks</a></h2>
<p>
<a href="http://www.autohotkey.com/docs/commands/Block.htm" class="url">Code blocks</a> are little curly brackets (<b>{</b> and <b>}</b>) that are there to 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 <i>If</i> and <i>Loop</i>s. Without them, only the first line in the block is called.<br /><br />
</p>
<div>
In the following code, both lines are ran only if var equals 5.
<pre class="MultiCode">
if (var=5)
{
MsgBox, var equals %var%!!
Exitapp
}
</pre><br />
In the following code, the msgbox is only ran if var equals 5. The code will always exit, even if var=5.
<pre class="MultiCode">
if (var=5)
MsgBox, var equals %var%!!
Exitapp
</pre><br />
This is perfectly fine since the if only had 1 line of code associated with it. It's exactly the same as above, but I outdented the second line so we know it's separate from the if.
<pre class="MultiCode">
if (var=5)
MsgBox, var equals %var%!!
MsgBox, We are now 'outside' the if. We did not need {}'s since there was only 1 line below it.
</pre>
</div>
<!-- PAGE 5 -->
<!-- PAGE 5 -->
<!-- PAGE 5 -->
</div>
<div id="variables" class="section">
<h1>6 - <a id="s6" href="#s6">Variables</a></h1>
<p>
<a href="http://www.autohotkey.com/docs/Variables.htm" class="url">Variables</a> are like little post-it notes that hold some information. They can be used to store text, numbers, data from functions and commands or even mathematical equations. Without them, programming & scripting would be much more tedius.
</p>
<hr />
<div>
Variables can be assigned a few ways, We'll cover the most common forms. Please pay attention to the equal sign (=).
<ol>
<li class="hover">variable=text<br />
<div class="indented">This is the simplest form for a variable, traditional assignment. Simply type in your text and done.</div>
</li>
<li class="hover">variable=%variable2%<br />
<div class="indented">Same as above, but you are assigning a variable to a different variables value.</div>
</li>
<li class="hover">variable:="text"<br />
<div class="indented">This is an expression assignment, due to the : before the =. Any text needs to be in "quotes".</div>
</li>
<li class="hover">variable:=variable2<br />
<div class="indented">In expression mode, variables do not need %'s.</div>
</li>
<li class="hover">variable:=6+8/3*2-sqrt(9)<br />
<div class="indented">Thanks to expressions, you can do math!</div>
</li>
</ol>
Number 1 & 2 can be combined. <span class="InlineCode">var=%var2% some text %var3%.</span><br />
3, 4 & 5 can be combined too. <span class="InlineCode">var:="The value of 5+ " Variable " is: " 5+Variable</span>
</div>
<hr />
<p class="Note">
Any equal sign (<b>=</b>) with a symbol infront of it is called an <b>Assignment Operator</b>, which are always an expression. So <span class="InlineCode">:=</span> <span class="InlineCode">+=</span> <span class="InlineCode">-=</span> <span class="InlineCode">.=</span> etc. always use expressions.
</p>
<h2>a. <a id="s61" href="#s61">When to use percents</a></h2>
<p>
One of the most common issues with AutoHotkey involving variables is when to use the percent signs (<b>%</b>). Hopefully this will clear some confusion.
</p>
<div>
When to use %'s:
<ol>
<li>When you are using Commands (see above) you use percent signs.<br />
-- Except when the parameter is OutputVar or InputVar.</li>
<li>When you are assigning a variable to a value using a traditional mode (an equal sign with no symbol infront of it).</li>
</ol>
When <b>not</b> to use %'s:
<ol>
<li>In parameters that are input or output variables, For example: <span class="InlineCode">StringLen, <span style="color:red">OutputVar</span>, <span style="color:red">InputVar</span></span></li>
<li>On the left side of an assignment: <span class="InlineCode"><span style="color:red">Var</span> = 123abc</span></li>
<li>On the left side of traditional (non-expression) if-statements: <span class="InlineCode">If <span style="color:red">Var1</span> < %Var2%</span></li>
<li>Everywhere in expressions. For example:
<pre class="MultiCode">
If (<span style="color:red">Var1</span> != <span style="color:red">Var2</span>)
<span style="color:red">Var1</span> := <span style="color:red">Var2</span> + 100
</pre>
</li>
</ol>
</div>
<h2>b. <a id="s62" href="#s62">Getting user input</a></h2>
<div>
Sometimes you want to have the user to choose the value of stuff. There are several ways of doing this, but the simplest way is <a href="http://www.autohotkey.com/docs/commands/InputBox.htm" class="url">Inputbox</a>. Here is a simple example on how to ask the user a couple of questions and doing some stuff with what was entered.
<pre class="MultiCode">
InputBox, OutputVar, Question 1, What is your first name?
if (OutputVar="Bill")
MsgBox, That's is an awesome name, %OutputVar%.
InputBox, OutputVar2, Question 2, Do you like AutoHotkey?
if (OutputVar2="yes")
MsgBox, Thank you for answering %OutputVar2%`, %OutputVar%! We will become great friends.
else
MsgBox, %OutputVar%`, That makes me sad.
</pre>
</div>
<h2>c. <a id="s63" href="#s63">other examples?</a></h2>
<div>
<pre class="MultiCode">
<a href="http://www.autohotkey.com/docs/commands/MsgBox.htm" class="url">MsgBox</a>, 4, , Would you like to continue?
<a href="http://www.autohotkey.com/docs/commands/IfMsgBox.htm" class="url">IfMsgBox</a>, No
Return ; If No, stop the code from going further.
MsgBox You pressed YES. ; Otherwise, the user picked yes.
</pre>
<pre class="MultiCode">
; Some examples showing when to use percents and when not
Variable=text ; Assign a variable some text using 'traditional' assignment.
VariableNumber:=6 ; Assign a variable a number using 'expressional' assignment.
Variable2=%Variable% ; Assign a variable to another variable using traditional assignment.
Variable3:=Variable ; Assign a variable to another variable using expressional assignment.
Variable4.=Variable ; Append a variable to the end of another variable using expressional assignment.
Variable5+=VariableNumber ; Add the value of a variable to another variable using expressional assignment.
Variable5-=VariableNumber ; Subtract the value of a variable from another variable using expressional assignment.
Variable6:=SubStr(Variable, 2, 2) ; Variable inside a function. This is always an expression.
MsgBox, %Variable% ; Variable inside a command.
StringSplit, Variable, Variable, x ; Variable inside a command that uses InputVar and OutputVar.
if (VariableNumber=6) ; Whenever an IF has parenthesis, it'll be an expression. So no %'s.
If (Variable != VariableNumber) ; Whenever an IF has parenthesis, it'll be an expression. So no %'s.
if VariableNumber=6 ; Without parenthesis, the if is Traditional. However, only variables on the 'right side' need %'s.
If Var1 < %Var2% ; Without parenthesis, the if is Traditional. However, only variables on the 'right side' need %'s.
</pre>
</div>
<!-- PAGE 6 -->
<!-- PAGE 6 -->
<!-- PAGE 6 -->
</div>
<div id="helpful_goodies" class="section">
<h1>7 - <a id="s7" href="#s7">Other</a> helpful goodies</h1>
<p>
We have reached the end of our journey, my good friend. I hope you have learned something.
But before we go, here are some other things that I think you should know. Enjoy!
</p>
<h2>a. <a id="s71" href="#s71">The mysterious []'s</a></h2>
<div>
Throughout the documentation, you will see these two symbols (<b>[</b> and <b>]</b>) surrounding code in the yellow syntax box at the top of almost all pages. Anything inside of these brackets are <b><i>OPTIONAL</i></b>. Meaning the stuff inside can be left out if you don't need them. When writing your code, it is very important to <b>NOT</b> type the []'s in your code.<br /><br />
On the <a href="http://www.autohotkey.com/docs/commands/ControlGetText.htm" class="url">ControlGetText</a> page you will see this (without the colors):<br />
<span class="InlineCode">ControlGetText, OutputVar <span style="color:red"><b>[</b></span><span style="color:navy">, Control, WinTitle, WinText, ExcludeTitle, ExcludeText</span><span style="color:red"><b>]</b></span></span><br /><br />
So you could simply do this if you wanted:<br />
<span class="InlineCode">ControlGetText, OutputVar</span><br /><br />
Or add in some more details:<br />
<span class="InlineCode">ControlGetText, OutputVar, Control, WinTitle</span><br /><br />
What if you wanted to use ExludeTitle but not fill in WinText or WinTitle? Simple!<br />
<span class="InlineCode">ControlGetText, OutputVar, Control,,, ExcludeTitle</span><br /><br />
<p class="Note">
Please note that you cannot IGNORE parameters, you can however leave them blank.<br />
If you were to Ignore "WinTitle, WinText", it would look like this and cause issues:<br />
<span class="InlineCode">ControlGetText, OutputVar, Control, ExcludeTitle</span><br />
This is valid.<br />
<span class="InlineCode">ControlGetText, OutputVar, Control,,, ExcludeTitle</span>
</p>
</div>
<h2>b. <a id="s72" href="#s72">Finding your AHK version</a></h2>
<div>
Run this code to see your AHK version:
<pre class="MultiCode">
MsgBox, %A_AHKVersion%
</pre>
Or look for "AutoHotkey Help File" or "AutoHotkey.chm" in the start menu or your installation directory.
</div>
<h2>c. <a id="s73" href="#s73">Trial and Error</a></h2>
<p>
Trial and Error is a very common and effective way of learning. Instead of asking for help on every little thing, sometimes spending some time alone (sometimes hours or days) and trying to get something to work will help you learn faster.
</p>
<p>
If you try something and it gives you an error, study that error. Then try and fix your code. Then try running it again. If you still get an error, modify your code some more. Keep trying and failing until your code fails no more. You will learn a lot this way by reading the documentation, reading errors and learning what works and what doesn't.
<span class="InlineCode">Try, fail, try, fail, try, try, try, fail, fail, <b>succeed!</b></span>
</p>
<p>
This is how a lot of "pros" have learned. But don't be affraid to ask for help, we don't bite (hard).
Learning takes time, the "pros" you encounter did not learn to be masters in just a few hours or days.
</p>
<p class="Note">"If at first you don't succeed, try, try, try again." - Hickson, William E.</p>
<h2>d. <a id="s74" href="#s74">Indentation</a></h2>
<div>
This stuff (indentation) is very important! Your code will run perfectly fine without it, but it will be a major headache for you and other to read your code. Small code (25 lines or less) will probably be fine to read without indentation, but it'll soon get sloppy. It's best you learn to indent ASAP.<br />
Indentation has no set style, but it's best to keep everything consistent.<br />
"<b>What is indentation?</b>" you ask? It's simply spacing to break up your code so you can see what belongs to what. People usually use 3 or 4 spaces or 1 tab per "level".<br /><br />
No indents:
<pre class="MultiCode">
if (car="old")
{
msgbox, the car is really old
if (wheels="flat")
{
msgbox, this car is not safe to drive.
Return
}
else
{
msgbox, Be careful! This old car will be dangerous to drive.
}
}
else
{
msgbox, My`, what a shiny new vehicle you have there.
}
</pre>
Indented:
<pre class="MultiCode">
if (car="old")
{
msgbox, the car is really old
if (wheels="flat")
{
msgbox, this car is not safe to drive.
Return
}
else
{
msgbox, Be careful! This old car will be dangerous to drive.
}
}
else
{
msgbox, My`, what a shiny new vehicle you have there.
}
</pre>
Wiki has various styles and examples. Choose what you like or learn to indent how you think it's easiest to read.<br />
<a href="http://en.wikipedia.org/wiki/Indent_style" class="url">http://en.wikipedia.org/wiki/Indent_style</a>
</div>
<h2>e. <a id="s75" href="#s75">Asking for Help</a></h2>
Before you ask, try doing some research yourself or try to code it yourself. If that did not yield results that satisfy you, read below.
<ul>
<li>Don't be afraid to ask for help, even the smartest people ask others for help.</li>
<li>Don't be afraid to show what you tried, even if you think it's silly.</li>
<li>Post anything you have tried.</li>