此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。7 I# ~. C, f7 v1 j* I+ Q5 p
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 A" [6 ], b% T# `# ] 方式一:9 U& E7 H( I# N8 B
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) ]$ _! C7 B' a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
9 |3 A3 X$ G! j" g& G8 b" _- X( ~* L8 O HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 W# ?$ ]; w4 H7 O+ B9 k 方式二:& d9 d* @. d8 f# R. \3 A
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# t8 @6 J$ g3 ?9 T SetTitleMatchMode RegEx
, O ?- D9 }6 ]. ~ return
: M+ A: y; D. M: D$ B ; Stuff to do when Windows Explorer is open4 e. ?& P% ` I) {5 I$ U
;
/ v& C* u4 p, i0 h #IfWinActive ahk_class ExploreWClass|CabinetWClass
6 _! l# ]3 M, \ \9 S ; open ‘cmd’ in the current directory1 A# f( |) |0 q2 U) C
;
* m0 J9 }, P+ e! o& c `6 g #c::$ ^* ^6 k/ A3 g9 p4 @; L& ]4 A, X
OpenCmdInCurrent()! g2 M2 [' x3 _8 P* [, Z) U/ o& R
return5 P0 |( }( A8 Q/ A
#IfWinActive4 @, ]9 V2 ?* {: w
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 A$ h5 R, Q3 Y+ ]9 T( v! S ; Note: expecting to be run when the active window is Explorer.2 T: P. S6 e! ~3 I8 [
;5 U* {' f0 A' t. ~) A. R4 H7 d
OpenCmdInCurrent()0 a. V# g( |* E- `8 b8 H1 @
{4 _. K& M4 y4 w
; This is required to get the full path of the file from the address bar
5 \* Z1 F) a% P( W- m' T WinGetText, full_path, A
: G' S3 e+ h/ J' k9 k9 _ ; Split on newline (`n)
0 ]5 i1 Z- B& u* P) h) d' b StringSplit, word_array, full_path, `n/ [; a+ W8 t0 s
; Take the first element from the array
+ |# H, i3 N) C$ c" a5 F full_path = %word_array1%
* D1 p2 f/ q) C+ x% c4 C8 ^ ; strip to bare address
1 t; s/ K0 M i: B: P9 u. E, i3 i full_path := RegExReplace(full_path, “地址: “, “”), Y T& x/ f; o1 {: [9 w
; Just in case – remove all carriage returns (`r)
, _: N/ b( M. l5 s, j/ j: O' Q- [ StringReplace, full_path, full_path, `r, , all
% Y; U2 F/ x7 h9 _% _ IfInString full_path, \% Q4 D; w+ _7 }4 S
{0 V7 d* _+ _& Z$ S- O
Run, cmd /K cd /D “%full_path%”5 A4 s* N$ j d, D
}
$ n9 v; u- q7 V! G else
) v. A) n8 G T& F7 U$ } {! b& @$ d* u- z" W( |) m) F" d
Run, cmd /K cd /D “C:\ ”
6 u" Q: ?- g9 }5 c: X( W5 T }+ P& I# a D0 o' J' i. R, |5 B* P
}
7 K; @. j4 [3 X* S 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 ~9 I9 B8 y0 u; E/ D. \ 这段小代码肯能有两个你需要修改的地方5 j/ ]* x0 C4 ?* r4 H0 e5 |
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
" Y6 @2 M& Y0 r, l 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& e: k: q7 v$ S: K% O; q8 h6 c
|