此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ }7 z' Y( `: s. \. n2 `
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 D* f+ j$ J0 q6 E4 j 方式一:
$ x" w% r: \2 h* U! }2 c% p: A 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 e& f" A; x: @8 g: S0 J$ S: ~7 n
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- e5 u& \* a: }& `# U4 c) l# o3 ~
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ r7 \+ T+ K7 x& Q& h" R 方式二:
/ \: S! t8 j9 R1 [6 V4 W 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% e' |5 z% J4 e SetTitleMatchMode RegEx
0 n# L. e6 W+ J- s, c C return
" N/ F M2 p' r ; Stuff to do when Windows Explorer is open+ |7 r2 L; h4 j; x* K8 V
;" I2 A4 V4 _5 e) h9 g0 X# K
#IfWinActive ahk_class ExploreWClass|CabinetWClass
6 I0 }& H/ }$ Y( r4 T; { ; open ‘cmd’ in the current directory
5 n ~ W2 W# @' _' \! v0 X ;2 C% I0 [! ?1 L+ W
#c::. z4 h" d) N* n! O, N; i" {
OpenCmdInCurrent()
8 `* ]- a x: g9 P9 D4 g return
, E0 @" x* X0 y! B" J5 i #IfWinActive# Y2 i) m+ I7 b0 R8 k
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- x( j( ?: h) x8 b) I# ] ; Note: expecting to be run when the active window is Explorer.
) u/ v: g8 f/ E' d! U! Y ;. v( f& M9 N- h h
OpenCmdInCurrent()
* ^/ r; n; j1 ?6 j1 \ {
( q* V& T4 H* \: f( u ; This is required to get the full path of the file from the address bar3 ?$ B" A* L' K0 j6 j3 U
WinGetText, full_path, A
- E5 m$ r* d& t" I+ P& n ; Split on newline (`n)$ [2 L9 @7 P+ J) M( f
StringSplit, word_array, full_path, `n
5 B; Z4 F& ?/ h, C. l ; Take the first element from the array
: L" O4 }# Q: R& B4 } full_path = %word_array1%1 {9 I6 m/ J7 m3 Y9 k/ C
; strip to bare address; ~" ^: q; X) [# N; X
full_path := RegExReplace(full_path, “地址: “, “”)
7 J' w. }0 }' b4 j2 h* X ; Just in case – remove all carriage returns (`r)# b0 c$ Z& A2 v T4 j9 l
StringReplace, full_path, full_path, `r, , all
+ C4 \( r# E0 ~. O) G# z/ k& W! E# P IfInString full_path, \0 m4 y e$ G& D' g
{" w1 G b4 w4 Z0 a) w6 J j/ M
Run, cmd /K cd /D “%full_path%”
2 D. p1 e- G9 V* b; T }
/ o/ s: @$ B1 z; A/ a else
" |& D0 q/ j9 Y/ o2 }) k) J {; m3 V2 x: A6 l2 T
Run, cmd /K cd /D “C:\ ”
O( ?# C. J5 m4 \5 t }4 o4 m0 r$ A, k/ U6 ^8 s
}
! S) F2 G+ N$ V/ i# b 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 ]# [, E# [$ f7 J6 ~/ I
这段小代码肯能有两个你需要修改的地方
2 q" G8 E, B/ w# R9 z! m6 v* j6 |* r5 |5 t 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 B b* T$ S' j2 r- F 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 C5 Y) V# o# G" b |