此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- k5 n: P1 G/ _ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
# b/ V% g8 L) ]8 m 方式一: u9 x+ J6 N6 g1 ?; Z# W% ?' _
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 D9 q( C* w" \) r" w9 X
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& ?' r' F& C1 V+ W HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" k" Q4 W( [2 |1 W+ v
方式二:8 B2 y. g! b0 R6 ~# W$ Y2 j
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' A0 {6 ?- v, c* l SetTitleMatchMode RegEx5 Y* e: _" Y* L( N
return& P1 _0 `# {9 f3 e/ s1 w
; Stuff to do when Windows Explorer is open2 g: e# H; d# t4 z% |
; {" m3 j4 h9 V+ Q [& Q
#IfWinActive ahk_class ExploreWClass|CabinetWClass
# z! a! j% Q( B6 N3 _/ r6 l ; open ‘cmd’ in the current directory3 X' A! p( P- s3 V+ k$ |9 l b
;8 k, {' N# \# u+ t. g C" l) D$ N
#c::
, C. ]$ Q( b; X3 e" l OpenCmdInCurrent()
3 z, R# I3 E' A/ j return
! C/ ~ E" y+ H' } #IfWinActive
* u9 Q+ v2 B( }3 f" n ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& D7 F8 ~) u& B2 J
; Note: expecting to be run when the active window is Explorer.
7 x* p$ m' R& i: s ;! @6 x4 x. D+ k: p) N7 S+ L! s
OpenCmdInCurrent()( q, S- g. I2 E& @. {( F. r8 W$ D
{/ g' j9 X2 a- O# z! r5 X5 L
; This is required to get the full path of the file from the address bar
) z* }* L" |/ u$ Y: ] WinGetText, full_path, A
: T- e* \! e: P2 e; r ; Split on newline (`n). \: f$ U/ _% `2 y0 v7 _, d4 Z
StringSplit, word_array, full_path, `n
0 {* ]5 R# E% p0 R1 ] ; Take the first element from the array
1 `& _, i6 r0 z! s" l. Z5 L/ o' _ full_path = %word_array1%
4 {( u; }% q8 X, ~ N" w ; strip to bare address
0 L& |( Q0 j9 y: e full_path := RegExReplace(full_path, “地址: “, “”)( B$ v& Q" a# d% [/ R& Q! D
; Just in case – remove all carriage returns (`r)
3 W0 A& u9 D- ^5 T' g StringReplace, full_path, full_path, `r, , all
& g2 z3 b {6 E; K+ T1 M IfInString full_path, \
2 S( U5 n. E C k& `' r g, ] {4 r, q* K% Y H+ d6 Q# A5 F, s8 Y
Run, cmd /K cd /D “%full_path%” [( S; V2 {! k
}9 ?, K# V6 g2 X7 t6 T2 ~9 ]
else+ f7 y5 X9 M8 Z2 \* q1 @
{
, U" ^7 m/ u- }+ s Run, cmd /K cd /D “C:\ ”
7 k1 v5 _4 s4 U5 ^" s2 F2 C- \( L }
+ i$ i' _- v! F: P+ _6 [, g) } }1 Z9 f$ G- l& A) i! J" A& k
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) e" l8 L8 l# ?5 h8 w/ D
这段小代码肯能有两个你需要修改的地方
$ S# H6 j Y/ i: W, ~0 Q7 U% {% F 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 u# v; q+ h, r9 A& [
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' G7 }! Q) V+ h9 N$ g, v+ t |