此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: L# c7 G- j5 l7 u$ F" A/ B* L1 n
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
( R5 E$ G2 R P0 Q7 r4 y8 k 方式一:
% ~ I1 ^4 A1 U% ? 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 f6 W) S0 u7 g. y; | 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* Z7 ?0 \8 j! ?8 X
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 H0 q0 b& f' V5 o 方式二:3 u" g$ j% g4 G/ v1 Y/ h
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, n7 a V4 c: L3 p/ S+ n- [
SetTitleMatchMode RegEx, P. m9 ]* ]7 U! B! s8 b
return
! q, S' g* L1 Y) J ; Stuff to do when Windows Explorer is open, Z8 a9 e4 l$ k, k& I
;
9 s! ^, ]: }1 I m4 c #IfWinActive ahk_class ExploreWClass|CabinetWClass
$ a7 u0 p9 R2 V ; open ‘cmd’ in the current directory
. C9 k) B0 F- F* S3 s8 p- v ;
! V8 n) x4 N5 { J) l0 O/ V4 |) s #c::: u! `& G6 K( K8 T" e4 _: g5 o5 L
OpenCmdInCurrent()1 `3 V% {, l6 d
return6 w& s5 U5 \$ `
#IfWinActive* r! S0 m1 ]/ S% {, b7 O2 c+ U2 [9 a
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; C( ?4 V/ m2 \ y9 b4 x; B ; Note: expecting to be run when the active window is Explorer.
: u g. r# c% p8 f ;
2 s3 \! F- m0 B" l" ]2 L OpenCmdInCurrent()
0 t- O7 }/ ~1 `! g {6 ]; T( a* [" U; h9 y
; This is required to get the full path of the file from the address bar
+ F7 N, |+ ~% Z; g WinGetText, full_path, A9 } w# Z) z A0 }5 e# Z, V& n
; Split on newline (`n)
* T6 e8 ]4 U8 g8 P) u, p% S StringSplit, word_array, full_path, `n
, S' r* ?1 J5 R9 X( P% Y ; Take the first element from the array
5 A, ~! @5 K1 q, ~6 V full_path = %word_array1%6 t* M- Q6 ^3 j3 L
; strip to bare address- L3 @* C- ~4 ~$ W6 u
full_path := RegExReplace(full_path, “地址: “, “”)
2 U) M7 d: R c; u, n H ; Just in case – remove all carriage returns (`r)* b) R7 t/ \, V2 X1 t" o
StringReplace, full_path, full_path, `r, , all
6 A$ b1 L) d$ ?( f, Q IfInString full_path, \* p$ H+ k9 ]9 g3 A' C; z
{
: ]7 h8 z q5 g3 b- B% h# N Run, cmd /K cd /D “%full_path%”
) `9 [ [6 B0 e0 a' l* ~ }3 p6 |) ^3 l2 o# Y; M5 g3 T2 [
else1 @( Q/ {" f9 j" |5 q9 ?
{) @9 }7 k% g3 s
Run, cmd /K cd /D “C:\ ”
$ w( L! ?4 c& R& T }
& U5 f% f# A8 }) E# ~" T& ?7 n$ Y }% N, ~' A/ C! ?2 T. g
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
, s+ y: V* P+ u- b) \5 y9 s" n 这段小代码肯能有两个你需要修改的地方4 i- S7 \7 d. a. g5 Z+ Q, R
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% }) h4 m2 @! U7 ~, b' v
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) H6 o# C6 q- Y! c ]" U) q, E9 c |