这个程序是按照xeval的功能用AHK重新实现的。
原有的xeval程序(xeval 可扩展实时计算工具 v1.0)请参见王咏刚的个人网站,2004年的网页,不知道现在是否还在了。
因为AHK本身对热键支持很好,所以实现起来比较简单,代码只有C++版本的1/5。
这里修改了热键的定义方式,主要为了方便实现:
!表示shift键
^表示ctrl键
AHK源代码如下:
; Yet Another xeval
; Author: bilbo
; Create Date: Nov 04, 2007
; Modified Date: Nov 07, 2007
; Description:
; similar to xeval, autohotkey implementation.
#persistent
;程序名和关于字符串
progname = Yet Another Xeval
version = Version : 1.0
author = Author : Bilbo
datestring = Date : Nov 04, 2007.
;创建系统托盘菜单
Menu, Tray, NoStandard
Menu, tray, add, 帮助(&H)..., Readme
Menu, tray, add, 关于yaxeval(&A)..., HelpAbout
Menu, tray, add ; Creates a separator line.
Menu,Tray,Add, 退出(&X), ProgramExit
Menu, Tray, Click, 1
Menu, Tray, Tip, %title%
;分析配置文件
progcount = 0
FileRead, All, yaxeval.cfg
Loop, Parse, All, `n, `r
{
If RegExMatch(A_LoopField, "^#.*", Match)
{
; skip comments
}
else
{
if (strlen(A_LoopField) = 0)
{
; skip null line
}
else
{
StringSplit, extprog, A_LoopField, `,
progcount += 1
currentprogname = %extprog1% ;trim the spaces
hotkeystring = %extprog2% ;trim the spaces
; 动态加载热键
Hotkey, %hotkeystring% , MyLabel
prog%progcount% := currentprogname
key%progcount% := hotkeystring
}
}
}
return
!h::
Readme:
msgbox, open readme file
return
!x::
ProgramExit:
GuiClose: ; User closed the window.
ExitApp
return
!a::
HelpAbout:
Gui, 2:Add, Text,, %progname%
Gui, 2:Add, Text,, %version%, %author%, %datestring%
Gui, 2:Add, Button, Default w300, OK
Gui, 2:Show,,About
return
2ButtonOK: ; This section is used by the "about box" above.
2GuiClose:
2GuiEscape:
Gui Destroy ; Destroy the about box.
return
;Hotkey action
MyLabel:
Loop, %progcount%
{
if (key%A_Index% = A_ThisHotkey)
{
name := prog%A_Index%
FileDelete, ext.in
Send ^c
FileAppend, %clipboard%`n, ext.in
FileDelete, run.bat
FileAppend, %name% < ext.in > ext.out, run.bat
runwait, run.bat, ,hide
FileRead, result, ext.out
clipboard = %result%
Send ^v
}
}
return
可执行程序可从下面的链接下载:
 |
| 文件: | yaxeval.rar |
| 大小: | 279KB |
| 下载: | 下载 |
|