此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( {, u! N* S+ X; J" r0 v
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 e$ w% e6 C9 |* Z5 e 方式一:
9 G/ _5 B! c! A; f1 p3 r 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
+ c# l9 u0 S6 a 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; ?. b M, j9 y8 p* T) l7 c _% \
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 n% X) @9 Q+ G 方式二:$ W' Q0 s" Q( a9 z5 v8 u! w
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- _$ y+ a- i; V a# r% I
SetTitleMatchMode RegEx
9 N+ p/ M2 A# M6 X( N5 C$ M r7 P9 w return
7 b$ X- X, J7 V. c, a, P- } ; Stuff to do when Windows Explorer is open7 ^9 @0 Y6 a& F. Y' f: w' D
;
% c2 v! G7 E( |$ k #IfWinActive ahk_class ExploreWClass|CabinetWClass, i8 ~& g# i3 ^% j9 W! Z" `
; open ‘cmd’ in the current directory
2 n2 m1 s2 r/ c: c ;
1 u; i( R% F. u #c::8 `0 l+ [- Y5 q5 z8 N% i
OpenCmdInCurrent()
8 M+ t" M. d, h5 T8 f7 {6 G return
0 x8 d( K* }0 \0 ?9 I #IfWinActive
8 d, V) o8 k. b# a ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
$ Y3 z% f+ x# y% `0 V ; Note: expecting to be run when the active window is Explorer.* J& v- T/ a+ i& ]# F0 ]9 \
;
. V/ \2 h" X$ c. b. u OpenCmdInCurrent() B9 @3 y8 b+ o! x [7 A
{7 k4 ?9 P5 |. i' Q$ v& a
; This is required to get the full path of the file from the address bar
9 e: o. f, f; z% H WinGetText, full_path, A
* H# L/ y: d3 G$ k$ v: b ; Split on newline (`n)
: D# P+ j7 u. H7 U+ z StringSplit, word_array, full_path, `n
" b# M$ \4 B) S ; Take the first element from the array
- Y; L& E# L' Z0 q5 q/ W full_path = %word_array1%
2 P4 n4 H" h) }$ d- H3 s ; strip to bare address! {% v( k/ z2 M
full_path := RegExReplace(full_path, “地址: “, “”)
& n! A1 P" [3 Q4 S$ ^" U ; Just in case – remove all carriage returns (`r)
2 k! S* C/ M( Q: Q% _- m* q8 c; O, E StringReplace, full_path, full_path, `r, , all- X/ } G5 c; ~! v0 P; e
IfInString full_path, \
8 T1 `& v4 m) g. b {7 n5 h0 ^* C. A: H, y3 \
Run, cmd /K cd /D “%full_path%”8 B. b/ w9 e8 v: k' H
}2 h) B; |3 Z' g+ j9 e
else' a. \, Z1 k" b2 D. F! P9 C
{
' h$ G' n; \" p Run, cmd /K cd /D “C:\ ”
2 t- l6 {( Y% |# f1 c- ?2 s }. R( L9 n& I: p6 V: \/ v4 K9 j
}4 S/ X8 R8 ?+ t/ [. N! G% d
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
% |( W5 h# Y8 @2 q& w: B9 Q 这段小代码肯能有两个你需要修改的地方
8 `4 S" N5 R: R: O j# e2 n! ` 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. e5 M% W! X# I+ j- u0 { 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 E' I% M6 N+ u1 o
|