此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ B) R2 f5 P6 o6 S1 B1 q7 f* d" X
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
+ }! F9 ^( G. a# P( f9 a+ Z$ l$ h 方式一:
/ A8 f! i& D" l8 r 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' U4 z, p" T2 I9 r
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ R% O& @$ g& B, k2 }% F" g7 k$ k HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ f# C8 m' B0 G B% E 方式二:0 \3 E; D5 Z2 a" z4 _3 Z; x
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ _; \8 I7 U! z5 O0 ^2 t( z SetTitleMatchMode RegEx- V" s" l) X4 U, w9 C
return
7 q9 I: {" r6 M5 C. h ; Stuff to do when Windows Explorer is open
$ {# }1 S! x4 L" b ;
. K5 \! i7 A* U5 ?! ?0 \ #IfWinActive ahk_class ExploreWClass|CabinetWClass
9 o- U( p7 Z0 x; k ; open ‘cmd’ in the current directory
" ^# G& I- F# J5 j% j ;
& v4 g+ J4 w& y+ |& I& [! b #c::# N1 F/ `: r8 ?( U1 o, i
OpenCmdInCurrent()
; i W* E1 u4 o- L# n' d return
0 ^' |1 z% @% R. B% w #IfWinActive# a1 `# P9 \- ]; W5 C) t& h
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: ?8 L+ ]# N! @, D
; Note: expecting to be run when the active window is Explorer.+ A% _( ]5 g; m" a" P( Y& V* v7 G
;
! |$ T* c5 n% T4 _2 b/ G+ f" ?; r6 ]- f1 W OpenCmdInCurrent()" z2 _, W( d2 b+ ~9 `
{) |4 ~" j9 p* _
; This is required to get the full path of the file from the address bar
* @ W i$ s, B. O7 Q WinGetText, full_path, A
8 V3 L) P8 i9 D/ q' M8 }, e3 `- J0 }0 a ; Split on newline (`n)3 P+ E7 c& \2 J( s3 W S6 c c" [
StringSplit, word_array, full_path, `n! M* o7 D( |/ h
; Take the first element from the array0 R) K7 v( \$ p9 b2 y. ]: l
full_path = %word_array1%3 I) X. {7 M( d- i6 _
; strip to bare address1 I. S5 e7 Q) ]$ X" N4 U
full_path := RegExReplace(full_path, “地址: “, “”)
7 Q* {" k" n: f: F- z ; Just in case – remove all carriage returns (`r), E/ C) a1 o9 w( _( _% |
StringReplace, full_path, full_path, `r, , all
: r- {3 w" N* ]0 E3 A5 B IfInString full_path, \
- f, C- q4 b6 ]% J {
; y* Z2 C' x' ]3 B; ~# q Run, cmd /K cd /D “%full_path%”
4 V, {. L) m- x }
! R! v* k% b0 K ], E) R# K else
. H$ e! ^2 D7 A( P {$ f* m! }' w8 d+ D5 t# H
Run, cmd /K cd /D “C:\ ”
, o7 o* R" v5 m- G }
% o0 h( i C- n/ y6 E }6 k5 \: q) q) u! m! n9 O7 j
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ A# j0 |: Q( R 这段小代码肯能有两个你需要修改的地方
1 h! U% J6 c2 I2 O, r( ]& Y H 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& D6 B9 R% b: c 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “/ r- t8 Q8 g- \5 I& r
|