此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 c6 i5 P0 z" R( B0 T* j/ x 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, C4 l# a; w4 H! O8 J5 w
方式一:
( t& X E+ e3 q3 u J3 D# L 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( P Y. U3 Z! ]
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
Z3 O9 [1 }" b Q4 O* V4 Z: U( M HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 K/ Z. p7 B- @* U3 ` R
方式二:
: o8 I) C% q9 a6 [" M! o 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 E- ^/ g- E- v @1 o SetTitleMatchMode RegEx4 }% W3 L- i* y$ c
return
3 c/ s2 D3 i6 i: d$ G0 P7 G2 E ; Stuff to do when Windows Explorer is open
: [7 E4 ~8 l* `6 M/ M ;
; W% F+ S4 ]1 y8 s! }7 p& ? #IfWinActive ahk_class ExploreWClass|CabinetWClass) q) i+ g0 { e4 ~4 H2 ~" T
; open ‘cmd’ in the current directory
/ L8 g+ u# q k# Z. d1 K# q3 O ;+ _1 R B) p7 T
#c::
8 z. q2 v+ y* @# m) o- H/ @ OpenCmdInCurrent()
. W* K# `2 v$ s* `% Z$ a0 \3 B return/ x: F/ w2 m. n( f7 W3 E3 R
#IfWinActive% f, u% }1 J& Z% l3 E
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. D( `6 {! o o; u2 N ; Note: expecting to be run when the active window is Explorer.
3 u7 e! t/ Y3 E9 g ;, } I' n/ t6 u3 z9 V
OpenCmdInCurrent()
: [8 n6 Z+ V1 `4 G {
" ~) m Y E8 B8 |% R ; This is required to get the full path of the file from the address bar' Y0 T4 h% ]! \
WinGetText, full_path, A
8 { W1 Z! T! t% Z( L ; Split on newline (`n)
& L3 f% P# u* c! n% W8 B StringSplit, word_array, full_path, `n
- z; k8 f# e: ~# @3 `7 ` [ ; Take the first element from the array
Z2 _6 b9 O0 @ y full_path = %word_array1%' t! D5 G+ I& _2 W# y7 N
; strip to bare address
* |' C+ i4 D* P: R1 G1 O full_path := RegExReplace(full_path, “地址: “, “”); [( f1 N5 |- n6 o# c
; Just in case – remove all carriage returns (`r)
! i$ K2 m. b9 j4 w' j6 S m( R! F$ ~ StringReplace, full_path, full_path, `r, , all
$ R/ Z" y" k5 ~$ z- l IfInString full_path, \ f+ L% Y- e; X) j; f
{. E0 X5 v$ G ]# H, N
Run, cmd /K cd /D “%full_path%”; m" Y( r- f* Q
}- b& x6 p/ n2 e* g; j) P
else7 r4 g z3 @7 ^$ G8 N% l* L
{3 [; ?# e6 I8 y2 s; p
Run, cmd /K cd /D “C:\ ”/ a0 D- j2 D6 V- ^5 t
}
& }- v3 m" M5 A& \( ?4 b }
3 D& l4 {- F: [7 R H5 f( o2 Q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& |* V5 j% C$ m3 o: U
这段小代码肯能有两个你需要修改的地方7 ^9 `$ y, ~2 V3 f9 @% |0 b2 _7 K
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# J( U& ]2 B! Y6 H0 u1 N! B8 ?5 P 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
h) [1 L. y* A) k1 F g |