此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: m& [% B+ R- p2 |* e3 }/ g
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 G9 K4 z# b6 q9 P1 L; ~
方式一:
# ]# G0 b8 \0 P& f- y5 r 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( d* Y" ]5 I% a; `5 W* b
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* ~+ x5 P# b1 C4 L+ h1 ?# S& J9 \
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( b4 T7 O. L v7 x7 i& u* w 方式二:6 s4 r8 @, |0 n! S& S& h7 \4 @
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 _7 q6 l6 q% H" B8 k
SetTitleMatchMode RegEx
+ S! h9 |! p& W return" i: J" f2 \: F8 S
; Stuff to do when Windows Explorer is open6 w3 [$ J* E& t5 t
;
2 ^6 r, f5 H& u, A" t$ \1 Y7 ` #IfWinActive ahk_class ExploreWClass|CabinetWClass5 W, N: O$ |. l
; open ‘cmd’ in the current directory
" g: n- B' I1 `& [& O) K+ }$ Q! H( ^ ;8 L, r! W; r6 {
#c::1 d, W1 H, e0 a4 O* j
OpenCmdInCurrent()
7 ]1 H7 \: M* {$ M8 \/ U0 x+ Q return. F$ r" B+ x9 y* `$ o* G: ]
#IfWinActive
0 K0 ^1 |+ }6 y% X" i/ }1 ^& |' O ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- X. d% f w8 v( } r) ^
; Note: expecting to be run when the active window is Explorer.
k5 R9 u) S- k3 q' t ; [; N3 a3 f- `0 Z5 }, ]( n
OpenCmdInCurrent()
3 {" N: v6 q W7 R0 |% C4 n% U {
" R( D" u7 p$ ?0 T! @$ a: R ; This is required to get the full path of the file from the address bar
t7 l1 i' [( i: i2 @ WinGetText, full_path, A5 g" C$ F# c* V% f# z, B9 E
; Split on newline (`n)
) K4 W+ N- n2 C/ [( l; l StringSplit, word_array, full_path, `n. X# _: d9 i; [* k. z! T
; Take the first element from the array: T9 T: T. X) V$ O+ A
full_path = %word_array1%
2 A4 P) M( i. f9 x ; strip to bare address+ w- m: x2 O( L/ C7 q& T
full_path := RegExReplace(full_path, “地址: “, “”)( \2 @: Q- \; u) d+ \+ M( j9 [
; Just in case – remove all carriage returns (`r)
6 ^: q' q( S$ ?4 M StringReplace, full_path, full_path, `r, , all+ x( v1 U0 P- M3 x. X/ x n! X' v
IfInString full_path, \* N% S+ v2 l% m4 o
{
/ z. b3 t& Z) o0 j* y# O; r& e" U Run, cmd /K cd /D “%full_path%”" u$ h7 L4 n `7 L" J( [
}) c4 Y7 ?: |% T5 G% A
else
?* G/ w: P8 G0 z' g% r- b, f; r1 C {
: }3 J5 p8 x* [0 m1 ` Run, cmd /K cd /D “C:\ ”
b: ^- P0 ^3 n. M- ?- V }0 D+ ^1 ]; v; l0 i
}$ L$ x r0 |9 B
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( E R: P# J# d: ~
这段小代码肯能有两个你需要修改的地方
& B6 w; K" h1 d% B/ I 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' q \5 f2 j; Z4 `- O9 A
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 z$ W' M8 u$ `/ I
|