此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' u6 n6 Z) O( c8 s
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. R1 c9 B1 F$ q; l
方式一:
. T. d5 J2 V' F# l! t/ T- M: r 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ q) Q4 y) ?, \, X) }* X4 q/ V
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ P6 X% |( S2 _6 ]! H
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' A( w- X Z# q3 c1 A7 x 方式二:* Y# C' X" b& `
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- X2 a$ s3 b5 p( G- U2 H8 W
SetTitleMatchMode RegEx
. f$ E0 ]$ B" o7 M4 V return# W: w& s# o7 ]5 r2 R
; Stuff to do when Windows Explorer is open
. i8 [4 D8 X, [) I ;* \' z3 ~( ]9 ^3 p8 _7 L# y
#IfWinActive ahk_class ExploreWClass|CabinetWClass1 _, F; @2 C% P4 U) Z
; open ‘cmd’ in the current directory6 f Y# U7 F1 r0 u+ w. _
;( {7 J" h# G8 v F( t g+ @9 R1 ]
#c::
5 P* E/ \! r! M+ X. I7 f# v9 ~ OpenCmdInCurrent()
& X5 Y# K! w3 O. k: R/ \3 Y+ j* T return- G* ]" Y+ c& V! z; p& ]1 j
#IfWinActive
; n5 W D5 W" `! s ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' j- ? q, m3 c% a: m ; Note: expecting to be run when the active window is Explorer.
k# w4 S: `) [ ;
8 d6 m9 E1 T& [/ Y" F, @- W4 p OpenCmdInCurrent(); I. L& c5 e9 y/ }# A5 b
{+ e# L9 B+ @; Q0 T% B- b" s. `
; This is required to get the full path of the file from the address bar# v& M+ F9 I k/ p% g3 L5 Z) n3 Y# b
WinGetText, full_path, A
9 Z8 e( ?# ^/ j" m6 ? D) { ; Split on newline (`n)
: \ [9 l' j m$ v# A/ h StringSplit, word_array, full_path, `n+ ]4 s% u% ?6 _" e) n
; Take the first element from the array
; o; q: h2 q# P+ T6 D full_path = %word_array1%
5 `4 d* F+ e5 C; Z ; strip to bare address
; ~" h7 r' W$ H% K# t full_path := RegExReplace(full_path, “地址: “, “”)/ {8 W" i" U8 ?2 g, T9 E* ? D* i$ X. k
; Just in case – remove all carriage returns (`r)
! E& g4 U8 a- {( o- x: a" k StringReplace, full_path, full_path, `r, , all h2 Z# _# u( k2 P
IfInString full_path, \
/ }, o0 w4 x* S. q$ F2 V1 h; ?+ x9 { {' u9 H# k A. w4 A" g# z) ~
Run, cmd /K cd /D “%full_path%”
R3 Q; w: C5 w' O9 I3 @$ ~ }
/ g' T' S# J; W: d B" V& } else. V6 T0 q. ]2 [4 ^' {2 r5 ]
{
5 T; u6 M% H0 U. M0 M Run, cmd /K cd /D “C:\ ”
$ }) J' U) z, H- o5 f* T1 d+ r3 X5 x }
( V; [' T2 z+ y8 l }7 C* T. c ~( t4 p8 h9 d8 H3 h' v
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
' s- b4 R+ a! e- K 这段小代码肯能有两个你需要修改的地方
( C9 J4 w6 N3 E 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% r% J I2 R- `! o( O; X+ g; l 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 K" U4 Q5 \& B- {0 `
|