如何解决执行热键时缺少字符
我正在写一个热键快捷方式来在wordpress中突出显示文本。代码是这样的:
^f2::
Send,^x [su_highlight background="#DDFF99" color="#008000" class=""] ^v [/su_highlight]
return
但是,当我在字符串上执行它时,我们称它为string1,它会返回
[su_highlight background =“ DDFF99” color =“ 08000” class =“”] string1 [/ su_highlight]。
有人能解释为什么“#”消失以及颜色0之一消失了,我该如何解决?
谢谢!
解决方法
这是因为在使用“发送”时,“#”被视为Windows键,因此您需要对其进行转义
来自The #EscapeChar Documentation page:
在默认情况下使用发送命令或热字符串时 (非原始)模式,诸如{} ^!+#之类的字符具有特殊含义。 因此,要在这些情况下按原样使用它们,请将它们包含在 大括号。例如:发送{^} {!} {{}。
因此,修改后的代码为:
^f2::
Send ^x [su_highlight background="{#}DDFF99" color="{#}008000" class=""] ^v [/su_highlight]
return
编辑:或者,如果您不想每次都要键入文字#(或其他受影响的字符)时都不必换掉某些字符,则可以改用SendRaw命令。
例如:
为命令和文本使用单独的发送
^f2::
Send ^x
SendRaw [su_highlight background="#DDFF99" color="#008000" class=""]
Send ^v
SendRaw [/su_highlight]
return
有关SendRaw的更多信息,请访问the Documentation link for SendRaw。
,要添加其他答案,我建议使用Text mode而不是其他任何模式。因为它可以与SendInput结合使用,所以建议使用更快,更可靠的发送模式。
所以:
^F2::
SendInput,^x
SendInput,{Text}[su_highlight background="#DDFF99" color="#008000" class=""]
SendInput,^v
SendInput,[/su_highlight]
return
尽管如此,通过发送命令发送的时间开始变长了(我认为)。
考虑更多地使用剪贴板以获得更快,更可靠的选择:
^F2::
Clipboard := "" ;empty the clipboard first
;send ctrl+x (cut),ctrl+v could be used in most text editors as well
SendInput,^x
;wait for the clipboard to contain something
;this is not required and it will likely work without it
;but it's kind of recommended I guess
ClipWait
;set the clipboard to contain what we want
Clipboard := "[su_highlight background=""#DDFF99"" color=""#008000"" class=""""]" Clipboard "[/su_highlight]"
;send ctrl+v
SendInput,^v
return
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。