此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 D- n& r( a7 P2 k 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
) u' A: c% d0 x* N( h. S! Z* F) Y 方式一: [9 Q/ {4 L! x9 P$ A8 I4 b! ^: i
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 [! b+ p3 b2 c$ V# g, j
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. M' s6 o- z3 F( M HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ z7 i& Z2 H" N" H# D 方式二:
2 L4 x/ p, N/ A- s S/ J+ n/ d2 ` 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' d9 H/ t+ C! l# e& L SetTitleMatchMode RegEx3 z6 `0 J1 b3 v* _* r+ W, v
return
9 |$ A& s( E" D5 i! e ; Stuff to do when Windows Explorer is open
$ D$ D' [$ E0 G/ W. M8 U ;4 M) z% p0 v8 w0 w5 B1 A* C
#IfWinActive ahk_class ExploreWClass|CabinetWClass4 |* v+ C# ^- P0 }; U: M0 {$ [
; open ‘cmd’ in the current directory7 F. A/ v7 D/ C2 i
;
8 c* w$ O9 q5 r: y0 d #c::
6 T! |. r, J. D6 U( m) O3 p0 L8 Y& N OpenCmdInCurrent()
' d% Y1 J2 H+ Z! [ return0 ?8 a+ Q5 u9 p6 u- |
#IfWinActive
z% j! q) Y Q+ X1 B ; Opens the command shell ‘cmd’ in the directory browsed in Explorer. H- \/ h* N* C3 Y7 ~
; Note: expecting to be run when the active window is Explorer.5 X* ~) Y% V4 u- `+ L
;& k) m2 q0 M# K; J) A
OpenCmdInCurrent()& ^" `# u4 f, |" ^; Z' f% e) U
{
2 ]: {+ B2 c0 ?! X: n ; This is required to get the full path of the file from the address bar& t2 b: w4 [! a1 A2 j* N: ]
WinGetText, full_path, A
5 g9 C: h/ D4 b# K" J/ n ; Split on newline (`n)
$ l( h- J/ `' P( E2 A StringSplit, word_array, full_path, `n
& v# E7 r' }7 `7 c- p. h ; Take the first element from the array% O, s! N f* r8 a
full_path = %word_array1%
6 j( W9 z$ T% c$ Q C ; strip to bare address
8 ^( g2 _) G L$ L( [$ B; ` full_path := RegExReplace(full_path, “地址: “, “”)
9 Z# t) G& v9 l4 r# |9 ] ; Just in case – remove all carriage returns (`r) `3 x& m1 C; @& a- A6 Z4 _& [ W
StringReplace, full_path, full_path, `r, , all
$ |8 G% F" w) |+ W% ` IfInString full_path, \
' B4 k$ @$ j' h4 C {
! V' o- U0 y A' B Run, cmd /K cd /D “%full_path%”
* e" A0 |* k1 l$ `8 f }. K# M( e* K- B; c- j
else
/ `' ]9 G8 p( N- V) V$ q {' k! E( D( Y5 B: I3 u3 S8 ~
Run, cmd /K cd /D “C:\ ”7 u5 m& a: A. ?1 d+ T" K4 w
}3 N" ?! `+ i4 q* n5 I6 k
}
& @/ L5 U' K+ a4 x; a: e 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 U8 o1 @4 p% }5 R9 s
这段小代码肯能有两个你需要修改的地方
' R9 F4 g2 `2 M1 @2 j6 e7 L 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 c X5 [( U, G* u 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 ]: s j$ v X5 }% x' a
|