Autohotkey 自动热键:通过关联数组替换文本选择
我想使用Autohotkey实现以下行为: 按下Control+Shift+P后,当前选定的文本应替换为存储在字典中的值 我尝试了以下方法:Autohotkey 自动热键:通过关联数组替换文本选择,autohotkey,Autohotkey,我想使用Autohotkey实现以下行为: 按下Control+Shift+P后,当前选定的文本应替换为存储在字典中的值 我尝试了以下方法: ^+P:: Send, ^x ;cut current text selection dict := { "key1" : "value", "key2" : "value 2" } ; associative array Clipboard=%dict%.%Clipboard% Send, ^v ;paste back t
^+P::
Send, ^x ;cut current text selection
dict := { "key1" : "value", "key2" : "value 2" } ; associative array
Clipboard=%dict%.%Clipboard%
Send, ^v ;paste back treated text
但是,它只打印出当前剪贴板内容,前面有一个点。似乎连关联数组都没有创建。我错过了什么?如何检查字典中是否包含键?这将用字典中存储的值替换当前选定的文本
dict := { "key1" : "value", "key2" : "value 2" }
^+P::
Send, ^x
ClipWait 1
send % dict.HasKey(clipboard) ? dict[clipboard] : "???"