AutoHotkey for Faster Editing

Find detailed help from the AAO community, or write your own tutorials.

Moderator: EN - Forum Moderators

User avatar
Jean Of mArc
Posts: 822
Joined: Fri Oct 22, 2010 2:19 am
Gender: Male
Spoken languages: English, French, Japanese

AutoHotkey for Faster Editing

Post by Jean Of mArc »

--- AutoHotkey for Faster Editing ---


Purpose: I am a true believer in the hotkey; keyboard shortcuts that make using a computer much more fast and efficient. As such, I like to implement them while using the AAO Editor to make my work time more efficient. AutoHotkey is a program that allows you to write and define your own keyboard shortcuts for use in any program that you use. In this quick guide, I will show you how to set up AutoHotkey, and a few tricks as to how it can be used for AAO.

Disclaimer: Sorry, the program only works in a Windows (or perhaps Windows-emulated) environment. You can stop booing now. :)

1. Install AutoHotkey: Simply click on this link, and then follow the setup program's instructions. It is just like installing any other program.

2. Don't be scared of scripts: There is no program to run, per se, so the next thing to do is to write a script, which tells AutoHotkey what you want your hotkeys to be. This is not as difficult as it sounds, and if you are scared, just use the ones I have provided below. I also have included some ways in which you can adjust the shortcuts yourself.

3. Load up a text editor: To begin writing your script, load up any text editor, for example Notepad. The official editor for scripts is called SciTE4, which you can download here. If you don't want something so specific, I highly recommend the excellent Notepad++. DO NOT USE WORD or OPENOFFICE! These save their files in a special format, and they WON'T work with AutoHotkey unless you save it in the correct format. But even that will be a pain, because Word has auto-correct and such. Just trust me, it is better not to use them.

4. Write a script: This is where the meat of the tutorial comes in. In AutoHotkey, there are many ways to define what you want your shortcut to do. For example, you can set it so that when you press "F2", the mouse will automatically click a part of the screen. You can set it so that "Control+7" automatically types in the word "Ace Attorney Rules!" on your computer. You can set it so that whenever you type the word "btw" that it will automatically replace it with "by the way".

Here's an example. Let's say you wanted to create a shortcut in which whenever you press the Windows key + S, it will insert a "shake" into your text. Within the editor, there are two ways to do this: you either type "[#s]" every time, or you click on the "Shake" button. However, clicking the shake button adds a space before and after, which can be a bit tedious to delete every time. Not only that, but clicking on it every time is slower than just hitting Win+S, right!?

In your text editor, write the following line:

Code: Select all

^s::Send [{#}s]
AAAAAAHHHH!!! What does THAT mean!? Allow me to explain: the syntax of a keyboard shortcut is as follows:

{Shortcut}::{Action}

{Shortcut} describes to the program what our shortcut will be. We want our shortcut to occur when we press the "Windows" key, AND press the "s" key while it is held down. "^s" describes EXACTLY that. The "^" character means "the windows key" to the program, and the "s" tells the program what ELSE must be pressed at the same time. Therefore:

"^s" means "Win+s"

{Action} describes what will happen when the shortcut has been pressed. In this case, we want the keyboard to type "[#s]". Using the word "Send" tells the keyboard to type whatever comes after it. However, the character "#" has a special meaning in AutoHotkey. Therefore, it has to be "escaped". In programming, an "escaped" character means that we actually want the character, not its functional meaning. In AutoHotkey, any characters with special meaning have to be surrounded by "{" and "}". Therefore, in AutoHotkey:

"Send [{#}s]" means "Type [#s]"

Before, I told you that the syntax for a shortcut is {Shortcut}::{Action}. Therefore, typing:

Code: Select all

^s::Send [{#}s]

Means, in English, "Whenever I press the Windows key and 's' at the same time, type out the word "[#s]". (Don't worry if this seems like a lot to take in, it gets easier the more you work with it!)

Following the same principle, can you think of how to make a shortcut so that when we hit "Win+F", we type in "[#f]"? Every shortcut must be on A NEW LINE.
Spoiler : Answer :

Code: Select all

^f::Send [{#}f]
It is pretty much exactly the same as the previous one, expect that we replace the "s" with "f" in both cases.
4. Running our script: Nothing will take effect on our computer until we save and run our script. To do so, let's save what we have so far. Note: when you save it, the filename MUST end with ".ahk". Therefore, let's call it "AAOEditor.ahk" or something to that effect. Now, all you have to do is double-click on that file, and it will take effect. Try it out now!
Note: You must repeat these steps EVERY TIME you update the script. Furthermore, everytime you repeat these steps, you will get a pop-up that confirms that you want to update the script. Just click "Yes" every time.

5. More keyboard shortcuts: One of the best ways to improve the presentation of our trials is to add speech pauses. If you look at real AA games, there is always a short pause between sentences if they both appear in the same textbox. This makes sense, as when when speak in real life we tend to pause between sentences! So within the following textbox:

Code: Select all

I wasn't sure why he was
there. I'd never seen him
around the place before.
There should be a pause between the two sentences. Ie, it should look like this:

Code: Select all

I wasn't sure why he was
there.[#p25] I'd never seen him
around the place before.
This will input a 25 centisecond pause between the two sentence. This may not seem like much time, but it is enough.

Because I do that every time I end a sentence in the middle of a textbox, I've assigned a keyboard shortcut to it. I made it so that whenever I hit "Win+." (that is windows key plus the period key) it will automatically insert "[#p25]". Also, in "Justice For All" and beyond, I've noticed an even shorter pause at commas. So the following sentence:

Code: Select all

Well, I'm not so sure about 
that.
Will be written like this:

Code: Select all

Well,[#p10] I'm not so sure about 
that.
Knowing what you already know, can you figure out how to set Win+. to write "[#p25]", and for Win+, to write "[#p10]"?
Spoiler : Answer :

Code: Select all

^.::Send [{#}p25]
^,::Send [{#}p10]
6. Hotstrings: Hotstrings are a little bit different than hotkeys. Instead of hitting a key or two to perform an action, you instead type in some text. For example, you might type "ttyl", and then hit the space bar, and AutoHotkey will immediately it with "Talk to you later." The syntax for that is as follows:

::{Short text}}::{Long text}

This means that any time you type whatever is in "{Short text}", it will replace it with whatever is in "{Long text}". Note that {Long text} is different than {Action}. With {Action}, you HAD to type "Send" in order to tell AutoHotkey that you wanted to type some text. In {Long Text} you do NOT type "Send", as it automatically assumes that you want to replace the text.

Let's create an example. Pretty much every AA game will talk about the Court Record on a regular basis. Whether it is explaining the basics to a new user, or referring to evidence, or adding evidence, you will need to type it on occasion. Therefore, why don't we make a shortcut for it? Whenever we type the letters "cr" and hit space, it should automatically replace it with "Court Record". Note, this will NOT take effect as soon as you type "cr"! This is good, in case you were typing the word "cream" or something. It will only take effect if the initials are isolated. To create this shortcut, we simply add the following to our script:

Code: Select all

::cr::Court Record
Pretty simple, eh?

Just for practice, why not write some hotstrings, in which "pw" becomes "Phoenix Wright", "prc" becomes "prosecution", "yh" becomes "Your Honor", or anything else you can think of?
Spoiler : Answers :

Code: Select all

::pw::Phoenix Wright
::prc::prosecution
::yh::Your Honor
7. Advanced Examples: There are many ways in which this program can be taken advantage of besides just typing things in for us. This is especially true if you are in a textbox (where you type the text you want your characters to say), because then AutoHotkey can act relative from that point.

For example, we could make it so that whenever we type "s1.3", it changes the speed of that textbox to be 1.3 instead of 1. The way we do this is by taking advantage of TWO things: AutoHotkey's ability to hit many keys in a row, and Firefox's built-in keyboard shortcuts. (They are probably similar in other browsers, but I am only covering Firefox for now).

First, we need to figure out the EXACT combination of keys required to make this action happen. So if we are in a textbox, entering some text for a character to say, we need to find out how to get to the input box for "Speed", type "1.3" and then go back up using ONLY the keyboard. This example is actually not that difficult. When you are in a textbox, if you press Tab 3 times, you will go down to the "Speed" box. There, you can type in "1.3". After that, you press "Shift+Tab" again three times to get back up to the textbox.

With that knowledge at hand, we can make our script knowing only two additional things: to make the keyboard press tab, we must write "{Tab}" in the script. To get "Shift+Tab", we must use the special character "+", which represents "Shift". Hence, "+{Tab}" means "Shift and Tab":

Code: Select all

::s1.3::{Tab}{Tab}{Tab}1.3+{Tab}+{Tab}+{Tab}
After we run this script, from now on, we just type "s1.3" while in a textbox, and AutoHotkey will take care of the rest. Of course, if you foresee yourself typing that under any other circumstance, you might want to change the hotstring, or disable the script when not in use.

Now try doing the same thing, setting "s1.5" to be "1.5" and "s2" to set the speed to "2"!
Spoiler : Answers :

Code: Select all

::s1.5::{Tab}{Tab}{Tab}1.5+{Tab}+{Tab}+{Tab}
::s2::{Tab}{Tab}{Tab}2+{Tab}+{Tab}+{Tab}
Now for our most advanced usage of AutoHotkey so far: whenever we type ">>>", the current textbox will create a new frame BELOW the current one, AND it will merge the current one to the new one.

Again, to achieve this, we first find out the keystrokes required to achieve the result:

First, close the current textbox.
Second, add a new frame below the current one.
Third, merge the current frame with the new one we just created.

While we are in a textbox within the editor, we want to hit the confirm button. To do so, we need to hit Tab 4 times, then hit Enter.
From there, we want to create a new frame below the current one. To do so, we hit Tab 7 times, then hit Enter.
Finally, we want to go backwards and tick the checkbox that allows us to merge one frame to another. To do so, we hit Shift+Tab 7 times, then hit Space.

We look up the codes for Enter and Space in the AutoHotkey documentation. We discover that enter is just {Enter}, and space is just {Space}. And there we have it, all the information we need!

Can you think of what the script will be to make a shortcut, in which whenever we type ">>>" and hit space, we will confirm the current text area, add a frame below the current, and merge the current frame with the new one?
Spoiler : Answer :

Code: Select all

::>>>::{Tab}{Tab}{Tab}{Tab}{Enter}{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Tab}{Enter}+{Tab}+{Tab}+{Tab}+{Tab}+{Tab}+{Tab}+{Tab}{Space}
8. Conclusion: Well, that's it for this tutorial on how you can use AutoHotkey to benefit your AAO trial-making! I may add more along the way, if I can think of something appropriate or if others have something to add. I hope this is helpful to you! Please leave feedback and feel free to post your own shortcuts, if you discover some useful ones!
Last edited by Jean Of mArc on Thu Mar 03, 2011 9:28 am, edited 1 time in total.
User avatar
henke37
Security expert / tools programmer
Posts: 3031
Joined: Wed Mar 04, 2009 9:42 pm
Gender: Male
Spoken languages: Swedish,English
Location: Sweden
Contact:

Re: Guide: AutoHotkey for Faster Editing

Post by henke37 »

For the record, I'd like to note that the windows key is reservated by well, Windows. So I advice against using it in your own keyboard shortcuts.

But the overall idea of using custom shortcuts is a great idea.
Currently working on a redesign of Court-records.net.
User avatar
Jean Of mArc
Posts: 822
Joined: Fri Oct 22, 2010 2:19 am
Gender: Male
Spoken languages: English, French, Japanese

Re: Guide: AutoHotkey for Faster Editing

Post by Jean Of mArc »

henke37 wrote:For the record, I'd like to note that the windows key is reservated by well, Windows. So I advice against using it in your own keyboard shortcuts.
That's true. Windows does have a number of built-in functions with the windows key that you might not want to override.

Thankfully, AutoHotkey overrides the usual action Windows takes, so if you don't regularly use those actions, there's no problem re-purposing them. I get much more use out of them this way than I did for their original purpose.
User avatar
Meph
Posts: 13439
Joined: Mon Nov 10, 2008 10:07 pm
Gender: Male
Spoken languages: English
Location: Probably Disneyland Paris... or the UK

Re: Guide: AutoHotkey for Faster Editing

Post by Meph »

Thanks! This'll be really useful! :D
User avatar
Jean Of mArc
Posts: 822
Joined: Fri Oct 22, 2010 2:19 am
Gender: Male
Spoken languages: English, French, Japanese

Re: Guide: AutoHotkey for Faster Editing

Post by Jean Of mArc »

Haha, so far it looks like most people are too scared to comment... besides you two, of course... maybe it is more technical than most AAO members are comfortable with!

Meph, do you intend to use them? And then be amazed at how much faster certain tasks are?
User avatar
Meph
Posts: 13439
Joined: Mon Nov 10, 2008 10:07 pm
Gender: Male
Spoken languages: English
Location: Probably Disneyland Paris... or the UK

Re: Guide: AutoHotkey for Faster Editing

Post by Meph »

Jean Of mArc wrote:Meph, do you intend to use them?
Actually, I've changed my mind. Sorry. :( If it was a Firefox add-on, I would have used it. I don't like these sorts of programs.
Mimi
Posts: 10382
Joined: Wed Jan 27, 2010 6:35 am
Gender: Female
Spoken languages: English: the only language I can brag about

Re: Guide: AutoHotkey for Faster Editing

Post by Mimi »

This looks cool! But I'm afraid I won't be using it... because... I'm just sooooo lazy... :oops:
User avatar
Ryu Ushiromiya
Posts: 2361
Joined: Wed Jan 05, 2011 6:57 pm
Gender: Male
Spoken languages: American English, Español (Puerto Rico)
Location: Puerto Rico

Re: Guide: AutoHotkey for Faster Editing

Post by Ryu Ushiromiya »

Mii-sama, whenever you can, could you look at mine trial onegai? It needs your stamp of approval. XD

Jean- this is an excellent tip that'll work for most people. I hope it is of use.
IMPORTANT MESSAGE! CLICK HERE PLEASE?
Apologies if I do not reply in a timely manner. Sig by Tap!

Image
User avatar
Jean Of mArc
Posts: 822
Joined: Fri Oct 22, 2010 2:19 am
Gender: Male
Spoken languages: English, French, Japanese

Re: Guide: AutoHotkey for Faster Editing

Post by Jean Of mArc »

Meph wrote:
Jean Of mArc wrote:Meph, do you intend to use them?
Actually, I've changed my mind. Sorry. :( If it was a Firefox add-on, I would have used it. I don't like these sorts of programs.
To be honest, that doesn't make much sense to me... how could you want to do this if it were a firefox add-on, but not like it if it were a separate program?
Ryu wrote:Jean- this is an excellent tip that'll work for most people. I hope it is of use.
I hope so too, but so far it doesn't seem to be within the realm of interest for the majority of AAO users. Oh well. :P Maybe someone will eventually make use of it.
User avatar
Meph
Posts: 13439
Joined: Mon Nov 10, 2008 10:07 pm
Gender: Male
Spoken languages: English
Location: Probably Disneyland Paris... or the UK

Re: Guide: AutoHotkey for Faster Editing

Post by Meph »

Jean Of mArc wrote:
Meph wrote:
Jean Of mArc wrote:Meph, do you intend to use them?
Actually, I've changed my mind. Sorry. :( If it was a Firefox add-on, I would have used it. I don't like these sorts of programs.
To be honest, that doesn't make much sense to me... how could you want to do this if it were a firefox add-on, but not like it if it were a separate program?
It would be much simpler if it were an add-on. Also, I'm worried that the program might affect my computer's start-up time when I log on. :)
User avatar
SuperGanondorf
Posts: 3729
Joined: Sat Nov 01, 2008 6:37 pm
Gender: Male
Spoken languages: American English, learning German
Location: The End of Time

Re: Guide: AutoHotkey for Faster Editing

Post by SuperGanondorf »

Yet another great guide, Jean! I honestly don't see it as being very useful for the AAO editor, but it can be used for a number of other purposes. Thanks!
Main admin of the official AAO Chatroom
Ace Attorneys: Emerging Legacies Team Member
Creator of AAO's #1 Roleplay, Endless Time! Come join today!

It even has a TVTropes page!

Image
ENDLESS TIME: WINNER OF BEST AAO RP
Also the winner of:
Spoiler : Endless Time's Awards :
Coolest Original Weapon or Power: The Relics
Best Villain: Thereme
Most Well-Written Character, Most Original Character Concept, Best Design: Narome (LunchPolice)
Most Depressing Character, Greatest Backstory: Kenneth Roymond (GuardianDreamer)
Greatest RP Moment Ever, Saddest Moment: Narome's Feeding off Mika
Best NPC: The Doctor (ShadowEdgeworth)
Best Fight Scene: Drey Wilkins vs. Narome (Drey Wilkins, LunchPolice)
Best World
Most Eccentric Character: Ewyn (GuardianDreamer)
Best Duo: Narome and Kea (LunchPolice, Paradoxinparticles)
Biggest Crowning Moment of Awesome: The Sabolin Battle
And Best GM: ME ;P
User avatar
Jean Of mArc
Posts: 822
Joined: Fri Oct 22, 2010 2:19 am
Gender: Male
Spoken languages: English, French, Japanese

Re: Guide: AutoHotkey for Faster Editing

Post by Jean Of mArc »

SuperGanondorf wrote:Yet another great guide, Jean! I honestly don't see it as being very useful for the AAO editor, but it can be used for a number of other purposes. Thanks!
Thanks! Though I disagree: my work goes much faster in the AAO editor with keyboard shortcuts. Anyway, I guess this could be seen as a general tutorial to the program, but I wanted to make it relevant to AAO users. Use it as you will!
User avatar
Meph
Posts: 13439
Joined: Mon Nov 10, 2008 10:07 pm
Gender: Male
Spoken languages: English
Location: Probably Disneyland Paris... or the UK

Re: Guide: AutoHotkey for Faster Editing

Post by Meph »

By the way, Jean, what other keyboard shortcuts have you created for the Editor (other than adding SFX tags [#])? :)
User avatar
henke37
Security expert / tools programmer
Posts: 3031
Joined: Wed Mar 04, 2009 9:42 pm
Gender: Male
Spoken languages: Swedish,English
Location: Sweden
Contact:

Re: Guide: AutoHotkey for Faster Editing

Post by henke37 »

The ideal shortcut would be one to make it possible to type away for several frames in a row without using the mouse. Even if said frames have different characters.
Currently working on a redesign of Court-records.net.
User avatar
Meph
Posts: 13439
Joined: Mon Nov 10, 2008 10:07 pm
Gender: Male
Spoken languages: English
Location: Probably Disneyland Paris... or the UK

Re: Guide: AutoHotkey for Faster Editing

Post by Meph »

That's a good idea. You could use Shift + ↑ and Shift + ↓ to switch between frames.
Post Reply