AutoHotKey Tutorial
Sniper Elite Auto Hot Key Tutorial. By
Noballs(NZ) &
Kiwimage(NZ) Update to script 4/9/2009* The macro will now only run when Sniper Elite is maximised. E.g. If you are running sniper and minimise the game to type in keys associated with a hotkey in an internet browser or chat program etc, nothing will happen. i.e. script is automatically paused.
* Script can now close programs used with Sniper Elite, e.g. spotter and Fraps. For example when you run the script it will now launch Hotkeys + Fraps + Spotter + Sniper Elite. Once you have finished playing Sniper Elite and quit the game, the script will automatically terminate Fraps + spotter + Autohotkeys "your hotkeys".
* Updated logic for multiple macros on 1 button. "does not use a loop function" will cycle through your chosen macros each time you push the associated hotkey.
Note: This is a simplified tutorial explaining the basics to cover use in Sniper Elite. More advanced tutorials and code can be found
HERE or in the help file.
Quick Links
Downloading & InstallingTo start off, Download Auto Hot key from
HERE , the current version being Version 1.0.48.05
Next double click on the AutoHotkeyInstall.exe file, and follow the default installation, the default install folder should be "C:\Program Files\AutoHotkey\".
Creating Macro folder 1. Open "My Documents" click File---New Folder.
2. Right click on the "new folder" and rename it to Hotkey's or macros etc. This folder will store any Script files you create at a later date.
Creating Simple test ScriptWhile you have the "new folder" / "hotkeys" folder open, click File -- New -- AutoHotKey Script

Once you have done this, you will see a new file called "New AutoHotkey Script.ahk". Now open this file in notepad or another text editor. Right click on the file and select "edit script". NB: This file can be renamed at a later date, just keep the file extension e.g. "Sniperelite hotkeys.ahk".
Test files, and complete script file downloadsThese are only examples and you will need to edit these to display your own macros. Firstly, a script which will make your macro run only while Sniper Elite is the active window. E.g. it will not run if you are on your desktop, or in another game.
Code:
#IfWinActive Sniper Elite
ENTER YOUR MACRO SCRIPTS HERE
#IfWinActive
return
Add a simple Script to a HotKey, e.g. F2, Alt+F2 or Win+F2, either three methods work equally as well as the next.
Example 1Code:
;THIS IS A COMMENT LINE (HOTKEY F2)
$F2::
SetKeyDelay, 10, 10, PLAY
Sendplay, {t}
send ENTER YOUR MACRO HERE{ENTER}
return
Example 2Code:
;THIS IS A COMMENT LINE (HOTKEY alt+F2)
!F2::
SetKeyDelay, 10, 10, PLAY
Sendplay, {t}
send ENTER YOUR MACRO HERE{ENTER}
return
Example 3Code:
;THIS IS A COMMENT LINE (HOTKEY win+F2)
#F2::
SetKeyDelay, 10, 10, PLAY
Sendplay, {t}
send ENTER YOUR MACRO HERE{ENTER}
return
Add a Med Pack to a hotkey this macro has no send delay.
Code:
;medpack hotkey script (Hotkey is `)
`::Send ix
return
To Load your Hotkey script + applications e.g. Fraps & Sniperelite, a script like this can be used. This script will load your hotkey's first then fraps "minimized to tool bar, and finally Sniperelite "maximized". This script doesn't require a hotkey to run it, just double click, or create a short cut link on your desktop. NOTE: you will have to edit this script to show the directory's you installed sniperelite and fraps.
Code:
Run %A_MyDocuments%\hot keys\sniperelitehotkeys.ahk
Run, fraps.exe, C:\Program Files\Fraps, min
Run, SniperElite.exe, C:\Program Files\MC2\Sniper Elite, max
return
Full Script examplesCode:
; SniperElite Macros Noballs(NZ)
;Website : http://www.sniperelite.nzaus.co.nz/
;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; SniperElite Macros noballs(nz)
; This script will only run while sniperelite is maximized
#IfWinActive Sniper Elite
;medpack hotkey script
`::Send ix
return
;welcome hotkeys
$F2::
SetKeyDelay, 10, 10, PLAY
Sendplay, {t}
send Welcome, Please Stay out of Enemy Spawn{ENTER}
return
$F3::
SetKeyDelay, 10, 10, PLAY
Sendplay, {t}
send Get out of the Enemy Spawn Area Noob!!{ENTER}
return
$F4::
SetKeyDelay, 10, 10, PLAY
Sendplay, {t}
send Don't Unbalance the Server!!{ENTER}
return
;website macro
$F5::
SetKeyDelay, 10, 10, PLAY
Sendplay, {t}
send Website Google Sniperelite nz{ENTER}
return
#IfWinActive
return
Second scriptCode:
;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other
; SniperElite Macros Noballs(NZ)
;Website : http://www.sniperelite.nzaus.co.nz/
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Run %A_MyDocuments%\hot keys\sniperelitehotkeys.ahk
Run, fraps.exe, C:\Program Files\Fraps, min
Run, SniperElite.exe, C:\Program Files\MC2\Sniper Elite, max
return
The following script enables you to add a hotkey to any key in this case "e", which will be disabled when you push " t ' or " u " allowing you to use the key in your text. Pushing enter or esc will enable the macro again.
e.g. E= medpack, T= macro disabled "e" can be used without being associated to a hotkey. Enter= reinstates e= medpack
Code:
; SniperElite Macros Noballs(NZ)
;Website : http://www.sniperelite.nzaus.co.nz/
{
WinWait, Sniper Elite
WinWaitClose ; Wait for the exact window found by WinWait to be closed.
ExitApp ; Terminate
return
}
Hotkey, IfWinActive, Sniper Elite
Hotkey, e, EisIX , ON
Pause::Suspend
#IfWinActive Sniper Elite
{
t::
send t
Hotkey,e, EisIX ,OFF
return
u::
send u
Hotkey,e, EisIX ,OFF
return
Enter::
send {Enter}
Hotkey,e, EisIX ,ON
return
Esc::
send {Esc}
Hotkey,e, EisIX ,ON
return
}
#IfWinActive
return
IfWinNotActive Sniper Elite
{
Hotkey,e, EisIX ,OFF;
}
return
EisIX:
send ix
return
Disabling hotkey temporarilyThis Script is useful when assigning a hotkey to a single letter combination from a-z, while retaining the ability to use the letter in text messages. An example of this is to assign the med pack to the letter "e" which is disabled when either "t or u" are pressed, and reactivated by "esc and enter". This allows e to be used in conversations apposed to "ix" being sent each time you type "e".
First script is for 1 hotkey "e"Code:
; SniperElite Macros Noballs(NZ)
;Website : http://www.sniperelite.nzaus.co.nz/
Hotkey, IfWinActive, Sniper Elite
Hotkey, e, EisIX , ON
#IfWinActive Sniper Elite
{
t::
send t
Hotkey,e, EisIX ,OFF
return
u::
send u
Hotkey,e, EisIX ,OFF
return
Enter::
send {Enter}
Hotkey,e, EisIX ,ON
return
Esc::
send {Esc}
Hotkey,e, EisIX ,ON
return
}
#IfWinActive
return
IfWinNotActive Sniper Elite
{
Hotkey,e, EisIX ,OFF;
}
return
EisIX:
send ix
return
The following script incorporates F key macros along with E= med pack e.g. above script. Note: The limitation in sniper elite means that F keys cannot be pushed repetitively or the macro will not send correctly.
Multiple Macros on 1 buttonThis script will allow you to set two or more macros to a single key. For example if you want to have "Rule 1" and "Rule 2" both on F2, the macro will cycle through when pressing F2. Similarly this macro can be incorporated into the existing scripts in this tutorial so that you can use any key A to Z and have it disable when t or u are pressed. Example of the script below will cycle through 3 macros hotkey = F2
Code:
$F2::
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
if (macro_1var = 1)
{
macro_1var = 2
sendplay Macro option 1{ENTER}
}
else if (macro_1var = 2){
macro_1var = 3
sendplay Macro option 2{ENTER}
}
else if (macro_1var = 3){
macro_1var = 0
sendplay Macro option 3{ENTER}
}
else{
macro_1var = 1
sendplay Macro option 0{ENTER}
}
return
Example of the below code incorporated into ON OFF script allowing you to use t or u for text messaging
Complete Hoykey ScriptUpdated 20/5/09 script
This can be customised to suit, follow the examples given to add more macros to any key. Note: to have the number pad macros active Numlock needs to be ON.
This code also incorporates a script which will load sniperelite + your macros, and on exit of sniperelite will close autohotkey automatically. This will fix the bug where hotkey's retain running even if sniperelite is not running, or is minimized.
Code:
Run, Fraps.exe, C:\Program Files\Fraps\ , min
Run, Spotter.exe, C:\Program Files\Spotter for Sniper Elite , min
Sleep, 2000 ; 2 second
Run, SniperElite.exe, C:\Program Files\MC2\Sniper Elite\ , max
{
WinWait, Sniper Elite
WinWaitClose ; Wait for the exact window found by WinWait to be closed.
if WinExist("FRAPS general - Fraps")
WinClose
if WinExist("Spotter for Sniper Elite - Spotter for Sniper Elite")
WinClose
ExitApp ; Terminate
return
}
; SniperElite Macros Noballs(NZ)
;Website : http://www.sniperelite.nzaus.co.nz/
; This script will only run while sniperelite is maximized
Hotkey, IfWinActive, Sniper Elite
Pause::Suspend
{
Hotkey, 0, Smile , ON
Hotkey, 9, sad , ON
Hotkey, 8, tounge , ON
Hotkey, 7, shock , ON
Hotkey, e, medpack , ON
Hotkey, h, hi , ON
Hotkey, n, n1 , ON
Hotkey, o, ouch , ON
Hotkey, Numpad0, Teamspeak , ON
Hotkey, Numpad1, Noob2 , ON
Hotkey, Numpad2, killyou , ON
Hotkey, Numpad3, LMAO , ON
Hotkey, Numpad4, ROFL , ON
Hotkey, Numpad5, LOL , ON
Hotkey, Numpad6, thanks , ON
Hotkey, Numpad7, brb , ON
Hotkey, Numpad8, afk , ON
Hotkey, Numpad9, back , ON
}
#IfWinActive Sniper Elite
{
;welcome hotkeys
$F2::
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay Welcome, Stay out of Enemy Spawn{ENTER}
return
$F3::
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay Get out of the Enemy Spawn Area Noob!!{ENTER}
return
$F4::
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay Don't Unbalance the Server!!{ENTER}
return
;website macro
$F5::
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay Rules & Maps @ www.sniperelite.nzaus.co.nz{ENTER}
return
;no tnt
F6::
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay Don't place Tnt at Spawn Areas{ENTER}
return
;noob
F7::
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay Don't be a NOOB play like a Sniper!!!{ENTER}
return
F8::
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay We use the |GotS| no spawn maps{ENTER}
return
F11::
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay http://homepages.slingshot.co.nz/~rawjdmbj/sniperelite.html{ENTER}
return
t::
send t
Hotkey, 0, Smile ,OFF
Hotkey, 9, sad ,OFF
Hotkey, 8, tounge , OFF
Hotkey, 7, shock , OFF
Hotkey, e, medpack , OFF
Hotkey, h, hi , OFF
Hotkey, n, n1 , OFF
Hotkey, o, ouch , OFF
Hotkey, Numpad0, teamspeak , OFF
Hotkey, Numpad1, Noob2 , OFF
Hotkey, Numpad2, killyou , OFF
Hotkey, Numpad3, LMAO , OFF
Hotkey, Numpad4, ROFL , OFF
Hotkey, Numpad5, LOL , OFF
Hotkey, Numpad6, thanks , OFF
Hotkey, Numpad7, brb , OFF
Hotkey, Numpad8, afk , OFF
Hotkey, Numpad9, back , OFF
return
u::
send u
Hotkey, 0, Smile, OFF
Hotkey, 9, sad ,OFF
Hotkey, 8, tounge , OFF
Hotkey, 7, shock , OFF
Hotkey, e, medpack , OFF
Hotkey, h, hi , OFF
Hotkey, n, n1 , OFF
Hotkey, o, ouch , OFF
Hotkey, Numpad0, teamspeak , OFF
Hotkey, Numpad1, Noob2 , OFF
Hotkey, Numpad2, killyou , OFF
Hotkey, Numpad3, LMAO , OFF
Hotkey, Numpad4, ROFL , OFF
Hotkey, Numpad5, LOL , OFF
Hotkey, Numpad6, thanks , OFF
Hotkey, Numpad7, brb , OFF
Hotkey, Numpad8, afk , OFF
Hotkey, Numpad9, back , OFF
return
Enter::
send {Enter}
Hotkey, 0, Smile, ON
Hotkey, 9, sad, ON
Hotkey, 8, tounge , ON
Hotkey, 7, shock , ON
Hotkey, e, medpack , ON
Hotkey, h, hi , ON
Hotkey, n, n1 , ON
Hotkey, o, ouch , ON
Hotkey, Numpad0, teamspeak , ON
Hotkey, Numpad1, Noob2 , ON
Hotkey, Numpad2, killyou , ON
Hotkey, Numpad3, LMAO , ON
Hotkey, Numpad4, ROFL , ON
Hotkey, Numpad5, LOL , ON
Hotkey, Numpad6, thanks , ON
Hotkey, Numpad7, brb , ON
Hotkey, Numpad8, afk , ON
Hotkey, Numpad9, back , ON
return
Esc::
send {Esc}
Hotkey, 0, Smile, ON
Hotkey, 9, sad, ON
Hotkey, 8, tounge , ON
Hotkey, 7, shock , ON
Hotkey, e, medpack , ON
Hotkey, h, hi , ON
Hotkey, n, n1 , ON
Hotkey, o, ouch , ON
Hotkey, Numpad0, teamspeak , ON
Hotkey, Numpad1, Noob2 , ON
Hotkey, Numpad2, killyou , ON
Hotkey, Numpad3, LMAO , ON
Hotkey, Numpad4, ROFL , ON
Hotkey, Numpad5, LOL , ON
Hotkey, Numpad6, thanks , ON
Hotkey, Numpad7, brb , ON
Hotkey, Numpad8, afk , ON
Hotkey, Numpad9, back , ON
return
}
;#IfWinActive
return
IfWinNotActive Sniper Elite
{
Hotkey, 0, Smile, OFF;
Hotkey, 9, sad, OFF;
Hotkey, 8, tounge, OFF;
Hotkey, 7, shock , ON
Hotkey, e, medpack , OFF;
Hotkey, h, hi , OFF;
Hotkey, n, n1 , OFF;
Hotkey, o, ouch , OFF;
Hotkey, Numpad0, teamspeak , OFF;
Hotkey, Numpad1, Noob2 , OFF;
Hotkey, Numpad2, killyou , OFF;
Hotkey, Numpad3, LMAO , OFF;
Hotkey, Numpad4, ROFL , OFF;
Hotkey, Numpad5, LOL , OFF;
Hotkey, Numpad6, thanks , OFF;
Hotkey, Numpad7, brb , OFF;
Hotkey, Numpad8, afk , OFF;
Hotkey, Numpad9, back , OFF;
}
return
;Hotkey functions
Smile:
Hotkey, 0, Smile, OFF;
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay :){enter}
Hotkey, 0, Smile, ON;
return
sad:
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay :({enter}
return
tounge:
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay :P{enter}
return
shock:
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay :O{enter}
return
medpack:
send ix
return
hi:
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay Hi{enter}
return
n1:
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay n1{enter}
return
ouch:
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay ouch{enter}
return
;Bewlow are number pad hotkeys, only active if NumLock is ON!!!
teamspeak:
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay TS server ip 60.234.73.177:8769{enter}
return
Noob2:
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay Don't be such a NOOB!!{enter}
return
killyou:
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay I KILL YOU{enter}
return
LMAO:
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay lmao{enter}
return
ROFL:
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay rofl{enter}
return
LOL:
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay LOLOLOL{enter}
return
thanks:
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay ty{enter}
return
brb:
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay brb{enter}
return
afk:
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay afk{enter}
return
back:
SetKeyDelay, 10, 10, PLAY
sendplay t
Sleep, 30
SetKeyDelay, -1, -1, PLAY
sendplay back{enter}
return
Downloads Hotkey Macro ScriptsDownload medpack only script e=medpack, & Pause key = suspend macro"Standalone does not require autohotkey to be installed"
updated 18/5/09Attachment:
File comment: MedPack Macro v.3 Script file
Medpack Macro.ahk [658 Bytes]
Downloaded 97 times
Attachment:
File comment: MedPack Macro v.3 Stand Alone exe "Does not Require Autohotkey to be installed"
Medpack Macro v.3.exe [201.84 KiB]
Downloaded 105 times
Download Complete scriptupdated 18/5/09Attachment:
File comment: Complete Sniper Elite Macro Script file
Sniper Eilte.ahk [7.14 KiB]
Downloaded 130 times
Attachment:
File comment: Complete Sniper Elite Macro Script file Stand Alone exe "Does not Require Autohotkey to be installed"
Sniper Elite Macro.exe [202.72 KiB]
Downloaded 163 times