此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 K" \, R% B( W: q) ~0 N
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: N9 Z; k6 E% L* d: x; X 方式一:& d6 Z3 S$ r7 C6 T( B" V( A' \
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- t' U) [4 o7 G* j
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. q7 @9 w. z' z9 }+ I/ C HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( m6 z& q! p3 e3 F \) P/ ~
方式二:
' \; z$ d, l: u- k% ?! b$ E 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ h/ F8 f% x2 u# \% \- J SetTitleMatchMode RegEx9 W7 _* G& |7 t% N/ q% v/ L
return
0 H: [: {8 H7 Y* [) n% I ; Stuff to do when Windows Explorer is open
9 n6 q# {) o; Z- K1 x ;
" z: K# T' n' b #IfWinActive ahk_class ExploreWClass|CabinetWClass
% D; J. q. n( D ; open ‘cmd’ in the current directory- i: t# U6 {0 v, ~8 P
;- j- f$ f5 G8 b4 g. M1 [
#c:: y" o+ g% [0 _/ N( v" A1 V
OpenCmdInCurrent() i8 w, h# v) z* b2 g( _
return
! e& J$ }# g# {2 r #IfWinActive
, b1 W7 W. z: o( p* Q* P6 s8 q ; Opens the command shell ‘cmd’ in the directory browsed in Explorer., W7 f# b5 o0 Y1 X1 a/ s; z
; Note: expecting to be run when the active window is Explorer.! ~, W! s- ]% e& t0 l
;
8 Y% u6 \# g' [8 A) M. w7 d OpenCmdInCurrent()( w$ w' D0 J* a0 Z2 M3 T
{. I9 g+ c q" x: |* X) r9 u; B
; This is required to get the full path of the file from the address bar3 ^0 p! z) a, k1 g
WinGetText, full_path, A
% o6 P2 F$ s8 H o3 w ; Split on newline (`n)
, y( m7 I7 G. u0 ]9 ~+ Z0 p StringSplit, word_array, full_path, `n+ ]: B P+ O8 j
; Take the first element from the array" D! W/ J* p: }. H. q- [4 g
full_path = %word_array1%
/ M' a9 e; g, |0 o8 B4 \( s* h! c ; strip to bare address
5 G+ S) K2 o* k3 }$ S full_path := RegExReplace(full_path, “地址: “, “”) E' }# o" V% e0 C- |( u$ ?
; Just in case – remove all carriage returns (`r)
/ w( Z0 P( v6 [& b$ [% K StringReplace, full_path, full_path, `r, , all
4 {$ ^3 s1 p& [9 S' h IfInString full_path, \
& A2 U" V1 R: P ?+ j {
$ M" x# v; q' S0 j Run, cmd /K cd /D “%full_path%”
' M* I- ]2 X6 z: X) T }
5 A( r+ L6 d% b* K r1 n0 [ else) Q& n& Q a8 z/ K. W- X! E4 T
{7 ~" r2 y7 x4 n+ T, W' b
Run, cmd /K cd /D “C:\ ”3 z, D# e4 J- i) C5 Q6 C2 A
}& F! T& ]9 A8 P3 @
}
6 V( h$ d+ P" [/ H4 N 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 R1 V0 ~/ ^9 n! q
这段小代码肯能有两个你需要修改的地方
4 W/ F g. J9 I p5 Y6 x/ K 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 C A8 l% {- @ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: s8 a3 {* ]' E; t9 O
|