此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ e* J- \6 i2 C+ M4 l
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ A5 k3 \ d1 `5 W6 \% E& O
方式一:) E t3 ~5 o0 V' b& [% v* w6 Z$ ? D
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( A* {' g5 m2 |% C( t: |! @ z0 z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! ~6 M7 Y6 Y2 q HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( U. C& d+ U- V9 d" E: @8 Y" M; A 方式二:
; b$ Y' m; x& W" X 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( G1 _/ J8 m3 n2 i SetTitleMatchMode RegEx
1 Q3 G+ l3 p/ c/ ~2 `5 j! V+ W: u# E return
/ L+ A: }) f0 s8 q8 w" c ; Stuff to do when Windows Explorer is open r. ?9 K1 C; g: v
;
: R0 v% T0 `# D. _' f) c #IfWinActive ahk_class ExploreWClass|CabinetWClass
0 X' f' C3 i; y: a+ c( g! w6 u ; open ‘cmd’ in the current directory
2 w0 G1 i8 p. Z/ O6 h3 g ;
# D) E. ^ E& b #c::
8 J1 p4 V( y* g& e# w OpenCmdInCurrent(). d; r$ q& }0 u5 T' a2 T
return5 A4 x/ k4 V, q/ i& u ?
#IfWinActive
6 @+ u* m( a9 s' l1 z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer." o, f5 a8 x9 a
; Note: expecting to be run when the active window is Explorer.
. N' l% {- a2 A a$ b- J ;
+ i* @2 l( l. L' S OpenCmdInCurrent()5 k4 s" C" O" Q% p) e
{- E$ B& M3 x6 l$ Z/ ?+ ?
; This is required to get the full path of the file from the address bar5 I6 h6 m5 A1 S8 @# o
WinGetText, full_path, A
8 P7 b8 Q) ?! v- a" ~' O+ R; j ; Split on newline (`n)3 k) f7 E: n+ I v4 E& O
StringSplit, word_array, full_path, `n# @, g, X0 x; C% b0 d
; Take the first element from the array" |% P" N4 P+ ~6 Z2 G4 r
full_path = %word_array1%# u3 u7 Z( g1 ]: @, e
; strip to bare address
* d! V o' ]$ w3 P) X# g full_path := RegExReplace(full_path, “地址: “, “”)9 I; V2 r1 M- a# Y( Q; u% H' n& k/ t
; Just in case – remove all carriage returns (`r)
J/ e6 r, w6 d4 V+ [ StringReplace, full_path, full_path, `r, , all
# j4 V& L" C- |* n2 r# ?6 \ IfInString full_path, \# I7 @- T K7 U1 H( T! T
{% q1 R) P1 q, M
Run, cmd /K cd /D “%full_path%”
5 y; [2 P- a9 Q" S6 H }
f; e+ J. }% | else
% I* K8 w1 s6 }* {4 O4 X% m% y {7 i1 Z" h) o2 ]1 r
Run, cmd /K cd /D “C:\ ”8 f; I" e. t3 y% j K. a
}: {- o/ x0 v7 e7 @) K0 M/ O& A
} v& S2 Z% a# r
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" L3 ^* n% k4 t
这段小代码肯能有两个你需要修改的地方
1 X {: t4 a# u' W7 p 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) `/ R# n, A- V1 E7 ?# g. S
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 l: L! p( e4 x+ j0 B2 N# [' r
|