此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 V5 \3 G/ x7 ~ S7 `' V( S) O
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- _1 h/ `7 D% @6 P; A) C* S( R+ p
方式一:
. Y. `/ |% l7 s4 H4 ^$ @ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- w& |2 q% c2 I; J6 K& r5 |
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 i! |, {6 ~$ I1 \ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) ?) Z a" @- a* U 方式二:! z8 I) _2 f% [* z
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ n0 U" l* y2 _- w4 R
SetTitleMatchMode RegEx
. X: M( v9 V& u: M* m1 q return
; v8 Z% W$ H' h' `8 S/ G" s- q* [ ; Stuff to do when Windows Explorer is open: J! z' |+ [! r4 h( w- o; {6 J
;
3 S8 c5 N+ O) W #IfWinActive ahk_class ExploreWClass|CabinetWClass) R. N& e/ J6 T' M) j" l) Y
; open ‘cmd’ in the current directory6 t. K8 {: M: ?0 g
;
* J. E; N+ s! w #c::9 \) P; j/ _* L, P" |
OpenCmdInCurrent(). r1 h$ i5 N4 o, F
return
. P( z9 M1 ]/ ] #IfWinActive) j! g0 q( C% z5 e
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
2 {# c- M5 H$ p ; Note: expecting to be run when the active window is Explorer.
1 c& C& e0 [5 `. y1 N ;
! l- N) u1 v3 b2 S OpenCmdInCurrent(). t8 e) \( j( k' o
{7 i$ m0 R# B0 {4 I. |9 |; f3 R5 D
; This is required to get the full path of the file from the address bar
8 T* Z$ l7 A- ~( R WinGetText, full_path, A
0 @9 j0 S+ Z* m5 y+ J. P- B* E ; Split on newline (`n)
m+ C* `( ?) [! u% |" h0 S StringSplit, word_array, full_path, `n; p& \; @! A) H- Z- Q8 m
; Take the first element from the array
! N" `+ W' q) t- l0 i full_path = %word_array1%
* K2 f# l. ]6 ?4 ]: k1 r) m, h6 e$ ~ ; strip to bare address( v2 S+ r, f9 e- M& ]1 j% W5 J
full_path := RegExReplace(full_path, “地址: “, “”)
/ U7 A) p a2 A2 _$ I* R3 t ; Just in case – remove all carriage returns (`r)4 F5 y* Y8 w6 V- q- X+ D
StringReplace, full_path, full_path, `r, , all" T0 I+ H C: J: E: G3 o; }% C
IfInString full_path, \
\; E3 U# K X# O4 ]; y {
$ A- X. P; B4 K8 F1 R. v Run, cmd /K cd /D “%full_path%”) Y/ X' n8 v! q3 F
}) D+ E+ z1 l. L/ [
else
/ b9 i; e: s1 v1 T" W7 v, S/ _8 G {. w8 [" S0 m0 [! c d
Run, cmd /K cd /D “C:\ ”
* c ~8 f$ m1 w, c0 A2 G8 W1 _ }. Z9 m! G' J, x; M9 o
}& E3 _1 i$ u+ Q+ G5 n
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- l" r7 o" k+ R1 e$ E: o
这段小代码肯能有两个你需要修改的地方" V4 G2 M; Y8 [4 d! o& a3 x# @
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! Q( `9 Q9 _) O) I( z
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 b+ I: [; h: Q' m |