此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# x% X2 y8 k. K) Y' n0 W) p# e0 ^ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: Y& q/ b& B6 b6 D; ^# x6 u 方式一:# e7 v* _: x7 `1 L
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
; Y) _+ W! t* s- }6 p 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 `& N4 ?3 G/ R6 K2 @
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 K9 c% V5 m8 ]4 J+ E0 v0 z1 `
方式二:
2 F5 @1 G( x1 V. [/ L" J( N2 _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" K' y& L _4 q8 h" C. n3 K6 C SetTitleMatchMode RegEx
$ `* d: ]( U1 L& b% k1 \3 Y% R, ]. Z return5 s$ T h" N$ p' J
; Stuff to do when Windows Explorer is open
8 C* a8 ^5 g6 D2 a5 I5 Q, N' c ;) e# X8 y' P6 a( ]4 R4 }. M
#IfWinActive ahk_class ExploreWClass|CabinetWClass
6 K+ m7 r: |/ K ; open ‘cmd’ in the current directory
" y% J6 ?$ _5 l ;
' u( i; d$ A2 L' L #c::. ~3 s& T9 _' G/ h" h6 T6 w
OpenCmdInCurrent()
" F0 L6 @% I6 n" v' m; K return
" P# ~9 ^' h9 o2 {% Y/ Q, L #IfWinActive3 s7 |( k3 L9 V; [( L! u" J. Z
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ {6 j+ M8 H% \ ; Note: expecting to be run when the active window is Explorer.
+ }+ l$ [4 f6 }5 u* v ;
5 `. k K' y$ S* H OpenCmdInCurrent()
; Y, F3 w6 U4 k( D. g; j& d {
% s4 i" p+ {) g- ]/ P0 J ; This is required to get the full path of the file from the address bar7 w8 T4 |; }1 e/ \' e* N) W
WinGetText, full_path, A0 M1 Y# W$ Q, B& }! Q
; Split on newline (`n)" S; D: V( P% L& B! K
StringSplit, word_array, full_path, `n
! |/ C) {9 C t3 T+ E ; Take the first element from the array
+ f k( j7 I. j: L+ {8 w full_path = %word_array1%9 }: p9 z) R% K
; strip to bare address
T7 r9 a3 q5 |9 {$ L7 W7 w0 { full_path := RegExReplace(full_path, “地址: “, “”)% N# J: x. T& ~2 l8 V" u6 E
; Just in case – remove all carriage returns (`r) y2 \% y! b$ G0 ?! c9 N+ J/ k
StringReplace, full_path, full_path, `r, , all
! T) T) e$ O p& E IfInString full_path, \
( }5 S- Z# K; r( k. E {4 Z; u: S& T! P. D
Run, cmd /K cd /D “%full_path%”
0 i) K" A; b: z7 a3 x. Y. G9 n }
( z# @# f# R6 B* C) I0 b- m) J else
4 }. G& R+ m. K2 m7 }+ e {9 F+ ^/ [3 v; B! f. e
Run, cmd /K cd /D “C:\ ”; Y3 g6 R. A! |, q/ f
}0 Q; Q) i1 e8 {) w: C, ~
}, P4 K% h9 o) E' q
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* G( t+ @* y& _/ E4 l! ]$ C, g7 Z! Q 这段小代码肯能有两个你需要修改的地方
* B- Y; X, w9 f2 v0 r* _ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) A$ V) L$ |" f7 [6 Y* Q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. G% P, p9 ?& d4 J1 }, w: _ |