此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. S" s9 P6 }% A6 G9 C
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 l; e9 p) E0 P1 S1 z2 ?6 {8 B 方式一:
) q/ a# t m5 n. D/ i& z2 I* G 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
! x- R# }; z) z* \. x8 t 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- ]1 u7 d5 T7 k3 h/ J6 U HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 u! A! _2 G* W5 @8 S# M4 C
方式二:
- p5 v+ {8 W- c 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, B h7 c! }/ o0 g SetTitleMatchMode RegEx
/ i6 b' @' q) L/ A9 L! m# y' f return% l) [+ H1 B- i- k, v4 f, z
; Stuff to do when Windows Explorer is open* o' W! |5 x9 O' S' t g8 a
;9 b8 W2 ?- x& ]7 d
#IfWinActive ahk_class ExploreWClass|CabinetWClass' O; u4 {3 X* T0 J1 n, L2 r
; open ‘cmd’ in the current directory( X7 y6 o9 b; B- a
;: r; S; K* j! G. o! C
#c::5 x5 K; c8 q S. E! ?; p3 N/ v9 j2 ]
OpenCmdInCurrent()
7 v$ x+ h& G& b8 n return: q0 z1 t! ?# J5 j* e4 Q$ ~6 x5 y4 @
#IfWinActive% t) s& F, @7 W2 M7 x9 g! @
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 G4 [6 U* A/ j( b! C( b! \$ |1 ` ; Note: expecting to be run when the active window is Explorer.- _; P0 H2 h* ^4 _3 C6 v, [. _
;
- m( ^0 B$ M# V; P* [ OpenCmdInCurrent()
: U: }, R# w# e: o {, l' l: T7 |# e
; This is required to get the full path of the file from the address bar
- m% }) U, f3 p; `1 }" R# @% K WinGetText, full_path, A/ R, W( D, ` q/ R0 j3 A
; Split on newline (`n)
/ o* \$ u+ K& p$ k. J& r0 i7 l StringSplit, word_array, full_path, `n( y5 f; l& Z5 H5 R& @+ k
; Take the first element from the array- Z) o) o- R$ }0 u
full_path = %word_array1%
: x V: [8 J5 D! p ; strip to bare address
: @( [' r" s% h- [$ { full_path := RegExReplace(full_path, “地址: “, “”)2 Q/ b& Z7 c5 { H# J2 v
; Just in case – remove all carriage returns (`r)3 S% W6 b* f% i5 l' y3 W C( r1 Q/ t
StringReplace, full_path, full_path, `r, , all
& {+ b. t3 O$ k% A IfInString full_path, \
- m2 \8 C, k" h1 k: s5 Q& m" B {
" [( J0 i5 E+ T3 b7 F+ O, k Run, cmd /K cd /D “%full_path%”
; v4 G1 R3 l( }5 M' b! T }
8 S' b2 a% |$ d' U0 P1 K) q else
' U5 s3 _8 D/ B) }& A {
. X' Z) o( [4 V- z( q i! m Run, cmd /K cd /D “C:\ ”
2 f7 Z5 z) s( ]. O4 X3 _) f }
7 N7 n% G% m: i2 t, l |* E# D5 X }0 R, n$ x2 F% }$ C2 w/ W
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* s) ^$ r, ]# }/ ?0 \1 J 这段小代码肯能有两个你需要修改的地方3 B" i T6 b7 M9 I. t: O
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 }8 X! ^7 n3 j- R5 ^
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 J+ b% t" U( L |