Post new topic Reply to topic  [ 5 posts ] 

Autohotkey Tutorial "updated 28/9/09"

 Post subject: Autohotkey Tutorial "updated 28/9/09"
New postPosted: April 30th, 2009, 5:27 pm 
Offline
Site Admin
Site Admin

Joined: April 18th, 2009, 9:10 am
Posts: 7
Country: New Zealand (nz)
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 & Installing

To 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\".

Image

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 Script

While you have the "new folder" / "hotkeys" folder open, click File -- New -- AutoHotKey Script

Image

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 downloads

These 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 1
Code:
;THIS IS A COMMENT LINE (HOTKEY F2)
$F2::
SetKeyDelay, 10, 10, PLAY
Sendplay, {t}
send  ENTER YOUR MACRO HERE{ENTER}
return


Example 2
Code:
;THIS IS A COMMENT LINE (HOTKEY alt+F2)
!F2::
SetKeyDelay, 10, 10, PLAY
Sendplay, {t}
send  ENTER YOUR MACRO HERE{ENTER}
return


Example 3
Code:
;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 examples

Code:
; 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 script

Code:
;
; 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 temporarily

This 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 button

This 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 Script

Updated 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 Scripts

Download medpack only script e=medpack, & Pause key = suspend macro"Standalone does not require autohotkey to be installed" updated 18/5/09

Attachment:
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/09
Attachment:
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


Last edited by Noballs(NZ) on September 28th, 2009, 6:06 pm, edited 11 times in total.
updated link to new version of Autohotkey 1.0.48.05


Top
 Profile E-mail  
 
 Post subject: Re: Autohotkey Tutorial
New postPosted: May 18th, 2009, 9:09 pm 
Offline
Moderator
Moderator

Joined: April 18th, 2009, 6:08 pm
Posts: 15
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


this code is using a variable to store which macro option to run. it loops though them by incrementing the variable each time.
To add more insert a new "else if" statement into the code as shown below
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 = 4             ; <<<Change this to the new option number. From 0 to 4
            sendplay  Macro option 3{ENTER}
         }
      else if(macro_1var = 4) {                ;<<<New section
            macro_1var = 0                     ;<<<New section
              sendplay  Macro option 4{ENTER}  ;<<<New section
       }                                       ;<<<New section
      else{
            macro_1var = 1
            sendplay  Macro option 0{ENTER}
         }
      return

to add one more then
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 = 4                                     
            sendplay  Macro option 3{ENTER}
         }
      else if(macro_1var = 4) {                               
            macro_1var = 5                     ;Change this from 0 to 5                                       
              sendplay  Macro option 4{ENTER}           
       }           
      else if(macro_1var = 5) {                  ;<<<New Section
            macro_1var = 0                       ;<<<new section
              sendplay  Macro option 4{ENTER}    ;<<<new section
       }                                         ;<<<new section
       else{
            macro_1var = 1
            sendplay  Macro option 0{ENTER}
         }
      return




and for a further example
Code:


$F2::
     
      SetKeyDelay, 10, 10, PLAY
      sendplay t
      Sleep, 30
      SetKeyDelay, -1, -1, PLAY
      if (macro_1var = 1)
         {
            macro_1var = 2
            sendplay  OMG I died again{ENTER}
         }
      else if (macro_1var = 2){
            macro_1var = 3
            sendplay  and again{ENTER}
         }
      else if (macro_1var = 3){
            macro_1var = 4                                     
            sendplay  and again dammit{ENTER}
         }
      else if(macro_1var = 4) {                               
            macro_1var = 5                                                                                   
              sendplay  Screw this I'm off to play tiddlywinks{ENTER}           
       }           
       else{
            macro_1var = 1
            sendplay  I died god dammit{ENTER}  ;Note this is the first thing sent
         }
      return     
               

which if placed into the script would output one line at a time when the f2 key was pressed

I died god dammit
OMG I died again
and again
and again dammit
Screw this I'm off to play tiddlywinks

in that order before looping back through them.

_________________
...and back to lurking...like a sniper.


Top
 Profile  
 
 Post subject: Re: Autohotkey Tutorial "updated 20/5/09"
New postPosted: August 30th, 2009, 11:20 pm 
Offline
Rifleman
Rifleman
User avatar

Joined: May 5th, 2009, 10:51 am
Posts: 31
Location: moscow
Gender?: Male
We use lot of phrases how "Multiple Macros on 1 button"
In future there will be 20 phrases.
Is it possible write them random in chat sniper elite.
If it is.how?

P.S.:I think you must know.From russian community SovS i thank you.Without your help we cant use this programm.
Thank else for your work. :eusa-clap: amm.


Top
 Profile E-mail  
 
 Post subject: Re: Autohotkey Tutorial "updated 20/5/09"
New postPosted: September 2nd, 2009, 9:32 pm 
Offline
Moderator
Moderator

Joined: April 18th, 2009, 6:08 pm
Posts: 15
for having the one key send multiple strings, one per key press.
this time random

for more options add more if else sections and modify the line
Random, macro_1var, 0 , 4 to have a larger second digit. ie set the 4 to however many options you have

Code:

$F2::
     
      SetKeyDelay, 10, 10, PLAY
      sendplay t
      Sleep, 30
      SetKeyDelay, -1, -1, PLAY
      Random, macro_1var, 0, 4
      if (macro_1var = 1)
         {
            sendplay  Macro option 1{ENTER}
         }
      else if (macro_1var = 2){           
            sendplay  Macro option 2{ENTER}
         }
      else if (macro_1var = 3){
            sendplay  Macro option 3{ENTER}
         }
      else if(macro_1var = 4) {               
              sendplay  Macro option 4{ENTER} 
       }                                       
      else{           
            sendplay  Macro option 0{ENTER}
         }
      return

_________________
...and back to lurking...like a sniper.


Top
 Profile  
 
 Post subject: Re: Autohotkey Tutorial "updated 4/9/09"
New postPosted: September 28th, 2009, 6:05 pm 
Offline
Moderator
Moderator
User avatar

Joined: April 18th, 2009, 10:25 am
Posts: 693
Location: New Zealand
Country: New Zealand (nz)
Personal Message: mmm medic!!!!
Gender?: Male
Nick Name: Shifty
clan: NZAUS
Updated code
Attachment:
Sniper Eilte.ahk [7.35 KiB]
Downloaded 80 times

_________________
{Turning your Socks Red}


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

cron

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style by Daniel St. Jules of Gamexe.net Modified by NZAUS