“热键”的极致演绎,从Hoekey到AutoHotkey


2009-08-05 09:19



话说Hoekey这个软件我已经用了很长时间,年代久远到实在无从考证。而软件本身的存在早已被我淡忘,只在偶尔重装系统时才会发现,原来它并不是Windows的一部分。

  回头来细致观察Hoekey,发现它非常符合我对工具软件的审美观:Tiny、Efficient and Creative! 仅仅18k的身段、200k余的内存占用,包罗万象的热键功能…… 我对Hoekey的感觉可以归为“一见钟情”、“相见恨晚”的那一类,甚至会觉得没有Hoekey的IT人生是不完整的。

  前些天偶然间在水木Desktop版上看到有人提起AutoHotkey(AHK),听名字似乎与Hoekey同属“热键”增强类的工具,于是就饶有兴致的研究了一番。下载时已然觉得数M的AHK显得有些臃肿,再看源码,竟然有近5M!虽然第一印象上就大打折扣,但既然下载了好歹还是要试一试吧。好在主程序只有230k(其它附加的工具和脚本就不小了),第一次启动完后,自动弹出Notepad,打开的是它的配置文件,那种似曾相识的感觉~ 呵呵,看来又是一个可高度定制的热键工具!

  如果用娇俏可人的小家碧玉来形容Hoekey的话,那么AHK便是那琴棋书画样样精通的大家闺秀了。

  粗略的看了一下AHK的帮助文件,不禁为其庞大的API库所震慑。AutoHotkey这个名字实在算是谦虚,论功能,AHK早已远远超越Hotkey的范畴。就拿其提供的范例Script为例,比较典型的:

LiveWindows: Watch Dialog-boxes in Thumbnail — by Holomind: This script allows you to monitor the progress of downloads, file-copying, and other dialogs by displaying a small replica of each dialog and its progress bar (dialogs are automatically detected, even if they’re behind other windows). The preview window stays always-on-top but uses very little screen space (it can also be resized by dragging its edges). You can also monitor any window by dragging a selection rectangle around the area of interest (with control-shift-drag), then press Win+W to display that section in the preview window with real-time updates.

Mouse Gestures — by deguix: This script watches how you move the mouse whenever the right mouse button is being held down. If it sees you “draw” a recognized shape or symbol, it will launch a program or perform another custom action of your choice (just like hotkeys). See the included README file for how to define gestures.

Easy Access to Favorite Folders — by Savage: When you click the middle mouse button while certain types of windows are active, this script displays a menu of your favorite folders. Upon selecting a favorite, the script will instantly switch to that folder within the active window. The following window types are supported: 1) Standard file-open or file-save dialogs; 2) Explorer windows; 3) Console (command prompt) windows. The menu can also be optionally shown for unsupported window types, in which case the chosen favorite will be opened as a new Explorer window.

Volume On-Screen-Display (OSD) — by Rajat: This script assigns hotkeys of your choice to raise and lower the master and/or wave volume. Both volumes are displayed as different color bar graphs.

Window Shading (roll up a window to its title bar) — by Rajat: This script reduces a window to its title bar and then back to its original size by pressing a single hotkey. Any number of windows can be reduced in this fashion (the script remembers each). If the script exits for any reason, all “rolled up” windows will be automatically restored to their original heights.

  其中的任何一个倘若作为独立的工具都可算是非常出色了,实在难以想象他们竟然都是以AHK内置的脚本语言所编写的。简单试用了两天后,我彻底为AHK所折服了,能将一款热键工具演绎到如此程度,实在不单单对得起那230k的身躯,哪怕让我割舍50M内存与之也会毫不犹豫。

  我只用AHK写了一个简单的脚本,就一举解决了Creative Live!声卡的EAX音效无法通过热键调整的弊端,让这个头疼已久的问题迎刃而解!

#SingleInstance
#/:: ; Hotkey: Win+/
DetectHiddenWindows, On
IfWinNotExist, ahk_class CT_SMXWND
Run, "C:/Program Files/Creative/SurMix2/SurMix2.exe",, Hide
WinWait, Creative Surround Mixer 2, EAX Effects
ControlSend, ListBox1, {Home}, ahk_class CT_SMXWND
Sleep, 100
;WinClose, ahk_class CT_SMXWND
DetectHiddenWindows, Off
注:上述脚本暂时只实现了关闭EAX音效,以后有时间再来完成余下的功能,说不定可以实现一个OSD热键控制的EAX选单呢,再说不定还能实现Context-sensitive~ :)

  当然,Hoekey的一些优点还是AHK目前所暂时无法替代的(可能是我的理解程度不足,AHK实在给人有些深不可测的感觉),比如“Hide to tray”,“Kill current process”。所以现下小乔、大乔权且共寄檐下,倒也相安无事。:)

http://www.newsmth.net/pc/pccon.php?id=10&nid=26866

发信人: Machael (Special Striving For), 信区: NewSoftware
标 题: 顶力推荐:超级好用,超级强大的热键软件
发信站: BBS 水木清华站 (Thu Apr 29 14:41:07 2004), 站内

前言:
它小巧(13k),但是功能强大
它绿色,却又完全免费,
它可以把M$留给我们的一点点应用接口,运用得出神入化,调制出一键走天下的超级设置
它究竟是神仙的化身?还是地狱的使者?没人知道,但是可以肯定,每个人都给他一个称号───Hoe~Key!.

看看我用它热键设置的功能吧:
win+F12: TC,win+F11: FlashFXP,
win+F10: MyIE,win+N: Notepad,win+end: 缩小当前窗口到托盘中,win+home: 恢复最后一个隐藏的窗口,
win+Y: 显示当前窗口可以Copy的文字,win+S: cmd.exe并进入当前目录,win+~: 关闭显示器,
win+K: 杀掉当前进程,win+up: 最大化当前窗口,win+down: 恢复当前窗口.....

打包中的hoekey.ini是我设置的,一般人应用够了,如果觉得不够爽可以恢复缺省带的ini
更多更高级的功能设置需要看帮助了,不看不知道,实在是强.推荐推荐再推荐!

 

 

----->   hoekey.ini

;   HoeKey config - example from a12b4
;
; key modifiers:
; ~=windows, _=shift, ^=ctrl, @=alt
;

; some general good stuff
-=Rem|-- General --
~Q=Config
~end=Hide||1             ; win+end: hide current window
~_end=Hide||2             ; win+end: hide current window
~home=Unhide          ; win+home: show last hidden window
~Y=Editify            ; show text from window for copy
~N=Run|notepad.exe    ; Notepad
~_S=Run|cmd.exe|||%c ; Command shell in curdir
~S=Run|cmd.exe        ; Command shell
;_^R=RunDialog|%c
~_E=Run|explorer.exe %c ; explorer in current directory

~4=Transparency          ; set current window to be transparent and on top
=AlwaysOnTop
~`=Run|rundll32.exe user32.dll,LockWorkStation    ; win+tick: lock workstation
_~`=Run|rundll32.exe powrprof.dll,SetSuspendState ; win+tilde: suspend / hibernate

~^`=Wait|1000            ; turn monitor off
=Msg|Progman|274|61808|2

_^E=Keys|/a/0/1/2/8/A    ; euro symbol
~_^@K=Kill;~up=Msg||274|61488      ; win+up: maximize current window
;~down=Msg||274|61728    ; win+down: restore current window
~page down=Msg||274|61472    ; win+pgdn: minimize current window

-=Rem|-- WWW stuff --
~I=Input|Google search:|Moz tacular||%s ; Prompted Google
=Run|"http://www.google.com/search?q=%u"
~1=Run|http://translate.google.com/translate_t?langpair=en|fr&text=%s ; xlate selection english->french
;~2=Run|http://translate.google.com/translate_t?langpair=fr|en&text=%s ; xlate selection french->english
~G=Run|http://www.google.com/search?q=%s                              ; search google for selection
_~G=Run|http://www.google.com/search?btnI=I'm+Feeling+Lucky&q=%s      ; lucky google search selection
~3=Run|http://dictionary.reference.com/search?q=%s                    ; look up selection in dictionary
~_3=Input|Look up word:|Dictionary.com||%u ; prompted dictionary lookup
=Run|http://dictionary.reference.com/search?q=%u

-=Rem|-- Sound --
_~1=Volume||0   ; volume: 0%
_~2=Volume||10 ; volume: 10%
_~4=Volume||30 ; volume: 30%
_~5=Volume||42 ; volume: 42%
_~6=Volume||57 ; volume: 57%
_~7=Volume||70 ; volume: 70%
_~8=Volume||80 ; volume: 80%
_~9=Volume||90 ; volume: 90%
_~0=Volume||100 ; volume: 100%
~up=Msg|Progman|793|0|655360   ; win+up: vol up
~down=Msg|Progman|793|0|589824 ; win+down: vol down

; Winamp keys
-=Rem|-- Winamp --
~W=Run|c:/program files/Winamp5/winamp.exe ; Winamp: start/activate

~Z=Msg|Winamp v1.x|273|40044 ; Winamp: prev
=Msg|WMPlayerApp|793|0|786432 ; WMP - prev
~X=Msg|Winamp v1.x|273|40045 ; Winamp: play
=Msg|WMPlayerApp|793|0|851968 ; WMP - Stop
~C=Msg|Winamp v1.x|273|40046 ; Winamp: pause
=Msg|WMPlayerApp|793|0|917504 ; WMP - Pause
~V=Msg|Winamp v1.x|273|40048 ; Winamp: next
=Msg|WMPlayerApp|793|0|720896 ; WMP - next

177=Msg|Winamp v1.x|273|40044 ; Winamp: prev
178=Msg|Winamp v1.x|273|40047 ; Winamp: stop
176=Msg|Winamp v1.x|273|40048 ; Winamp: next

179=Msg|Winamp v1.x|273|40046 ; Winamp: pause
=Msg|Winamp v1.x|1024|0|104|0 ; see if playing
=Msg|Winamp v1.x|273|40045 ; stopped, so push play

; * win+V rather than win+B as WinXP explorer uses win+B to focus systray
~A=FocusMsg|Winamp v1.x|273|40188         ; Winamp: about current song
~J=FocusMsg|Winamp v1.x|273|40194         ; Winamp: jump to song
~7=FocusMsg|Winamp v1.x|273|23123         ; Winamp 2.9+: Show media library

-=Rem|-- Nonsense --

~^E=Kill|progman ; restart explorer
=Run|explorer.exe

~f2=Eject|f         ; eject d: cd rom
~f3=Msg|0|274|61760 ; start screensaver
~f4=Apps            ; show list of hidden apps

;
; More Examples:
;

; Show current window title and classname
~9=MsgBox|Window Title:[%t] -- Classname:[%l]

; Disable hotkeys, run notepad, re-enable hotkeys
;~9=Enable
;=Run|notepad.exe||1
;=Enable|1

; Move current window to left side of 1024x768 screen:
; ~9=Move||0|0|512|-30

; Move current window to right side of 1024x768 screen:
; ~^9=Move|||512|0|512|-30

; Center current window:
; ~6=Keys|/c/p/Cu
;Center

; Popup start menu, choose programs
; ~8=Keys|/wp/W

; Use different program for config of HoeKey (automatically disables hotkeys during config):
;config=Run|notepad %i||1

; Show icon in system tray for HoeKey, double click to bring up hoekey config
;load=trayicon|1

; You can override explorer hotkeys (win+B, win+D, win+E, win+F, win+R, win+L, win+M, win+U)
; for winxp: use regkey:
;   [HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Policies/Explorer]
;   "NoWinKeys"=dword:00000001
; for win95/98/me? you can stop explorer, reload hoekey config, restart explorer
;~E=Run|explorer.exe
;~R=RunDialog
;~M=Msg|Shell_TrayWnd|273|419

;load=MsgBox|Hoekey started :)|Hoe-tastic|2000

; include another settings file:
;load=Reload|include.hki|1

; show add/remove programs dialog:
; ^@~X=Run|Rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl

; ~0=show|ET WinConsole   ; Show hidden Enemy Territory console

; Custom window tabbing: stack adds to stack, unstack removes, cycle tabs between stacked apps
;@2=stack
;@3=unstack
;@4=cycle

~t=run|C:/Program Files/DScaler/DScaler.exe

;=Run|notepad.exe "%c/%u.txt"
^_F=Run|wscript.exe CreateFolder.vbs "%c"

;^12=Msg|Winamp v1.x|273|40040 ;playlist window toggle
;^101=Msg|Winamp v1.x|273|40040 ;playlist window toggle
;~@44=MsgBox|You hit the win-alt-printscreen key!
;19=Run|Rundll32 shell32.dll,Control_RunDLL

;~5=Keys|&nbsp/a/0/5/9/A
;
;~5=Run|putty @gateway
;~5=FocusMsg|Shell_TrayWnd
;=Keys|/w/W/ztq
;=Show|Shell_TrayWnd|0

;~5=run|cmd.exe /c "dir&pause"