Jump to content
News Ticker
  • Developer applications are still open
  • Helper applications are still open
  • ba-rp.net:7777
Airwalk

Airwalk's autohotkey

Recommended Posts

Airwalk

Posted that guide on every server I've played on so far, so I'm gonna post it here as well. I don't take responsibility for any sort of misuse of Autohotkey and everyone should make themselves aware of their respective servers' rules regarding it.

 

1. Download Autohotkey and creation of your first script

1.1 Installing autohotkey

Before getting anything to work, we need a compiler with all the functions. The compiler can be found on the official autohotkey website, then you download Autohotkey_L.
After the download is finished, you go through the custom installation!
When being asked for the version, you pick Autohotkey_L 32Bit ANSI, it has the best compatibility, then you hit Install script compiler and install it.

 

1.2 Installing an editor with Syntax-Highlighting (optional, but recommended!)

I recommend downloading a an editor right at the beginning, because it displays the code in different colors, so the code is easier to read.
You simply download the programm called SciTE4AutoHotkey, download and install it, but also don't forget to tick Set as default .ahk file editor.
It runs itself after the installation, then you can do all the settings you wish (language preferences etc.)

 

1.3 How to create a script

Creating a script is easy, you just right click on your desktop and hit "new" -> "Autohotkey script".

 

2. Creation of hotkeys

2.1 A simple keybind

Now we're moving on to the creation of a simple keybind, upon triggering a set hotkey. We will start with /lock being sent upon pressing "1". Therefore, we use one of the many functions of Autohotkey, called SendInput alternatively you could also use Send or SendRaw, though I recommend the usage of SendInput, because the other two are slower and not useful for longer texts in your hotkeys.

Spoiler

 

We start with chosing the hotkey you wish to use to trigger your bind, in this example I will be using the 1 key on every keyboard. A hotkey is a "registered key", meaning a key, that is occupied with a function. The key stays occupied, until the script is closed or we do this manually (see further below).
You "register" a key, by adding a :: to your hotkey, an example would be KEY:: or 1:: for our example with using the key 1.
As explained above, I recommend the usage of SendInput to give the key a function, so it would look like this with the example of /lock:
1::
SendInput t/lock
The "t" automatically opens the chatlog for you, to type in the command. Now you want to close the chatbox as well, that is simply done by adding a {enter} beside your keybind, to simulate pressing the enter key:
1::
SendInput t/lock{enter}
To round everything up, add a return beneath your keybind, to prevent errors in your script.
How does the proper keybind look like now?

1::
SendInput t/lock{enter}
return

 

2.2 Modifying hotkey prefix symbols

Now, a brief description of prefix symbols; like control, alt, shift etc. A full list can be found here.

Spoiler

 

# Stands for Win (Windows-Logo-Key)
! Stands for L-Alt
^ Stands for Ctrl
+ Stands for Shift

Hotkey example:
!1::
The key 1 was triggered in combination with Alt.
With the keybind created in 2.1, the example would be:

!1::
SendInput t/lock{enter}
return

 

 

 

2.3 Sleep function
The word sleep is self-explaining, but in the means of Autohotkey, it means the script is paused for a set amount of time.
The usage is simple, if you wish to have multiple binds with one hotkey and also add a delay, you use the sleep function by adding a Sleep, TIMEINMS (Sleep, 1000 would mean that the script is paused for 1 second, alternatively 1000 milliseconds).

Spoiler

 

Starting with the /lock command again, saying that you want to automatically lock your vehicle after unlocking and entering it.
You write the bind regulary,
1::
Sendinput t/lock{enter}


But now we also add the sleep function to the script, to achieve what was said above

1::
SendInput t/lock{enter}
Sleep 5000
SendInput t/lock{enter}
return

 

 

 

2.4 Sending texts with Autohotkey

Now that you learned how to trigger your hotkeys, we will move on to sending longer texts.
Usage: SendInput TEXT
Attention! As mentioned above, we have learned how to use hotkey prefix symbols (windows key, ctrl, alt etc), those cannot be sent just like that, they have to be put in between a { and }. This also includes keys with a name that has more than 1 character eg. ENTER, TAB, or ESCAPE.

Spoiler

 

Sending a text without any special characters:

1::
SendInput tHello world, how are you?{enter}
return

This sends a regular chat message into the IC chat.

Hotkeys with prefix symbols:

2::
SendInput tHELP{!}{!}{!}{enter}
return

The exclamation mark has to be put into the { } as well, because it'll give you an error when you compile your script and won't let it work.

Typing into the chatbox, to make an addition to your hotkey:

3::
SendInput t/ticket  68127592 Being dumb{HOME}{right 8}
return

This could be used for tickets, if you don't know the amounts, as an example or are too lazy to learn them. The hotkey sends the text of the ticket, the amount. The {HOME} automatically moves your cursor to the far left side of your chatbox and the {right 8} moves your cursor 8 figures to the side, where you type the ID of the player you wish to ticket. This can be, ofcourse used for many other things as well.

 

2.5 Hotstrings ("/test")

Hotstrings are the concatenation of single hotkeys, as the titles says: ("/test").
The structure is similiar to the regular hotkeys, but you need to add two colons (:) infront and beside the hotkey.

Spoiler

 

("::hi::") -> when typing "hi" in the regular chatbox, you say "Hello" in the IC chat.

::hi::
SendInput Hello.{enter}
return

We do not place a t infront of the bind, because the chatbox is already opened.

Another example for a / bind would be:

:?:/snoozer::
SendInput /ticket 123 fuck a snake{enter}
return

The question mark (?) in between the colons (:) is used to make the bind work in SAMP only, not in your browser, Skype, Teamspeak or whatever.

 

2.6 Creation of a loop

Loops can be permanent or one-timed.
Usage: Loop, AMOUNT (if you leave the AMOUNT out, it creates a permanent loop).
A loop is used permanently, unless you add a return or break.

Spoiler

 

Example 1:
Use a loop five times

1::
Loop, 5 {     SendInput t/fish{enter}
}

/fish will be sent 5 times.

Example 2:
Use a loop indefinitely

1::
Loop
{
    SendInput t/fish{enter}
}

/fish will be sent indefinitely.

Example 3:
Use a loop until a certain key is pressed

1::
Loop,
{
SendInput t/fish{enter}
Keywait,<,D,T2
If !errorlevel
{
SendInput t/myfish{enter}
return
}
}
Return

The loop will be sent every 2 seconds (T2) until you press < (or any other key you replace it with in the script). Upon pressing <, the loop will stop and send /myfish as a last command, to end the loop and show the results of it.

 

 

Edited by Airwalk
  • Like 4

Share this post


Link to post
Share on other sites
Zapper

Looking good! Really helpful to new users.

Share this post


Link to post
Share on other sites
Bradley

Nice guide.

  • Like 1

Share this post


Link to post
Share on other sites
goldencandy610

Great guide 

Share this post


Link to post
Share on other sites
ElecTroN1

Nice guide, dude.

Share this post


Link to post
Share on other sites
Shots

Well needed.

Share this post


Link to post
Share on other sites
Pheno

Looks good, I will test it out soon.

Share this post


Link to post
Share on other sites
RNSS

Not a bad guide, but single-line commands can be made a bit easier. For example:
 

!1:: Send, t^a/lock`n


Works exactly the same as:

!1::

Send, t^a/lock`n

Return


But it looks neater in some code.

Also, instead of t/, rather use t^a/ or t^a^x/. t/ results in people typing "Hello, my nat/lock" more often than I like to see, while t^a/ selects all pretyped text before typing any commands, which just results in having to retype. t^a^x/ cuts the text to your clipboard so you don't need to retype, you just need to paste and continue.

And the `n that I use is just personal preference. It's shorter and does the same as {Enter}.

Still a good guide, these are just some pet peeves :p I'll make my own guide about it a bit later.

Edited by RNSS
Screwed up the [code] sections

Share this post


Link to post
Share on other sites
Connor

Man like Airwalk

 

ese Toza

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×