此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) ]- @2 E8 R' R* b5 q' |
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; b( P! b5 q, z7 T% R4 u
方式一:
" A. k- e) ^5 o" b 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
; K" G. f1 |! v1 {* y 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. x, e% u. K$ `- T HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 ?, B1 \% A4 G3 q" F 方式二:
- V) `& s; \! q9 u 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) `- x5 r7 @1 ]* R) K' t
SetTitleMatchMode RegEx
! |- R, e. Y( m9 J2 w return
/ M2 X2 V& C5 Y! X& d: C7 F ; Stuff to do when Windows Explorer is open
/ z. E6 b# X8 O- Y ;
9 o' `- _6 k! U5 M2 v3 B6 ?. K #IfWinActive ahk_class ExploreWClass|CabinetWClass' l, n+ e1 n; }5 O# y$ N( c
; open ‘cmd’ in the current directory& @3 D3 F+ x3 L2 ]# U) A
;: ^! V" L0 R3 T5 C# L
#c::
5 U/ N2 x6 t1 p OpenCmdInCurrent()+ {. C( f% q1 Z+ S7 r7 M/ C* Z
return$ `3 |" O8 w! J- g
#IfWinActive
+ \- U0 o. ]) J, |2 W9 W- } ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# l5 `6 k' u! w3 } v' [
; Note: expecting to be run when the active window is Explorer.
+ A( J2 S# O4 b' K' f: r3 \ ;9 N0 |4 D2 @0 b$ h2 ^( D7 n( s) u
OpenCmdInCurrent()
, A7 R# a- k3 Y, l {/ w- x# O0 p, Z/ }7 ^
; This is required to get the full path of the file from the address bar0 ?, ~ Y* i2 N I0 S
WinGetText, full_path, A
* t+ L, @/ H9 w5 C% V$ I' \# \ ; Split on newline (`n)
; O- l& a1 p* t) D3 q; W+ x StringSplit, word_array, full_path, `n( ^; m, O: F; }: Y; n' w
; Take the first element from the array
+ x. j' p3 q# D- w! M% o full_path = %word_array1%
( L. m/ k3 f& |/ U3 m E& { ; strip to bare address; |$ I2 ~ Y6 |* d( A
full_path := RegExReplace(full_path, “地址: “, “”)& q8 L2 z9 a) U' p! I. F0 {
; Just in case – remove all carriage returns (`r)
! Q9 a7 l) w, _( {& C& R StringReplace, full_path, full_path, `r, , all
2 M2 ~/ _/ x( |: r" {$ [1 [ IfInString full_path, \
5 e% N* V$ j9 T2 d5 p {. b7 h9 ~: C( I+ Q. j( o
Run, cmd /K cd /D “%full_path%”
8 }& d! h$ R, d3 H' I( T3 h }
( h% a& L/ u# M) D else! U1 x" ~' z4 g) Z* N9 H8 V& i
{
8 \5 W2 V$ ?( O Run, cmd /K cd /D “C:\ ”
, k3 C: [2 s2 v. D }
; j1 q( g- m5 ^ j+ @ }
) Y, w$ e1 y" S- j! q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# h% s" M* {/ i) S' B: h
这段小代码肯能有两个你需要修改的地方% {: B& x, d1 k3 ~: V
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! t# R& p0 |+ j% h
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' i4 a7 [+ }7 g% c, A |