2007年8月11日星期六

Autohotkey在TC中的应用—包括TrayIcon的Alt-Tab问题

Autohotkey在TC中的应用—包括TrayIcon的Alt-Tab问题

偶逛TC的wiki,才发现有脚本这一块,把喜欢的Autohotkey所有文章翻了一遍,找出几个自己喜欢的整理一下,可能是我孤陋寡闻,见笑了:)。也学习AHK是如何来控制TC的,以便以后DIY。

Autohotkey的应用请google一下,很简单的。

(http://chenqj.blogspot.com, qjchen)

1)让TC在trayicon的情况下ALT-TAB时不用再按enter,这个问题在TC论坛上也颇久了,G兄似乎也没有想去解决之。所以有如下ahk。
#Persistent
#SingleInstance force
#NoTrayIcon
SetTimer subTimer, 500
subTimer:
If WinActive( "ahk_class switchwin2" )
{
SendInput, {Enter}
}
Return

2)鼠标中键打开新的Tab(不一定很必要)
cm_OpenDirInNewTab := 3003
#IfWinActive ahk_class TTOTAL_CMD
$MButton::
MouseGetPos, , , , sControl
if (sControl != "TMyListBox1" and sControl != "TMyListBox2")
{
Send {MButton}
Return
}
Click
PostMessage 1075, %cm_OpenDirInNewTab%, 0
Return

3)通过热键调整splitter(就是用键盘调用窗口分隔条,可能是我愚笨,没有在TC的command中找到这个键盘快捷键)
http://www.ghisler.ch/wiki/index.php/AutoHotkey:_Popup_the_splitter_menu
; Win-G (Total Commander: splitter menu)
~#g::
if not WinActive( "ahk_class TTOTAL_CMD" )
Return

WinGet sf_aControls, ControlList
Loop Parse, sf_aControls, `n
{
StringLeft sf_sTemp, A_LoopField, 6
if (sf_sTemp = "TPanel")
{
ControlGetPos Cx,Cy,Cw,Ch, %A_LoopField%
if (Cw < 16)
{
ControlClick %A_LoopField%, A,,RIGHT
Break
}
}
}
Return

4)TC Fav Menu
http://www.ghisler.ch/wiki/index.php/AutoHotkey:_TC_Fav_Menu
文件较大
这个可以把TC的收藏夹也作为可以为资源管理器所用,也可以作为Open和save时候所用

5)在TC的标题栏里面显示文件路径(这个是用来开心的吧:P,自己加点什么有趣的信息上去TITLE)
#Persistent
SetTimer subTimer, 250
subTimer:
if WinActive( "ahk_class TTOTAL_CMD" )
{
ControlGetText sPath, TMyPanel2
StringMid sPath, sPath, 1, StrLen(sPath) -1
WinGetTitle sWindowTitle
if ( sWindowTitle != sPath )
WinSetTitle %sPath%
}
Return

6)在进度条上显示进度的已用时间,剩余时间,总时间,和开始结束时间
http://www.ghisler.ch/wiki/index.php/AutoHotkey:_Show_elapsed_/_remaining_/_total_/_start_/_finish_times_in_title_bar_of_progress_dialogs
代码颇长。
在进度条激活的情况下,按shift键就可以了。

7)给工具栏图标Toolbar Icon增加弹出菜单,可以多项启动参数。
http://www.ghisler.ch/wiki/index.php/AutoHotkey:_Popup_menu_for_button_bar_or_F4

8)最大化窗口的情况下,双击窗口的最左边或者最右边将去到相应的根目录
RegRead, DoubleClickSpeed, HKEY_CURRENT_USER, Control Panel\Mouse, DoubleClickSpeed
If DoubleClickSpeed =
DoubleClickSpeed = 500

~LButton::
IfWinActive, ahk_class TTOTAL_CMD
{
If A_TimeSinceThisHotkey >= %DoubleClickSpeed%
ClickCount = 0
MouseGetPos, xcoordinate
If xcoordinate = 4
{
ClickCount++
PostMessage 1075, 4001, , , ahk_class TTOTAL_CMD
}
If (xcoordinate = A_ScreenWidth+3)
{
ClickCount++
PostMessage 1075, 4002, , , ahk_class TTOTAL_CMD
}
If ClickCount = 2
{
PostMessage 1075, 2002, , , ahk_class TTOTAL_CMD
ClickCount = 0
}
}
Return

有空把其他几个脚本的也翻一遍,看看有没有什么好的。