简体   繁体   English

AutoHotkey热字符串在Eclipse中无法正常工作

[英]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. 我将AutoHotkey用于我经常使用的各种文本,因此在签名或经常使用的邮件文本中,我还在其中存储了一些代码片段以便快速使用。

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. 其中一些热字符串可以在写字板或Ultraedit等编辑器中正常工作,但在Eclipse(我的版本为3.6.1)中,它们不能正确删除热字符串。

Very simple example: 很简单的例子:

  • I type #echo 我输入#echo
  • I get a variable prompt 我得到一个可变提示
  • I provide the string $myVar 我提供了字符串$ myVar
  • The string is inserted in the current file 字符串已插入当前文件中

As said, this works fine in lots of editors, but not in eclipse, where parts of the hotstring - eg #ec - remain in front of the output, the hotstring is not removed completely. 如前所述,这在许多编辑器中都可以正常工作,但是在eclipse中却不能,在eclipse中,热字符串的某些部分(例如#ec)保留在输出的前面,热字符串并未完全删除。 The strange thing is, sometimes it leaves 1 letter, sometimes 3, without any obvious logic. 奇怪的是,有时留下1个字母,有时留下3个字母,没有任何明显的逻辑。

In my AutoHotkey file foo.ahk I have some code like this: 在我的AutoHotkey文件foo.ahk中,我有一些类似以下的代码:

::#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. 作为AutoHotkey的新手,我之前可以解决其他一些问题,因此这些问题不应成为所描述问题的根源。

  • Scripts with special characters like German Umlauts have to be encoded in UTF8 具有特殊字符的脚本(例如德国Umlauts)必须使用UTF8编码
  • Scripts or compiled scripts have to be run as administrator 脚本或编译脚本必须以管理员身份运行

I have no idea what the reason for the eclipse problem could be, any hint is appreciated. 我不知道月食问题的原因是什么,任何提示都值得赞赏。

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. 对我来说,切换到SendPlay模式而不是固定使用SendInput可以使一切正常运行。

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'. 请参阅文档中的“ #Hotstring”命令以获取更多信息,以及“ Hotstrings和自动替换”的“选项”部分。

UPDATE 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. “ #Hotstring B0”行将阻止AutoHotkey自己执行退格键。 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. 第一行SendInput将发送Ctrl-Shift-Left两次,以选择键入的“ #echo”文本,然后将其替换为InputBox之后的第二个SendInput。

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. 这有点hacky,您可能需要根据使用方式将“ {Left 2}”中的数字更改为其他名称,但这对我也很好。

Why insist on hotstrings? 为什么要坚持热钱? You can use a weird hotkey instead(like Alt + Windows + V ) 您可以改用奇怪的热键(例如Alt + Windows + V

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM