此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
/ t9 U: D( u, ~ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" w% @" j3 v+ y# c 方式一:
! P- e) ]3 i' T I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: y3 K2 m8 Q, Y2 f$ T3 k" b9 |
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: ]# X2 Q' E5 [5 r( {7 R HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
J- y0 y7 M9 q5 u 方式二:; v2 i( W8 T+ r( b3 \. e' E0 ]
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:& W, A; R/ ]$ G9 C, u x! ]; j
SetTitleMatchMode RegEx
L2 F# V' j2 M' L return
% i" N- j2 ^/ B5 B3 K% Z ; Stuff to do when Windows Explorer is open
: @( I: O; H# q2 @( |0 Y) s ;. @5 V& T$ b+ [
#IfWinActive ahk_class ExploreWClass|CabinetWClass2 h K, b: N# w# X* k2 g5 k
; open ‘cmd’ in the current directory
9 `+ b7 S f- G2 R- Z- U ;6 a) S% O$ d# d; [; v* j
#c::+ q, W) c: J1 @ U. I) o- `
OpenCmdInCurrent()6 D9 O" a+ g* ^9 O
return) X! j: G5 f) }
#IfWinActive+ T: T, d$ @8 ^* |+ _- u' }3 h$ d
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; P/ e4 Y x; M B5 q/ \& [8 @ ; Note: expecting to be run when the active window is Explorer.; P# ^5 f( K; e1 a
; N5 G$ x1 Z0 l
OpenCmdInCurrent()
- A; @! Z6 B4 w6 x7 x {
4 x% _0 N; U! ~- {- c5 I ; This is required to get the full path of the file from the address bar$ Y- f0 p$ F6 o% @0 N/ e
WinGetText, full_path, A/ q3 Y9 J- r2 }
; Split on newline (`n)8 s+ M* h- x# e% k# C* T! d% f
StringSplit, word_array, full_path, `n
# M2 \6 M; N: g8 h ; Take the first element from the array9 }4 Q* t# v9 q# x7 ~$ M
full_path = %word_array1%
3 l6 ]! R' a* ~9 e ; strip to bare address& B& N l: V0 M6 D
full_path := RegExReplace(full_path, “地址: “, “”)
- m# P( l. F& n9 P+ |6 ` ; Just in case – remove all carriage returns (`r)
- G% m T/ Z& k StringReplace, full_path, full_path, `r, , all
, g$ K( a+ M. E+ j IfInString full_path, \
3 U5 W! l" q: h# J; M. T1 M {
5 e' U+ L4 @: y Run, cmd /K cd /D “%full_path%”
3 h* \: _8 r2 M- g X }; e1 I# ]8 T) W) S) y9 e {: f
else
- i' H4 Z& |' N- w1 u {* Q! h8 O3 J2 u9 v6 Z- u
Run, cmd /K cd /D “C:\ ”' D1 ~: [6 d# i6 s0 R8 Q
}
* u. i9 v; g, X% R& ` }
2 _2 V4 z* [! \$ p2 L1 p 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" Y% q) r; A0 x7 F ]
这段小代码肯能有两个你需要修改的地方) \# x' L6 x- ]/ C |
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( I$ Y w) n$ u0 b
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “/ @: |8 o3 `& H8 Y
|