Autohotkey, putting "D89dl" at the end of a sentence doesn't work as intended - autohotkey

I have a Autohotkey script that puts "D89dl" at the end of a sentence everytime I press Enter, but using it with a AutoCorrect script it doesn't work as it should. Let's say you type "dont", it then would look like this "don't" instead of "don't.". Something is blocking it but I'm not sure what it is, I've been trying for months now.
Here are the scripts:
enter::
send,D89dl{Enter}
Return
#Hotstring EndChars -()[]{}:;'"/\,.?!`n `t
::dont::don't
I would be VERY thankful if anyone of you helps me with this.
Overall, do you know any other way instead of Autohotkey that puts "D89dl" at the end of a sentence?

The easiest solution seems to be to use the :*: mode, which will trigger everytime the misspelled word is typed, without the need for Hotstring EndChars:
:*:dont::don't
Instead of using Enter, I suggest you use a special combination of keys that enter the string D89dl and then press Enter. Use a modifier like ctrl or alt and another key. The reasoning is that the key Enter has very important functionality and should not be changed. Pressing that special combination is appropriate, given the very special function it does.

It's a bit hacky, but it should do the job (given that by "end of sentence" you actually meant pressing "Enter"):
~enter::
Sleep, 100
SendInput, {BS}D89dl{Enter}
Return
#Hotstring EndChars -()[]{}:;'"/\,.?!`n `t
::dont::don't

Related

AHK for enter and arrow key

Can't seem to find this simple script anywhere. I'm trying to create a script that runs when the enter and right arrow key is pressed.
Here's what I've tried so far:
{Enter}{Right}::
Send, #tab
return
I know it must be something really simple but can't find the solution anywhere!
Here's the documentation link for hotkeys:
https://www.autohotkey.com/docs/Hotkeys.htm
And in there, after understanding the basics, you're interested in this part of it:
https://www.autohotkey.com/docs/Hotkeys.htm#combo
And assuming by #tab you mean pressing Windows key and the Tab key, you want to look at this page of the documentation:
https://www.autohotkey.com/docs/misc/Remap.htm
(If you wanted to use the Send command, it'd be Send, #{Tab})
You should end up with this:
Enter & Right::#Tab (have to press enter before right arrow key)
And that works, though you're probably going to want to add one little addition, which the ~ modifier.
It'll make it so your Enter key also works on itself while the script is active.
So you'd end up with this:
~Enter & Right::#Tab
Though, now you'll always send a Enter keystroke every time you run the hotkey, which might not be good, I recommend switching it around to:
~Right & Enter::#Tab

Remove the space in the end of text

I'm just starting to learn to use Autohotkey, mostly for text expansion, ie when I type goo and it will become www.google.com. Problem is, in Windows, it always leaves a space in the end and that's annoying. What can I do to avoid that?
I tried added {bs} and {left 1} to the script but it moves the cursor before the last character eg www.google.com
The reason there is a space at the end is because you're pressing space to end your hotstring. If you use the O option, it will omit the ending character. Try this:
:O:goo::www.google.com
More information can be found here in the official help docs: https://www.autohotkey.com/docs/Hotstrings.htm
Found the answer myself! My original code syntax was like this...
::goo ::www.google.com
Doing so leaves a space in the end
I changed it to...
::goo ::
Send, www.google.com
return
Another option is to use :*:goo::www.google.com
The asterisk means that the hotstring will be activated without waiting for you to end the hotstring (though in this case, typing 'good' would pose a problem)

Autohotkey can't handle characters? (BitCoin reward for the answer!)

I have the follow autohotkey map:
^j:: Send ^{PgUp}
This works fine. It maps control + j to control+pagedown.
But I would like to map the keycombination
s & j:: Send ^{PgUp}
So when you press s and j simultaneously, it will send control pagedown to Windows.
Then i'm running into the problem that the character 's' never shows up in my input field, but the character 'j' is appearing as normal. That is weird. The combo key is working, by the way. But I want to get the character 's' key working too.
And are there ways to map the key combination sj (when the both are pressed simultaneously) ?
~s & j::
Send ^{PgUp}
return
was the winning answer by the way, got it from the user RCHP on Autohotkey forum :)
This is by design. The first key of a custom hotkey always loses it's original function. To work around this, create a new hotkey for "s" that sends "s".
In AutoHotKey, hotkeys override their normal function, which is generally desirable. In order to avoid this behavior, prefix your hotkey with a tilde.
~s & j:: Send ^{PgUp} return
The terrific AHK docs explain this.

SendInput %userInput% causes my computer to malfunction oddly

SendInput %userInput% causes my computer to do very weird stuff. Sometimes it logs off, sometimes my arrows of the keyboard get disabled, sometimes it runs cmd in windows an infinite times...
UPDATE:
this is the thing that gets inputed in the command line and runs:
runas /user:administrator cmd
UPDATE:
I think I almost got the problem, as such I edited the question to leave out what I deem to be irrelevant now.
When SendInput is happening, and the user is still inputting data in the keyboard, such as pressing the win-key, then this can cause the system to log off because win-key + l is a shortcut for that. Likewise must be for all the other things that are happening. Another observation is that SendInput skips certain characters, like {enter} etc. It only processes them at the end, when all the regular characters are put into place. I notice that at the end, SendInput is still busy doing stuff, perhaps some exotic characters it delayed till the end. Because the user think the output is complete, he ends up pressing the shortcut key again which in combination with the current sendInput is causing the system to crash.
UPDATE:
It also goes bezerk if there is a "!" to be send with SendInput.
This is one string I pasted to the copyboard:
dsjkfhjdsfsjdh!!!!!!!!!!!####################$$$$$$$$$$$%%%%%%%%%^^^^^^^^^^^^^&&&&&&&&&&&&&*****(((((((((())))))))))))____++++++++++++++++=======------------000000000000000099999988888.
But the output is WITHOUT the exclamation marks. Like this:
dsjkfhjdsfsjdh#######$$$$$$$$$$%%%%%%%%%&&&&&&&&&&&&*****(((((((((())))))))))))____+======------------000000000000000099999988888.
Why is that? Are there any other characters? Exclamation marks are important I feel, and I don't want to remove them. Are there any workarounds?
UPDATE:
It is more complicated than that. When I copy paste the above characters WITHOUT the exclamation marks, it still does weird stuff.
Here is some of the code that eventually userInput combines and sends away with SendInput:
StringReplace, contents, save_selection, ``, ````, All ; Do this replacement first to avoid interfering with the others below.
StringReplace, contents, contents, `r`n, %A_SPACE%, All ; Using `r works better than `n in MS Word, etc.
StringReplace, contents, contents, `;, ```;, All
;* loc_title origanally contains browser specification. Remove it.
StringGetPos, pos_delim, loc_title, - , R
length := StrLen(loc_title)
count := length - pos_delim
StringTrimRight, loc_title, loc_title, count
You could use sendraw instead of sendinput.
Here is what the docs say:
Raw mode: The SendRaw command interprets all characters literally
rather than translating {Enter} to an ENTER keystroke, ^c to
Control-C, etc. However, the normal rules for escape sequences,
variable references and expressions still apply since these are
processed before the command executes. To use raw mode with SendInput,
SendPlay, or SendEvent, write {Raw} as the first item in the string;
for example: SendInput {Raw}abc.
Then you don't have to worry about the ! or other control modifiers.
The reason that the exclamation mark character is an issue is because SendInput treats it as a code to press the Alt key.
There are several similar codes:
^ = Ctrl
+ = Shift
# = Windows key
You can find the others listed in the documentation for SendInput.
It seems like you want to send the raw text and not have SendInput look for these codes. You should be able to put {Raw} at the beginning of the userinput variable and it will ignore any codes in the rest of the characters.
If it is typing too slowly, you could put SetKeyDelay,-1 in your script to remove the key sending delay.
A good workaround that I found was to avoid SendInput altogether. Rather use the clipboard to copy the string inside, to then paste it on your screen. It works flawlessly, and is a billion times faster. Why would a person utilize SendInput in the first place? However, the actual question still is standing, why does SendInput behave so strangely? What is inside that string: %userInput% that causes my system to crash? How can I find out?

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.