此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ K( H5 Z4 ]5 q" {. t, ~: Z; w
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 J# ^& ?5 a9 ?* s0 W1 P
方式一:7 w. ] o4 _/ e
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 m# T4 j& K$ G4 n 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ ^$ t. I, g! w2 z: Z( o. e5 q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( A/ n; y6 c- N( I$ S+ A! T
方式二:1 ?0 ?% X) X) Q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 x4 C4 }( F: S& `7 q/ E SetTitleMatchMode RegEx8 ?. k3 O, j6 R- P8 Z3 p' b9 G
return8 ]* v% |; N1 u+ x0 f s7 X& D( _: C) M4 u
; Stuff to do when Windows Explorer is open
Z0 t5 q% U8 T# F7 s) b3 k1 k ;3 ?8 p: ^/ o3 E6 R( A( [
#IfWinActive ahk_class ExploreWClass|CabinetWClass, C& o5 [: |5 w W% q
; open ‘cmd’ in the current directory) p' O; _4 U' F) z& C$ t$ T6 w
;
$ V: t0 y7 ]" Y: n; {3 l #c::
& D( p7 V! e; W9 c' a OpenCmdInCurrent()
! {1 F' E$ m5 x return
- a9 m. C6 L. t ?1 I9 C9 N' _ #IfWinActive2 b- _, o8 q; g! m) x) w
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* x* I, l' Y/ e4 D; r8 }- } ; Note: expecting to be run when the active window is Explorer.
0 V# g6 ^" R2 J2 L) |- D# I7 e ;4 H2 t* x/ n/ P) b& ?, g
OpenCmdInCurrent()
5 g* W+ [& i" t6 Z7 p" K {3 X% n% W4 o+ l
; This is required to get the full path of the file from the address bar
& p% c4 N9 w3 v5 p WinGetText, full_path, A% E3 J1 W" C. h+ Z: h1 j
; Split on newline (`n)
0 b1 S4 }3 V0 a$ v$ o StringSplit, word_array, full_path, `n
" N' n- [5 O# T7 ~) U z" ? ; Take the first element from the array
v' D2 f ~; ~- l3 _! R, N) i+ d full_path = %word_array1%; x+ x* X; [) R
; strip to bare address; \" a, w4 [! g
full_path := RegExReplace(full_path, “地址: “, “”)0 h7 E M B$ P# N, ?; ~. }
; Just in case – remove all carriage returns (`r) k2 K2 X- }7 a s6 U7 `' T/ O
StringReplace, full_path, full_path, `r, , all# i' g+ g- Y9 _5 H. m s
IfInString full_path, \
. K: y0 m& G2 x9 G5 r2 A {. f/ Z9 V' a1 A2 D# ^" N- S- B
Run, cmd /K cd /D “%full_path%”
3 N; y% Z' c% M }
7 j: D* i" M% F/ B( v0 ~ else
9 ?. h6 C; K+ H {
6 y- _0 k" n d& z' P* ~; O" t Run, cmd /K cd /D “C:\ ”0 h2 a! w' R# s( G
}
# ^. {. j& I& \+ z5 V7 @ }, O$ ^5 i" B! I6 U% Z: q5 l
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 E5 P, k" C! _5 R$ U% e 这段小代码肯能有两个你需要修改的地方
: Y' g9 K2 e9 A- B& x" b4 n 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键4 j# [1 \5 Z; ]# Q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* v" J' c; q, |# O7 g5 u! A |