1、环境准备
- windows 7,8,10,11操作系统
- ahk 2.x_64位
2、使用方式
uuid/cpuid 用于获取随机值,和cpu的序列号
- 输入win+R打开windows运行框
- 在运行框中输入:cpuid ,输出cpu的序列号
- 在运行框中输入:uuid ,输出随机值
- 表达式按== 触发结果
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
{
;执行比表达式计算,"==" 触发,callflag是其他函数调用该方法
static calculateExpression(rawstr,callflag:=0)
{
;获取cpuid
if strLower(trim(rawStr))=="cpuid"{
cpuid :=ak.cpuid or ak.getCpuid()
fulltxt:= rawStr . "=" . cpuid
return cpuid
}
;获取uuid随机值
if strLower(trim(rawStr))=="uuid"{
uuid:=ak.uuid()
fulltxt:= rawStr . "=" . uuid
return uuid
}
}
}
;==========================================================================================================系统快捷键映射
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ak工具类class
class ak
{
static cpuid:=""
;Func获取cpuid,需要在脚本开始阶段就执行
static getCpuid()
{
query := "SELECT * FROM Win32_Processor"
wmi := ComObjGet("winmgmts:\\.\root\cimv2")
col := wmi.ExecQuery(query)
for obj in col {
return this.cpuid:=obj.ProcessorID
}
return ""
}
;Func 生成32位UUID来源于guid
static uuid()
{
shellobj := ComObject("Scriptlet.TypeLib")
return RegExReplace(shellobj.GUID,"({|}|-)","") ;去掉花括号和-
}
}
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ak工具类class
5、总结
cpuid获取比较耗时,我们可以在脚本开启时异步获取
完整功能参考:windows超级运行框-表达式计算(12)汇总
各位大佬觉得还可以怎么操作? 欢迎评论区留言讨论!
打破0回复