1、环境准备
- windows 7,8,10,11操作系统
- ahk 2.x_64位
2、使用方式
encode 对汉字或者是字符编码,decode 对unicode编码的解码成汉字、
- 在运行框中输入:encode 你好呀 ,输出:“\u4F60\u597D\u5440”
- 在运行框中输入: decod e \u4F60\u597D\u5440 ,输出:“你好呀”
- 在运行框中输入:\u4F60\u597D\u5440 ,输出 “你好呀”,运行框可以直接识别“\u”开头的字符为unicode编码
- 表达式按== 触发结果
3、演示
4、代码
#HotIf winActive("运行") and winActive("ahk_class #32770")
#MaxThreadsPerHotkey 10
;在运行框中执行强大的计算功能,包括数学运算等
:*?:==::{
try{
rawText:=ControlGetText("Edit1","A") ;
fullResult:=runbox.calculateExpression(rawText)
if fullResult{
ControlsetText(fullResult,"Edit1","A")
}
ControlSend("{END}","Edit1","A")
}
}
#HotIf
;==========================================================================================================系统快捷键映射
;执行各种运算取值
class runbox
{
;定时器
static spycmdTimer:=ObjBindMethod(this, "spyCmd")
;spy显示信息
static spytext:=""
;执行比表达式计算,"==" 触发,callflag是其他函数调用该方法
static calculateExpression(rawstr,callflag:=0)
{
;把字符转换为uncode编码
if inStr(rawStr,"encode ")==1{
result:=this.charcodeExpression(Trim(LTrim(rawStr,"encode")),1)
return result
}
;把字unicode编码转换为字符串
if inStr(rawStr,"decode ")==1 or inStr(rawStr,"\u")==1{
result:=this.charcodeExpression(Trim(LTrim(rawStr,"decode")),0)
return result
}
}
;计算编码,默认编码,0表示解码
static charcodeExpression(str,encode:=1)
{
if encode{
result:=ak.encodeUtf8(str)
}else{
result:=ak.decodeUtf8(str)
}
return result
}
}
;==========================================================================================================系统快捷键映射
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ak工具类class
class ak
{
;Func对中文编码进行unicode编码
static encodeUtf8(str)
{
resultStr:=""
Loop Parse, str {
resultStr:=resultStr . "\u" . String(Ord(A_LoopField)>0x100 ? Format("{:04X}", Ord(A_LoopField) ):A_LoopField)
}
return resultStr
}
;Func 对中英文unicode进行解码
static decodeUtf8(str)
{
ret:="",aStr:=subStr(str,1,inStr(str,"\u")-1),bStr:=subStr(str,inStr(str,"\u")),arr:=strSplit(bStr,"\u")
for k in arr{
ret:=k?ret . chr(Abs("0x" . subStr(k,1,4))) . subStr(k,5):""
}
return aStr . ret
}
}
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ak工具类class
5、总结
当然运行框中字符有限,手动输入只能到250字符左右、如果大量文字可以放到txt记事本中!
完整功能参考:windows超级运行框-表达式计算(12)汇总
各位大佬觉得还可以怎么操作? 欢迎评论区留言讨论!