[Tutorial] Auto HotKey - post your questions & requests here

Status
Not open for further replies.

Fleur

Retired Admin
Joined
Dec 29, 2010
Messages
2,658
Likes
1
IG Name
Le Flower
#1
Disclaimer
This guide is made exclusively for RCRP, and I would deeply appreciate it if it wasn't plagiarized anywhere else. You can post questions about your binds, or even have one made for you! I will be posting a couple of examples (some of which were brought to my knowledge, thanks to the community), which you can edit to your liking at the end of this post.​
What is Auto HotKey?
AutoHotKey, or AHK, is a keyboard macro program. It is basically assigning a different key, command (or even a series of commands) into one key (or command). This wonderful program is free to download, just click HERE!

With just one press of a button, you can do things like this without having to type a thing!

Code:
** Fleur Fournier crouches, opens her large metallic briefcase and reveals a disassembled sniper rifle. **
** Fleur Fournier takes the three-part rifle out and starts assembling it piece-by-piece. **
** (1/3) Attaches the barrel piece to the main rifle.. ((Fleur Fournier))**
** (2/3) Attaches the sniper scope to the main rifle.. ((Fleur Fournier))**
** (3/3) Loads bullet rounds into the rifle chamber and shuts it close with a snap! ((Fleur Fournier)) **
This was a bind I used back in Aperture. The code is found below, if you're interested. You can also use AHK to open paytolls, enter and exit a building, turn your vehicle's engine and lights on, and even add /anims to your me's! Neat, huh?

Advantages?​
  • You can easily keep up with other people's RP binds.
    (ex. He pulls out a desert eagle in a second because of binds, you won't be stuck typing your /me.)
  • The likelihood of asspulls are reduced.
  • Your /me's mixed with /ame's will distinguish you from other strangers when you're masked!
  • You can add additional things you just can't be bothered to type over and over, like various /ames, /dos and /anims to spice up your RP!

Disadvantages?​
  • It somewhat takes the fun out of the RP if you bind every single thing you do! eg. repetitive.
  • It is somewhat prone to abuse with its warped sense of time, especially in creating binds with multiple actions.
    (ex. Some people whip out an AK from their backpacks in a fraction of a second, spraying you with bullets immediately)
Auto Hotkey Basics #1​

Most people use binds for simple and repetetive tasks: like opening a door to enter or exit, or pulling their gun out.
Normally, we would type it as:

Code:
"/me opens the door, makes a quick exit and slams the door behind her."
Followed by an "/exit".

"/me reaches under her skirt and reveals a Desert Eagle tucked into her leg holster."
"/me quickly pulls it out and removes the safety."
Followed by scrolling.
Okay, most people don't even bother with the first bind at all, but the latter will prove to be very useful.
Why? Because it will probably take you a longer time to type everything out compared to the actions your character is supposedly doing.

Now, I'll post the AHK code equivalent for the ones posted above!
Code:
F1:: SendInput t/me opens the door, makes a quick exit and slams the door behind her.{enter}t/exit{enter}
F2:: SendInput /me reaches under her skirt and reveals a Desert Eagle tucked into her leg holster.{enter}t/me quickly pulls it out and removes the safety.{enter}
How Does It Work?​

F1::SendInput t/me opens the door, makes a quick exit and slams the door behind her.{enter}t/exit{enter}
Anything behind the two colons will act as your trigger button. In the case above, pressing F1 will activate the bind for exiting the building, while pressing F2 will activate the revealing and drawing of your Desert Eagle. If you want to know what keys and buttons you can use, simply click HERE!

F1:: SendInput t/me opens the door, makes a quick exit and slams the door behind her.{enter}t/exit{enter}
This is just one of the many command lines in AHK. Luckily, this is the only one you need to know because we will only be typing in chat commands. If you're interested in what other commands AHK has in store for you, simply click HERE! Although it's only something I would recommend after you've mastered the basics for simple binding.

F1:: SendInput t/me opens the door, makes a quick exit and slams the door behind her.{enter}t/exit{enter}
You might have noticed that there's always a "T" before our /me's. It's there because before you type in anything in RCRP, you always have to press "T" (for talk) first! Makes sense, right?

F1:: SendInput t/me opens the door, makes a quick exit and slams the door behind her.{enter}t/exit{enter}
What comes after the "T" is your usual RCRP chat commands, pretty self explanatory.

F1:: SendInput t/me opens the door, makes a quick exit and slams the door behind her.{enter}t/exit{enter}

Okay, {enter} is the command AHK accepts to press the actual "Enter" key. Don't forget to put this in after every command! Again, pretty self explanatory. After each {enter} you can put in an unlimited number of commands, provided you don't forget to add the "T" that activates the chatbox first.

Auto Hotkey Basics #2, Q&A​

Question: I have too much binds and I ran out of keys for more!

Answer : It's simple! You can combine your trigger buttons with other buttons like ALT, CTRL and SHIFT for more options. You just have to add the right variable before your trigger button. Let's say I want to press ALT+Q to activate the command, "/paytoll".

Just type in !Q:: as your trigger. The ! is your variable which stands for ALT. Therefore, !Q means ALT+Q. Still with me? Great!
How about CTRL and SHIFT? The variable for CTRL is ^, while SHIFT is +. So, here's a quick review!

!1 = ALT and Q
^Q = CTRL and Q
+F1 = SHIFT and F1

Question: If exclamation marks (!) stand for ALT, then how do I add exclamation marks to my binds?

Answer: You will have to wrap them in brackets, like so {!}. The same goes for {^} and {+}.

Advanced Auto Hotkey​

Okay, so you've pretty much mastered the basics and have setup a pretty good set of binds, huh?
Here's a little guide you can refer to when the basics just don't satisfy you anymore.

Binds AndTimers​
These are especially handy for a more realistic approach to your binds (because, duh, they don't take one second to finish)!
For this tutorial, we will be quoting the first AHK code posted above.

Code:
** Fleur Fournier crouches, opens her large metallic briefcase and reveals a disassembled sniper rifle. **
After 2 seconds..
** Fleur Fournier takes the three-part rifle out and starts assembling it piece-by-piece. **
After 4 seconds..
** (1/3) Attaches the barrel piece to the main rifle.. ((Fleur Fournier))**
After 4 seconds..
** (2/3) Attaches the sniper scope to the main rifle.. ((Fleur Fournier))**
After 3 seconds..
** (3/3) Loads bullet rounds into the rifle chamber and shuts it close with a snap! ((Fleur Fournier)) **
All in all, this semi-realistic bind takes around 13-15 seconds to finish. The next question is: how do we achieve this using AHK?
I'll be providing the code I used for this bind (/anims included), and like before, we're going to dissect it piece by piece.

Code:
F1:: 
{
SendInput t/bomb{enter}
SendInput t/me crouches down and opens her large metalic briefcase, revealing a disassembled Sniper Rifle.{enter}
SendInput t/ame Fleur Fournier crouches down and opens her large metalic briefcase, revealing a disassembled Sniper Rifle.{enter}
sleep 2000
SendInput t/me takes the 3-part rifle out, assembling it - piece by piece.{enter}
SendInput t/ame Fleur Fournier takes the 3-part rifle out, assembling it - piece by piece.{enter}
sleep 4000
SendInput t/bomb{enter}
SendInput t/do (1/3) Attaching the barrel piece to the main rifle.{enter}
SendInput t/ame *click* *click* *click*{enter}
sleep 4000
SendInput t/bomb{enter}
SendInput t/do (2/3) Attaching the sniper scope to the main rifle.{enter}
SendInput t/ame *click* *click* *click*{enter}
sleep 3000
SendInput t/bomb{enter}
SendInput t/do (3/3) Loading bullets into the chamber, shutting it close with a *SNAP!*{enter}
SendInput t/ame *CLICK*{enter}
    return
}
Okay, so the new things here're are the opening and closing brackets, and the sleep command. Notice the two brackets ( { } ) after the trigger button and at the end of the actual code. These brackets safely enclose all the codes you want to use in one bind. DON'T FORGET THEM. Especially when you're dealing with multiple commands and long binds.

The Sleep command acts like a timer, with the number next to it acting as the variable.

Code:
sleep [b]2000[/b]
SendInput t/me takes the 3-part rifle out, assembling it - piece by piece.{enter}
2000 = 2000 miliseconds, meaning after 2 seconds, your "/me takes the three-part.." will appear.

Note/s​
Will add some extras after a bit, no ETA though. Again, I'd appreciate it if we help each other out with requests.
Comments? Suggestions? Anything you want to add or ask? Got a request?
Post below and thank you for reading!
 
Joined
Oct 26, 2010
Messages
3,610
Likes
8
IG Name
'Dre | Maze
#2
Re: Guide : Auto HotKey - posts your questions and requests here!

Nice guide. Although there are others. This is better. You should provide a link for download.
/sticky.
 

Steve

Donator
Joined
Sep 5, 2010
Messages
2,746
Likes
1
IG Name
Steve Hudson
#3
Re: Guide : Auto HotKey - posts your questions and requests here!

Never used AHK before, is it better then CHAOS AD SAMP keybinder?
 

Fleur

Retired Admin
Joined
Dec 29, 2010
Messages
2,658
Likes
1
IG Name
Le Flower
#4
Re: Guide : Auto HotKey - posts your questions and requests here!

There're alot of things you can do with AHK that you can't do with Chaos AD!
Like timers! 8D
Plus, you have the option of alt+button, shift+button, ctrl+button to trigger your binds.

Note : Added download link.
 

Steve

Donator
Joined
Sep 5, 2010
Messages
2,746
Likes
1
IG Name
Steve Hudson
#5
Re: Guide : Auto HotKey - posts your questions and requests here!

Aah, okay.
I will give it a try. ;)
 

Robin

Lead Administrator
Joined
Sep 11, 2010
Messages
8,469
Likes
445
IG Name
Finlayson / Quatros
IG Faction
RCPD (7) | L.Diablos (7) | DoC
#6
Re: Guide : Auto HotKey - posts your questions and requests here!

It looks nice, but I installed it, in C:/Program Files/Autohotkey blabalblab
But then you got a few icons, but how the f*** can you start it? If I click the green thingy, a notepad comes up with some text. Do I need to edit that? and how can I open it to let it run IG? I fail epicly and don't understand a shit from it.

Hope you can help me nor make some SS's like : Step 1, Step 2, then click this etc etc.
 

Fleur

Retired Admin
Joined
Dec 29, 2010
Messages
2,658
Likes
1
IG Name
Le Flower
#7
Re: Guide : Auto HotKey - posts your questions and requests here!

Robin said:
It looks nice, but I installed it, in C:/Program Files/Autohotkey blabalblab
But then you got a few icons, but how the f*** can you start it? If I click the green thingy, a notepad comes up with some text. Do I need to edit that? and how can I open it to let it run IG? I fail epicly and don't understand a shit from it.

Hope you can help me nor make some SS's like : Step 1, Step 2, then click this etc etc.
You right click on the desktop, and go on NEW>Autohotkey Script.

It should create something like "New Autohotkey Script.ahk" with a big 'H' icon.

Right click on it, OPEN WITH > Notepad.

You should see this. (and yes, that's my awesome wallpaper)


Just put in the script on the right place, if you still have troubles with your script post here again!
 

Robin

Lead Administrator
Joined
Sep 11, 2010
Messages
8,469
Likes
445
IG Name
Finlayson / Quatros
IG Faction
RCPD (7) | L.Diablos (7) | DoC
#8
Re: Guide : Auto HotKey - posts your questions and requests here!

Thanks for the help! I will try it out later, since I'm busy with my homework ATM.
 
Joined
Aug 13, 2010
Messages
7,065
Likes
22
#9
Re: Guide : Auto HotKey - posts your questions and requests here!

Nice but confusing.. Currently making scripts now.

Edit: Is this right?


Double edit: Here is my script fleur.

;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other <[email protected]>
;
; 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.


F1::SendInput t/me opens the door, making a quick exit and slams the door behind her.{enter}t/exit{enter} (( <-- Thats yours. ))
 

Fleur

Retired Admin
Joined
Dec 29, 2010
Messages
2,658
Likes
1
IG Name
Le Flower
#10
Re: Guide : Auto HotKey - posts your questions and requests here!

 
Status
Not open for further replies.