此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' y& y( b7 p& B: m5 R/ A
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 v$ ~/ S" N) Q. @) u f" E7 c3 [
方式一:
/ g. B" `( q% N& `8 I5 {" Y" H ] 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- Z7 X* ]: e2 \* W0 ^
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; t1 j8 z- [6 P. z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* J+ f- \+ k D, z 方式二:. C. j* q$ C$ n) V9 i" y q( @2 B0 F
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ `' j2 b) x5 @8 e SetTitleMatchMode RegEx
, ] _! a w& }% U return
! C# O$ v# a/ `% M ; Stuff to do when Windows Explorer is open
3 w! i2 @, Z: C: K$ B ;3 _& F" \2 u( W S
#IfWinActive ahk_class ExploreWClass|CabinetWClass5 t& g4 C. U/ {7 C' j1 o. }; P* M
; open ‘cmd’ in the current directory
: ^+ E! F: `0 s ;1 T7 Y* y$ `- N) P' w0 c
#c::& l' t! [2 c+ ?
OpenCmdInCurrent()
3 t1 l( Y! l( r, q( j1 }0 `% q" F return: R5 W7 O1 ^8 q1 k1 t# x# ~% F9 f
#IfWinActive
# s8 }+ O, q" m/ D/ D, r/ g) `8 ~ ` ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 c! w5 j, v2 i* _: G5 z3 } ; Note: expecting to be run when the active window is Explorer.
( n" a7 a [& @9 ~2 v. I. | ;
" p% I, }( c. E7 M; I- g6 V OpenCmdInCurrent() @$ x2 T* {; c8 }: h1 L
{
; G3 q% n3 J* _* y5 b4 f# E ; This is required to get the full path of the file from the address bar; p; T% @# R) R2 P: [6 q
WinGetText, full_path, A
. o+ _ O' o* B; p( r1 R, u# X ; Split on newline (`n)5 e/ X- i$ o" J F. V
StringSplit, word_array, full_path, `n4 E2 h \. Y. u) o
; Take the first element from the array1 f b' W A# ?' q5 d) b7 P+ c4 n
full_path = %word_array1%9 ]8 R5 o' e' g" p/ U5 m/ Z
; strip to bare address2 }& d J4 G3 p9 S2 Z+ u3 O
full_path := RegExReplace(full_path, “地址: “, “”)( u9 M! J( L8 q. Z, V6 O) M, g
; Just in case – remove all carriage returns (`r)
+ W) B8 ^/ l! _; G8 t3 s( ~4 r* O StringReplace, full_path, full_path, `r, , all
: g7 t% j& N: Y- | IfInString full_path, \* I# Q* C% i4 Y: M
{3 n) k. m7 j/ F) I
Run, cmd /K cd /D “%full_path%”: Q5 c& I% V* K
}2 E2 f7 @( N8 b+ Z- s! b9 I. D9 h
else8 f& _4 r) A9 Y5 G
{" C$ B! E" b3 k" K) q6 ~+ u" g. D: V4 K8 c
Run, cmd /K cd /D “C:\ ”
- g" P& e* K0 V8 F }6 ]4 E( H+ H0 g2 _* h3 \
}% o5 p0 Z, {+ \( C9 W. S! m
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* n; l j0 B4 ?
这段小代码肯能有两个你需要修改的地方' s) {+ i% @4 m( q0 J- W
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, K5 o, k/ }) v( t5 | 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 Y ^* V4 E1 L: S; Y0 z- Z
|