此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
\$ G x/ c3 C' ~ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
7 F( A' I3 j# X' `6 f1 L! l 方式一:
" C/ M! D: S; l 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* f" c- d# f: P; }. N3 N# q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ s, W' U- k: i$ h) v. b1 b" v HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 Z6 _0 I9 p- g( W6 j( h 方式二:
& F0 `, ]* |7 O3 t3 ~8 R. { 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& d1 M4 T2 e. ?! n0 L SetTitleMatchMode RegEx/ C) I( j v0 j' Q& g
return
* U- i9 H- n, }) q6 X9 g" m2 H ; Stuff to do when Windows Explorer is open" t( h7 `5 V9 Z% [& Y
;/ n6 `8 {# p% }
#IfWinActive ahk_class ExploreWClass|CabinetWClass: U3 R% R: v) ?/ s8 K
; open ‘cmd’ in the current directory
5 E3 v: @# C- W ;9 n# x5 V& b+ C) `+ S
#c::
2 ?- o' c/ Y B2 R1 _& `, l* ~ OpenCmdInCurrent()
9 ~. I( C( M! k8 U, ~ return! ^& H" {; N: n3 O
#IfWinActive$ f, l2 r* l- P% B# l8 V" r l( n$ W9 L
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
K" m9 k! y' Q: C* ~ ; Note: expecting to be run when the active window is Explorer.
8 g5 O) f3 G" V: d3 s ;7 p' L3 `6 Z" Y& s4 X. F5 q0 ~
OpenCmdInCurrent()* R* c$ U- a/ J) E0 q6 ~0 a3 Q
{8 ^& x. O+ a3 ~% I6 M2 C5 C5 F% F
; This is required to get the full path of the file from the address bar
% F1 M" Q q8 A. w4 O WinGetText, full_path, A
9 S5 X8 l3 b0 r) Z ; Split on newline (`n)
* h% A, X! k3 G; s StringSplit, word_array, full_path, `n3 _' `8 f6 I) r; Y2 ^1 b8 h; B$ W
; Take the first element from the array
" f) p% B- F5 F q+ \ full_path = %word_array1%
: h% C; y& D) p* h7 v! l7 n ; strip to bare address
6 V/ Z4 T, }3 e- D6 d" i full_path := RegExReplace(full_path, “地址: “, “”)3 c" N. o* Z8 Y' A
; Just in case – remove all carriage returns (`r)& x; h0 t' ]# b
StringReplace, full_path, full_path, `r, , all
/ h: M$ e! C5 M- D3 x+ r8 f. E IfInString full_path, \
: @( G- F3 Q w6 D5 |) k {
3 B+ g6 e; }* b1 m Run, cmd /K cd /D “%full_path%”+ A) ?- \2 F. y N( Q: S
}
9 {% X" r! B+ p+ R) } else
" M3 L+ i( g$ N. q7 R9 m. F {
+ ]# C6 w2 y, n: I z* L& u Run, cmd /K cd /D “C:\ ”8 w3 p' [/ [" i
}
9 r, Y+ @! J$ {% d, C# i }
4 e2 R, B0 l/ w 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- q0 J/ r- m$ u: N2 I# \0 I
这段小代码肯能有两个你需要修改的地方
8 q& f, k/ |. n6 u1 F$ s7 T 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& ~1 m% c; R7 d7 ]' F
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: |) m% \" A4 W, Q6 x |