autohotkey: go to a specific place in a line - autohotkey

I have a long mermaid code line like
A("hello world, this is a really long sentence that needs editing"):::test %% here are some commments about the line
I'm editing this in obsidian and I want to go to the end of the ) to change the :::test to something else.
What I'm trying to accomplish is to press use AHK to press a key that will take my cursor to after the ). Right now, I can press end and go back wards, or ctrl arrow, both options suck when the code line is really long and the ) is right in the middle.
can AHK do something like this?

this works in obsidian, probably works in most apps
!\::
Send {home}
Send ^f
Send )
Send {esc}{esc}
return

Related

How can I make AutoHotKey script execute its function with multiple hotkeys?

LButton::
^LButton::
While GetKeyState("LButton","p"){
Send {LButton}
Sleep 20
}
return
This is my current script. What it does is when I hold the left mouse button it simulates pressing it repeatedly every 20 milliseconds. But, because in the game I use it with I often have to hold Alt down to crouch I need it to work with ^LButton. But for some reason, when holding alt+LButton it just acts normally i.e. it reverts to me holding down the left mouse button.
One thing I thought of is possibly adding
While GetKeyState("LButton","p") or GetKeyState("alt LButton","p"){
However I am lacking proper syntax to pass a modifier along with a button to the GetKeyState function.
I searched through the documents and did a bit of googling but it seems like the AHK forums have been inactive for around 5 years now. If anyone knows how to solve this issue your help would be appreciated!
#CherryDT Thanks for the quick response. I actually think I was just googling the wrong because I have solved it.
The trick is that with mouse buttons, you have to use a different syntax and also there is a precedence to the order in which the combination is pressed.
LButton::
Alt + LButton::
etc...
Again, thanks for the response :)

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

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

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

autohotkey long text and in a virtual machine

So I'm trying to learn autohotkey scripts and the documentation is lacking at best. First, can authotkey read commands and perform actions and such inside a virtual machine? I have a windows host and a linux virtual machine running eclipse. I'd like to get a hostring (or a keyboard macro, either is fine) to put in some long (10+ lines) of text. Can that actually work in a VM or do I have to run autohotkey inside the VM for it to work?
As for implementing this, I have 2 problems. First, how do I display multiple lines of text from a keyboard macro? I know about the Send command, but I haven't figured out how that works. I have this:
:*:insert::
(
Text to
insert
goes here
and more here
)
And this works fine except in notepad++, it inserts consecutively more tabs, so it will look like
Text to
insert
goes here
and more goes here
And so in my many line macro, by the end it's several pages scrolled off the screen.
As for keyboard macro, changing the above to
#c::
Send{Raw} (
stuf
to send
)
Return
This gives syntax errors and I have no idea what the correct way of doing that would be. Should I just stick with using hotstrings?
You could try to modify the clipboard and use control + v to paste it into the proper place.
Try:
#c::
{
clipboard := "yourtext`nMultiline`nYet another line"
send, {control down}v{control up}
return
}
The first 'insert' hotstring is correct,
however, you would get the same result that you describe,
if you performed manually, the keypresses that the hotstring is sending.
To get the output you want,
you need to change these two settings:
Settings, Preferences...,
Auto-Completion,
untick: Enable auto-completion on each input
Settings, Preferences...,
MISC.,
untick: Auto-indent
the '#c' hotstring is amended below:
#c::
Send {Raw}
(
stuf
to send
)
Return

Autohotkey to select text under cursor?

Is it possible to select text under cursor using Autohotkey specifically, using a mouse and a key combination. e.g. I specifically want to just do a Ctrl-click on any word in IE/FF/Foxit Reader and a webpage with first Google search result opens up.
Thank you.
Yes it is possible...
The easiest way is to set Ctrl+LButton to double click (which selects the current word under the cursor) copy the word to the clipboard and then use google with the parameters "q=" for the search term and "btnI=I'm+Feeling+Lucky" for using the "I'm Feeling Lucky" function.
It would look like this:
^LButton::
Send, {LButton 2}^c
Run, http://www.google.com/search?&q=%clipboard%&btnI=I'm+Feeling+Lucky
return
This would work in most cases without issues, the issue comes when selecting words like:
53°C
Jhon's
test%s
and others, because double clicking them only selects the first part of the text before the symbols.
So as long as you are double clicking normal words this should work fine.