转自http://blog.csdn.net/zxremail/archive/2011/01/13/6135731.aspx
;******************************** 我的最新试验田 ************************************
;******************************** 我的外部头文件 ************************************
;#include CurrentPrograminstallPath.ahk
#include _SendRaw.ahk
#include GetMyPath.ahk
#include Ime.ahk
#include UrlEncode.ahk
#include CMDret_RunReturn.ahk
;******************************** 我的常用快捷键 ************************************
;作者:朱兴瑞 草成于 2009-11-01
;******************************************************************************************
;******************************************************************************************
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
FileRead, Contents, MyAutoHotkeyPath.txt
;----------------------------------------------------------------------------------
;----------------------------------------------------------------------------------
;前面加上 $ 符号有效地防止了 send 进行重复热键(例如 NumPad1 )!!!!!!!!!!!!!!!!!!!!
;或者使用键盘钩子也可以
#UseHook
;----------------------------------------------------------------------------------
;----------------------------------------------------------------------------------
path_firefox:=GetMyPath("ahk_firefox_Path")
;----------------------------------------------------------------------------------
;----------------------------------------------------------------------------------
;----------------临时热字符串(用后删除)------------------------------------------------------------------
;------------------------(可能会对很多后续快捷键产生影响!!)------------------------------------------------
;字符串替换系列
;:*://::
;_sendraw("I2C")
;return
;:*:..::
;_sendraw("SO380000")
;return
;----------------------------------------------------------------------------------
;----------------------------------------------------------------------------------
;----------------------------------------------------------------------------------
;----------------------------------------------------------------------------------
;把英文(忘记切换输入法状态了)翻译为中文
RAlt Up::
inputNum := DllCall("GetKeyboardLayout","UINT",DllCall("GetWindowThreadProcessId","UINT",WinActive("A"),"UINTP",0),UInt)
;msgbox %inputNum%
if inputNum = 3760261124
{
;send {space}{space}
Send, {LShift Down}{LShift Up}{Space}
SwitchIME("中文 (简体) - 美式键盘")
return
}
Clipboard :=
Send {left}{Right}^{Left}^+{Right}
send ^c
AutoTrim, On
Clipboard=%Clipboard%
SwitchIME("中文 (简体) - 美式键盘")
SwitchIME("谷歌拼音输入法 2")
StringLen, length, Clipboard
if length > 60
{
return
}
send %clipboard%
return
;----------------------------------------------------------------------------------
;----------------------------------------------------------------------------------
1::
IfWinNotActive ahk_class EVERYTHING
{
Clipboard :=
IfWinActive ahk_class CabinetWClass
{
}
else IfWinActive ahk_class Vim
{
}
else IfWinActive ahk_class ExploreWClass
{
}
else
{
send ^c
}
send ^+#!s
sleep 200
SwitchIME("中文 (简体) - 美式键盘")
if Clipboard
{
send ^v
}
}
else
{
Send,{LAlt down}{Tab}
Send,{LAlt up}
Winhide , ahk_class EVERYTHING
; send !{F4}
}
return
;----------------------------------------------------------------------------------
;----------------------------------------------------------------------------------
Esc::
path:=path_firefox
;RunWait %path% -new-window http://www.google.com/
RunWait %path% -new-window http://www.google.com.hk/
return
;----------------------------------------------------------------------------------
;----------------------------------------------------------------------------------
;显示或者隐藏 OutLook
9::
SetTitleMatchMode,2
IfWinActive - Microsoft Outlook
{
; WinMinimize,A
Send,{LAlt down}{Tab}
Send,{LAlt up}
Winhide , - Microsoft Outlook
}
else
{
winshow , - Microsoft Outlook
;sleep 100
WinActivate, - Microsoft Outlook
}
return
;----------------------------------------------------------------------------------
;----------------------------------------------------------------------------------
^Numpad1::
send ^1
return
^Numpad2::
send ^2
return
^Numpad3::
send ^3
return
^Numpad4::
send ^4
return
^Numpad5::
send ^5
return
^Numpad6::
send ^6
return
^Numpad7::
send ^7
return
^Numpad8::
send ^8
return
^Numpad9::
send ^9
return
;----------------------------------------------------------------------------------
;----------------------------------------------------------------------------------
~LWin & LButton::
send {LButton}
return
~RWin & LButton::
send {LButton}
return
;----------------------------------------------------------------------------------
;----------------------------------------------------------------------------------
;----------------------------------------------------------------------------------
;----------------------------------------------------------------------------------
;看似无用,但是必须加上,否则“单键切换”与那些组合键冲突了!
~LAlt & Space::
send !{space}
return
;单键切换
~LAlt Up::
state := GetKeyState("Capslock", "T")
if state
{
SetCapsLockState , Off
}
Send,{LAlt down}{Tab}
Send,{LAlt up}
return
;----------------------------------------------------------------------------------
;----------------------------------------------------------------------------------
;一键打开快捷键编辑页面(本来早该实现的,还是被惯性所囿)
~RWin Up::
IfWinExist kuaijiejian.ahk
{
WinActivate, kuaijiejian.ahk
return
}
path:=GetMyPath("ahk_gvim_Path")
ahkpath:=GetMyPath("ahk_kuaijiejian_Path")
Run, %path% %ahkpath% ,,max
return
;----------------------------------------------------------------------------------
;----------------------------------------------------------------------------------
; 双击右键抓取桌面
~RButton Up::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 300)
{
send {ralt}
sleep 200
send ^+!{PrintScreen}
}
return
;----------------------------------------------------------------------------------
;----------------------------------------------------------------------------------
;双击LCtrl打开 百度
;加波浪号防止热键自循环
~LCtrl Up::
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 300)
{
Clipboard :=
IfWinActive ahk_class si_Frame
{
Send {Right}^{Left}^+{Right}
}
IfWinActive ahk_class CabinetWClass
{
Clipboard :=
}
else
{
send ^c
; send ^c
;下面这一句拖慢了速度
; ClipWait,4
sleep 400
}
IfWinNotExist ahk_class MozillaUIWindowClass
{
return
}
AutoTrim, On
; path:=GetMyPath("ahk_firefox_Path")
path:=path_firefox
if not Clipboard
{
RunWait %path% -new-window http://www.baidu.com/
sleep 2000
WinMaximize,A
return
}
Clipboard=%Clipboard%
ClipboardO := Clipboard
StringReplace, Clipboard, Clipboard, %A_SPACE%, +, All
StringLen, length, Clipboard
if length > 200
{
return
}
clipboardwiki := Clipboard
;百度的汉字不可以,不知道为什么(历经千辛万苦,终于解决了)
OutputVar:=UrlEncode(Clipboard)
StringReplace, clipboard, OutputVar, `%2B, "%A_SPACE%", All
;采用百度搜索
RunWait %path% -new-window http://www.baidu.com/s?wd=%clipboard%
sleep 3000
;采用百度百科搜索
RunWait %path% -new-tab http://baike.baidu.com/searchword/?word=%clipboard%&pic=1&sug=1&rsp=1
;采用维基中文百科搜索
; RunWait %path% -new-tab http://zh.wikipedia.org/zh-cn/%clipboardwiki%
sleep 1000
click
; WinMaximize,A
send {F11}
Clipboard := ClipboardOfont-family: verdana, sans-serif;