此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 ?, t$ s$ J3 R* n* y X
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ b- w; j: o j( b. d( }/ _ 方式一:
2 K) U5 [: y& A/ R; R" h 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ l. N+ i# A& i+ L 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& T! L* m( [& I I* _ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( y" ~! g5 c5 T
方式二:4 P3 n3 h' d, }2 W8 x5 n0 [
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* q9 F) k% S8 |; t" z E: U# ] SetTitleMatchMode RegEx
. x, a* q% }& ]6 r return
' k8 F( C& a8 ]5 y. L7 x u3 k ; Stuff to do when Windows Explorer is open
6 F( E8 d: |2 P& c4 H8 v5 K! a. u ;4 c! ^9 Q% Z9 J7 g9 K( L- K$ G! \% \" [
#IfWinActive ahk_class ExploreWClass|CabinetWClass2 s. x: z2 j7 V0 n' X
; open ‘cmd’ in the current directory; c1 h; B9 j0 k4 @" {) l) l
;
# w: Q; V" F% C$ ~* F2 F# P #c::
4 `, ?/ j; H: h* m$ B5 ^/ {6 R OpenCmdInCurrent()
( w$ d$ }; F& L9 H. \4 f return
8 y0 K- d" K: x' y; R; T #IfWinActive, p9 i$ q5 Y, q" \
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. F- I4 F! @* i4 y ; Note: expecting to be run when the active window is Explorer.! d, j. Q D6 q2 O% l4 w" h9 y
;
6 a8 y p! u, B0 X OpenCmdInCurrent()
* D/ N( u5 n( ~4 J5 H( z {5 D: ?0 g ?+ k. v+ g$ S1 G
; This is required to get the full path of the file from the address bar' V' N( D7 Q7 a3 x' Q+ C3 ]
WinGetText, full_path, A- V' y9 O- T) S
; Split on newline (`n)3 k" d% w1 u: p# I6 w
StringSplit, word_array, full_path, `n* S) F: A# U, A2 }
; Take the first element from the array0 } o8 }% j+ S5 H6 @% X
full_path = %word_array1%2 r$ s0 M8 ?3 S+ `4 t+ ?
; strip to bare address
5 z$ r# x2 R. j$ x full_path := RegExReplace(full_path, “地址: “, “”)( V' r2 Z& J/ Q, j; U
; Just in case – remove all carriage returns (`r)( {+ z6 l# F3 K+ ~& x; q8 i
StringReplace, full_path, full_path, `r, , all9 m! f$ [: [3 j. x |6 |2 w
IfInString full_path, \
+ J$ @. V7 S- t- k/ ^- D$ J9 E* m {# {# Y) L3 Y/ G" r( [0 {
Run, cmd /K cd /D “%full_path%”
" C, T H2 Y, ?& F- P }" U" K7 f* r! ]% n5 N$ |6 y
else. N" }* q1 D4 Q( r4 k+ ^
{1 f8 H* [" c+ Q9 \% r+ W
Run, cmd /K cd /D “C:\ ”, |7 e. ~9 k4 ]$ D! @
}# i* f/ B, @4 f: T
}3 m+ B% r3 C$ `$ P5 z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 ^4 v R/ O/ f' c4 d1 W/ d 这段小代码肯能有两个你需要修改的地方. g' Q2 Q: w5 V4 C7 f! l0 A
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 [. u( u/ x1 u3 e. ]5 l- a4 @
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; d% G/ ?' U" y
|