此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ C+ t8 W, o5 m R
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 Z' h7 z( D" D7 R0 r: f$ P 方式一:
0 |2 f; e+ b, g$ y1 f2 y0 {* h 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 i5 \1 Q! a0 y. t+ I# F
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! C9 N: d" u1 s% A" F HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! h$ k# B6 V9 n" J& A 方式二:+ |0 @& B) _6 ?8 k) k- a' `
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ i; w0 ^5 ?6 A4 G
SetTitleMatchMode RegEx' L! M9 f0 L' {1 b( M
return- E) `7 h$ V& a9 |
; Stuff to do when Windows Explorer is open
& I4 x( q7 @, a+ ? ;; j- N( t/ \ S* ~: t* l8 R1 u+ [/ V
#IfWinActive ahk_class ExploreWClass|CabinetWClass) ^+ C$ n4 n6 k- w2 o) b/ G& R5 w
; open ‘cmd’ in the current directory. u7 N/ w7 R! r6 f/ r! f" A
;
, C) t& @# F6 q) u6 n& J# h7 o# v7 J #c::
% h* A; n/ J. T OpenCmdInCurrent()
( n9 b9 ?( ]; j0 }6 f4 ], W return" ?+ s% l! y3 H7 o$ @0 o; l
#IfWinActive
2 _: ^9 V0 {! L! } ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 ^: Q6 g6 Q; o' Q( f4 @3 E6 f
; Note: expecting to be run when the active window is Explorer.& S- _6 D1 j7 @( H7 y8 g' `( Q1 D
;
. b$ {* C' y! k3 E: h OpenCmdInCurrent()2 T: O. y, Y! r$ y# A
{
9 z: v, E5 ^1 n- o% F" Z ; This is required to get the full path of the file from the address bar/ N/ p( c- E* R
WinGetText, full_path, A" |' @8 E% T- l Z3 k
; Split on newline (`n)
% {- W' B8 J6 v0 o0 `* m0 O StringSplit, word_array, full_path, `n$ e' C( Y9 E' t8 O
; Take the first element from the array; @6 Y* G/ y: J* B- s
full_path = %word_array1%
5 c. _0 A {" U6 U ; strip to bare address9 H# q9 z6 O5 K9 W I
full_path := RegExReplace(full_path, “地址: “, “”)
: H& j+ Q8 }; p2 f# O ; Just in case – remove all carriage returns (`r)
4 }0 Y" q$ Y% L& h4 V StringReplace, full_path, full_path, `r, , all
6 U* ^6 X2 a" A/ E" | IfInString full_path, \ j j) y3 \7 p8 d8 p! u( \
{5 Y8 y, _( }- X# t
Run, cmd /K cd /D “%full_path%”
}9 l4 r) u+ l! Y5 M }
: d. F# _1 J. \2 b+ b# Q2 s- g else
. @7 A/ i. O2 ?6 P( i% v {5 s8 @2 ]" P& r$ J8 A
Run, cmd /K cd /D “C:\ ”
% R1 ~- Y3 c& V1 M }
; r. @0 s6 k" J+ l/ @2 a! L0 ^ }
# k5 G1 r% m% U, P1 |/ c 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) B4 ], P6 d7 P) `7 u
这段小代码肯能有两个你需要修改的地方
. z$ j& l$ n$ x/ o4 V% P+ H! f 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! |. |$ p7 d' L7 s: z 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 D% k# {4 v7 I0 X1 F& ? N
|