stefax
stefax

Reputation: 171

AutoHotkey hotstrings don't work correctly in eclipse

I use AutoHotkey for all sorts of texts that I use often, so among signatures or often used mail texts I also store some code snippets there for quick usage.

Some of those hotstrings work fine in editors like wordpad or ultraedit but in eclipse (my version is 3.6.1) they do not remove the hotstring correctly.

Very simple example:

As said, this works fine in lots of editors, but not in eclipse, where parts of the hotstring - e.g. #ec - remain in front of the output, the hotstring is not removed completely. The strange thing is, sometimes it leaves 1 letter, sometimes 3, without any obvious logic.

In my AutoHotkey file foo.ahk I have some code like this:

::#echo::
InputBox, VAR, User input, Please enter the variable VAR., , 320, 130
SendInput,
(
<?php echo(%VAR%); ?>
)
Return

As a newbie with AutoHotkey I had some other problems before, which I could solve, so they should not be the source of the described problem.

I have no idea what the reason for the eclipse problem could be, any hint is appreciated.

Upvotes: 2

Views: 1221

Answers (2)

tumchaaditya
tumchaaditya

Reputation: 1297

Why insist on hotstrings? You can use a weird hotkey instead(like Alt+Windows+V)

!#v::
InputBox, VAR, User input, Please enter the variable VAR., , 320, 130
SendInput,
(
<?php echo(%VAR%); ?>
)
Return

Upvotes: 0

Gary Hughes
Gary Hughes

Reputation: 4510

I've just tried this out myself and saw the same behaviour. For me, switching to the SendPlay mode rather than SendInput fixed made things work perfectly.

Add the line:

#Hotstring SP

just before the code you posted and see if that resolves the issue.

Have a look at the '#Hotstring' command in the documentation for more information as well as the Options section of 'Hotstrings and Auto-replace'.

UPDATE

Ok, try this:

#Hotstring B0

::#echo::
SendInput, {Control Down}{Shift Down}{Left 2}{Control Up}{Shift Up}
InputBox, VAR, User input, Please enter the variable VAR., , 320, 130
SendInput,
(
<?php echo(%VAR%); ?>
)
Return

The '#Hotstring B0' line will prevent AutoHotkey from doing the backspaces by itself. The first SendInput line will send Ctrl-Shift-Left twice to select the typed '#echo' text which will then be replaced by the second SendInput after the InputBox.

It's a little more hacky and you may need to change the number in '{Left 2}' to something else depending on how you use it, but this also works fine for me.

Upvotes: 1

Related Questions