此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, N4 E6 B! E) [, ~5 ~( O
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: P" u+ Z: T1 s; d& X+ W0 X [4 G$ P) V) {
方式一:
5 Z* t/ w% e- S# S1 N 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 {& z2 O: G+ e- {% R 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, Y5 a7 ^) e# [$ P9 P
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 W. F. h. q1 _* `1 E
方式二:' U6 R/ q" Q; C# `
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ F! m* r' ^6 y1 P" @2 W SetTitleMatchMode RegEx( `# j2 M2 x- Q8 K; a
return
( l# y: E6 i; t# W ; Stuff to do when Windows Explorer is open) r6 u4 s4 _ ^$ {) i
;3 s# r, a* G1 D7 Y/ y; |
#IfWinActive ahk_class ExploreWClass|CabinetWClass
" y- m+ G! V/ ^7 F ; open ‘cmd’ in the current directory
# U ?( }: ^; d' H ;
$ Q% S! r6 ]. H/ m #c::& `+ C; s3 S5 I; A
OpenCmdInCurrent()& `% z9 q0 J$ ^; Z. _5 ^
return
1 h( |; q9 q; l- @( g #IfWinActive
$ t j P: `2 r) S0 `. z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 k' a% f, O7 d1 o ; Note: expecting to be run when the active window is Explorer.8 G+ ^; G+ i% x9 {
;2 |* x8 D6 ]; y* L. H- z
OpenCmdInCurrent()
9 c; b% J) M' M9 h {" i5 G# N9 n0 k" l& t, t
; This is required to get the full path of the file from the address bar* p S* H% [4 B9 g+ Q
WinGetText, full_path, A
8 Y- _' _; G: F6 X ; Split on newline (`n)
2 `+ B* R$ t+ q StringSplit, word_array, full_path, `n
7 C# k# f2 s" G. b: ?: u ; Take the first element from the array
9 M/ G1 V7 \5 M5 K full_path = %word_array1%
5 s/ Y! H+ k" p6 f ; strip to bare address1 F9 v9 C q3 L* W) K7 l
full_path := RegExReplace(full_path, “地址: “, “”)+ i9 D9 T! H5 d! c
; Just in case – remove all carriage returns (`r)$ `5 w3 x/ ?' x+ ^: ]
StringReplace, full_path, full_path, `r, , all6 @2 v+ d7 P5 T+ I) e
IfInString full_path, \
" V H! `& P1 {1 |, U# I6 _ {$ a0 L' }" H, y7 H6 R
Run, cmd /K cd /D “%full_path%”
7 i+ e5 c/ Y% `( I. \$ t }
' D! Z I* l; v) {# S else2 \7 o) T, ^1 X4 c" k+ S" A/ N4 O K
{3 _' n x. Y, T) H
Run, cmd /K cd /D “C:\ ”
" P. J7 s8 V7 q, j2 l; t) T }
" D* A. J a5 U }3 f* E& A G W2 f$ X) G
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( X1 W) I. ^8 H, X 这段小代码肯能有两个你需要修改的地方
* x/ T& D& a0 w. M8 c6 C 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# E8 L j# j1 S# f1 L 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! L H+ y ]* ^* I: n$ `- W |