How to detect if a user writes a specific sentence? - autohotkey

So, I want to detect if a user writes a specific sentence on the keyboard, and if so afterwards perform a function.
For example, if the user writes:
if user types /hello
script activates and for example puts out
Send, Hello. How are you today?

According to the documentation for Hotstrings, your example would look like this:
::if user types /hello::Send, Hello. How are you today?
Although, this requires typing an additional "ending character" such as a space or tab to trigger the transformation.
To immediately replace the text after entering the last character you add the * option:
:*:if user types /hello::Send, Hello. How are you today?

Related

How to remap Tab key to two dots/period key presses

I want to map two dot/period key presses to Tab key in AutoHotkey script. I tried to map similarly as its shown for remapping semicolon key - on AutoHotkey forums, but it doesn't work. I tried following:
1. `..`::Tab
2. ..::Tab
AutoHotkey gives an error
.
I tried searching on AutoHotkey Remap docs, but couldn't figure it out. The period key is the one with the greater than mark and not the number keypad period key. See this: Dot/period key
Addition info/context in response to reply by user 0x464e:
Basically, I am trying to expand Emmet style abbreviations in devtools style sub-panel since the chrome devtools team wont implement it.
I am not a fast typist, so it's a pain to type complete property names. For example, if I want to type margin-top, (see the image), Chrome autocomplete brings up margin, margin-block margin-block-end etc.
Now, for margin-top, you need to at least type margin-t to get the autocomplete to show that property.
This is the case for many very common CSS properties like margins, paddings, etc., so autocomplete isn't great.
On the other hand, if I just type mt and have Autohotkey expand to margin-top, it's much much faster, saves me much time and keeps me sane.
Basically, I have setup some hotstring in .ahk script and they work too.
However, if I press mt followed by a Tab key press, Chrome's autocomplete takes over and hotstring fails, (try once to see the problem). Instead, currently I press spacebar, or . (period) to trigger the hotstring. It works, but the problem is it leaves a space or a dot with the expanded text. [see this].
So, that's the actual reason I wanted a double period key trigger to replace Tab.
It would be great if the hotstring trigger would work with a double period key, but doesn't leave the trigger character itself and then have send Tab so as to jump to the value input of the just expanded property.
You're not really looking for a traditional remap, which is why you didn't find it from the documentation.
Remapping is just simply remapping one key to another, but you're not trying to do that. You're trying to make some action do another action.
Anyway, what you're asking is doable, but there's loads of different ways it can be achieved with difficulties varying from simple to extremely advanced & complicated.
You'll need to specify things more clearly before this can be answered properly.
Biggest questions that pop into my head right away are at least:
Should this work everywhere, or just in text input fields?
How should the original functionality of . be preserved, if at all.
(What should happen after the initial . keypress?)
Should there be some timeout between the keypresses?
Etc, this is just what I could think of right away, but surely there's more.
Anyway, for now I can give a simple implementation with a hotstring:
:*?:..::{Tab}
So this is a hotstring with the * and ? options.
I'm guessing these would probably be pretty good options for this.
So what this does, is it presses backspace twice and sends a Tab if you type ...
This should be fine for text editors, but it leaves much to be desired (the points I listed above aren't considered since I can't know what you're looking for. This is just what a default simple hotstring can offer).
Looks to me like you don't actually want the additional mapping of .. to Tab, but instead just want to update your existing hotstrings to activate immediately (without waiting for an EndChar) when the hotstring is followed by ..
Normally, you might look to the Ending Characters option to create this functionality, but since you want multiple characters to trigger this, we need to look to other options.
I will be using the example of ::mt::margin-top for my sample implementation. Extend any changes I make to these to the rest of your hotstrings in the script you screenshotted.
Here are the changes I am making to this example:
Add your .. to the end of each of your hotstrings triggers. For example ::mt::margin-top becomes ::mt..::margin-top. However, at this present, this still requires some sort of ending character to be pressed in order to proc. Let's fix that in the next step
Add the Asterisk Modifier to the hotstring. From the docs:
* (asterisk): An ending character (e.g. Space, ., or Enter) is not required to trigger the hotstring.
Final code for ::mt::margin-top example:
:*:mt..::margin-top
And extend this * insertion and .. appendation to each of your hotstrings.
Hope this helped! Lmk if you need any more help or changes.

AutoHotkey send without replacement

I'm using AutoHotkey. Is there a way of using "Send" without getting the previously wirtten Hotstring replaced?
So if I want to use the Hotkey System it always overrides the System with the text I set after "Send". But how can I achive that it is just appending my Send text to the hotstring?
Send, Hotstring Rest of Things You Want to Say
I think you may be mistaken in what you're trying to say or how you're using Send, as it doesn't replace previously written hotstrings. If you post an example of what you're saying, it will be easier to help. Also, what do you mean when you say "Hotkey System"?
Helpful info from the online documentation, Hotkeys & Hotstrings.
EDIT (per your comment below):
I understand what you're saying now. This is the default way that hotstrings work and has nothing to do with using the Send command. If you want to keep the activating text in a hotstring, you need to use the B0 option. Something like this:
:*B0:System::.out.println()
Note that the * makes it so you don't need to type a period after "system". If you want it to work that way instead, remove the asterisk.

hotstring to turn Mr into Mr. and Mrs into Mrs

Microsoft Word red-flags my Mr and wants to change it to Mr. and Mrs. every time. Since I have gotten used to typing Mr and Mrs, I want to use Autohotkey to change it automatically as I type...
Right now, I have:
:c*:Mrs::Mrs.
:c*:Mr::Mr.
But as you can probably guess, when I type Mrs it changes to Mr.S because of the Mr command, and the Mrs command is never called
Is it possible for me to get it to type Mrs. when I type Mrs, and Mr. when I type Mr?
Reading the docs on Hotstrings and comparing your code I see that you have * option which is triggering your hotstring immediately, this removes the need for a End Character (default is space, enter, tab) to trigger the hotstring replacement. To correct this behavior simply remove the *
:c:Mrs::Mrs.
:c:Mr::Mr.
Like ahkcoder, but I would have used an extra space and replaced the space with an asterisk.
:*:mr ::Mr. `
:*:mrs ::Mrs. `
By not using :c:, this makes it case independent.
Within Word, you could have used auto correct as well.

How to open a file without typing its entire name?

I want to be more comfortable with CLI, so I need practice. :D
I have a directory and within it I have more of them. I use ls to find their name, but the one I want to change into has a very long name.
Is it possible to change to that directory without typing his entire name?
Try to type few chars of that name and press Tab once to complete that name.
If it doesn't complete, press Tab twice to see available names that start with the character sequence that you entered. Then, add few more chars, so that sequence is unique for that name and press Tab to complete.

AutoHotKey script activates only on numpad enter

My script is only activating when I press the numpad enter, is it possible for it to work if I press the big enter?
Here is what I have, when I type test + numpad enter then it invokes ctr+shift+u
:*:test`n::test^+u
I need the other enter to work or both if possible.
Thanks
I tried this:
:*:test`n::bob
And it types bob no matter which enter key I push. If you use n, that doesn't necessarily indicate that you are pushing anyenterkey - it just means you are inserting a carriage return - so eitherenter` key will do that. But your text area must be able to receive and insert a carriage return.
That means, that if you are working in a single-line text box, it can't receive a carriage return, in which case, using `n won't work for you.
You might also assure that the active window is able to receive ^!u and do something with that.