此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; A; ^, s0 J$ A' a3 j: T* h 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 e: e# Z2 c0 X9 _3 l+ h3 g
方式一:
$ Z( N$ x3 J4 s. v2 ], C3 ]& @ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" W) I" N; J D& j; f% A 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% ?- k, X5 i! q" v' @
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
F: L) J4 u+ h( l 方式二:: n! U! F' g6 r6 t R
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' y9 e, S# ^$ B9 B+ b
SetTitleMatchMode RegEx+ H. B- j' v) f0 I- L
return
- [+ k/ m, h+ R* i ; Stuff to do when Windows Explorer is open
2 Y, R7 b( V# ~/ o1 G6 T ;
% \6 d, J a5 j- S4 C: N! l D #IfWinActive ahk_class ExploreWClass|CabinetWClass1 ^) m) b7 W! E# G3 W Z
; open ‘cmd’ in the current directory/ S `* q# L l4 L: [; z& W- v: l
;
+ [# Y: M; h" D# @ #c::/ U F! r! v( O0 `
OpenCmdInCurrent()4 Z6 A) c5 Z) K; I" K
return% o, L. U! F3 w( n$ d
#IfWinActive) t/ E; [* H; T2 l9 f; D/ k/ N
; Opens the command shell ‘cmd’ in the directory browsed in Explorer. }# E$ ~) y3 B9 j" p
; Note: expecting to be run when the active window is Explorer.4 f% K( E& C d% _+ m1 Q( S
;! s P0 M# z1 I3 H$ {
OpenCmdInCurrent()
( W u, E) l8 [: o0 r8 g {- P9 E; p2 \8 n0 D
; This is required to get the full path of the file from the address bar
5 F! [4 h7 E, R5 f$ w/ G9 \ WinGetText, full_path, A, _3 G) R0 N; x: b. C
; Split on newline (`n)
3 g/ g n0 D) E: }; } StringSplit, word_array, full_path, `n
( j- b8 W& F P* S' F2 g ; Take the first element from the array8 `: C8 y, w* G7 j5 W1 K( T
full_path = %word_array1%3 k+ z) a: S. j
; strip to bare address
7 j/ S3 o9 o4 t) B( F/ l full_path := RegExReplace(full_path, “地址: “, “”)
# R1 X L1 O9 |5 M$ T, f# D ; Just in case – remove all carriage returns (`r)
; Z H* Z! Y( j4 n StringReplace, full_path, full_path, `r, , all
' h4 t$ L# _$ V8 s2 F IfInString full_path, \2 e7 C) N6 q. z8 W) g$ y2 Z$ u
{7 I3 U( p3 o0 C
Run, cmd /K cd /D “%full_path%”
3 r M; K+ P# M5 c8 Q }% E( Y. V. S9 g' e4 o+ \
else
% [1 x, b, R( h% V. Y% V: G {2 n5 v; l& Y. K
Run, cmd /K cd /D “C:\ ”2 k$ F; _6 n( X# }* K: o
}/ ?9 Z7 _. G6 x: {/ k" a! u
}2 C- E' X; F. R( i5 P* z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 ]" f' K1 i8 }6 G* v) {/ ` 这段小代码肯能有两个你需要修改的地方
3 i9 f* _4 S0 s 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 o& a* H# _" U% X. k 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- A# h, }' C, C5 V$ u
|