此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# S* S9 y6 V. L 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。: d: G0 L: S" }) F4 {& X0 K) q
方式一:- r" L- Z" j' G: [# H+ ]5 j, n
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 q1 V0 f$ H; i
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 f1 |0 c: @! c0 s' \ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( U" `5 h T% Y2 y
方式二:
. M( F" \+ y( Q6 x+ s7 f: F! c 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: E$ l# R) O! Y0 {" U
SetTitleMatchMode RegEx! W, d$ _# N8 E* K- {5 J
return
C& }9 C* w: `5 A& n ; Stuff to do when Windows Explorer is open* K5 ~+ A! A- m! r/ l% h
;9 I% Q& k. D1 p/ ^
#IfWinActive ahk_class ExploreWClass|CabinetWClass
7 }5 }: N$ t( w3 V7 g% l+ w7 |! i9 t ; open ‘cmd’ in the current directory+ t+ E) N4 P/ m9 w4 `, N
;
4 H6 Q7 ~' @! _# u4 d1 X. \# ` #c::! X: w" i7 g; ?- Y
OpenCmdInCurrent()
" l3 `! F; f$ [* v return |2 m2 r( p8 C9 `1 o; s& q* F: d3 C1 p3 S
#IfWinActive7 O2 T5 f3 q B
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 l' P3 Y; j# E7 I
; Note: expecting to be run when the active window is Explorer.
! U! r1 B" l. P. f5 ~ ;0 F! K Y Z" W* b
OpenCmdInCurrent()
; ^+ J% a( i/ q. `" } {
2 r' ]0 n! B* C: s) c4 S1 e ; This is required to get the full path of the file from the address bar/ C* G8 r# C _2 [( N
WinGetText, full_path, A
7 Z+ d5 H+ }, K" v, s ; Split on newline (`n)$ m" a0 F( f5 W5 y2 u
StringSplit, word_array, full_path, `n
5 Q% w( O' m0 G: t* l ; Take the first element from the array
: C' H* A: f+ @; `$ U full_path = %word_array1%
" Q' ~6 E, A% U$ a9 P ; strip to bare address( f0 S' J0 e( Z' f* C
full_path := RegExReplace(full_path, “地址: “, “”)
/ |; S, J$ ]1 D ; Just in case – remove all carriage returns (`r)
1 N- O4 B$ s7 b7 j StringReplace, full_path, full_path, `r, , all, v' Z3 | p1 ~. l
IfInString full_path, \8 g! r4 `* p" E6 ?0 L# v
{
+ L# R; W4 J% g9 L4 i1 M Run, cmd /K cd /D “%full_path%”8 t1 ?: M8 v- H! G
}
' p @# q/ D% Y: M! Y# v( R: t else
' P* p; b6 Q9 {# I$ w {- ^& ^- u; D h
Run, cmd /K cd /D “C:\ ”
5 L5 n2 P0 U. i( L/ T8 Z% [ }
0 ?' M5 U7 a4 Q5 M: u+ [9 X: L }
& K) R2 Y+ e+ Z) X5 Z: [9 }. P: [ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 |+ m z1 x, k: [; H 这段小代码肯能有两个你需要修改的地方
1 I# c) o ]7 u) q$ j 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ P( P$ L% @ i, n" e- k: \ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! H- f; P1 p! y( U) L |