此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' B; R8 v* U% Q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 F0 d1 [3 Y) }7 e7 F% I
方式一:
/ } A# `" ~2 A l8 B/ m 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 [- F. V5 D4 F 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% P! E( b" M* t+ q) h) w HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ ]: y0 A+ w h- ]* l0 m 方式二:
, b" m2 U/ u; ~. G$ W 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! W7 ~& D2 ^2 M% m( Q2 ~# g5 j
SetTitleMatchMode RegEx
- f! {4 c5 O: N, F: F4 z C return. i% h: B6 N% h, G
; Stuff to do when Windows Explorer is open7 A+ y& l/ ^8 p9 \$ V
;" |; k, G: d5 ^5 j' X) g
#IfWinActive ahk_class ExploreWClass|CabinetWClass
: {. q* ]' O/ ]. v' D ; open ‘cmd’ in the current directory
) ~ v* w. \* f! W, P! S ;$ _% m" J* E, e K/ \' i0 V
#c::" P, i9 K% s% J! P% M# m
OpenCmdInCurrent()8 b6 K1 P% w4 v( I1 N! D e
return- e' G0 u! g# N \( l- b
#IfWinActive
" n" r6 w6 w+ x$ e5 w6 d ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' t3 }, ~1 M' b
; Note: expecting to be run when the active window is Explorer.
" H( E& E6 \! [! \" W; \8 S ;6 f) ~7 |% {5 f( f, b; q6 l9 |7 X
OpenCmdInCurrent()
3 W) g8 R1 Y/ t; `4 R c {! u1 k7 K( }+ a
; This is required to get the full path of the file from the address bar6 U6 Y: Y1 E+ f3 ?) v6 E9 e( p
WinGetText, full_path, A
9 L- o- H3 L/ r1 ^ ; Split on newline (`n)) o6 \; L* A e8 t
StringSplit, word_array, full_path, `n# m8 G% v' l8 p- R" ~1 ?' b
; Take the first element from the array& j8 d; _5 S8 R
full_path = %word_array1%
' D% K- U7 a7 d- z5 I7 N. R7 N9 g o* o# D ; strip to bare address( e: r' G6 y5 Z
full_path := RegExReplace(full_path, “地址: “, “”)
; P; A) m. |1 N ; Just in case – remove all carriage returns (`r)
3 ` F" l% [$ W6 W# Z+ @1 H& V StringReplace, full_path, full_path, `r, , all
9 F( q6 {6 Y- c4 C& v IfInString full_path, \
) P) L. [& z6 I# C* ` {0 e `. z7 ]3 ]: O3 O
Run, cmd /K cd /D “%full_path%”/ Y; f4 O$ b" N1 j( d
}( G% [3 s! S5 J6 j
else+ m+ D/ Z4 e6 v, M, o' Y, H/ W m
{. A; i. C. _/ d, i: |! D
Run, cmd /K cd /D “C:\ ”# t5 ?7 ^* ]6 R8 H0 l: f0 b
}
5 g, k0 g$ V E P# ~ }
; g. U2 A$ |! v, E 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! G* q8 y% D5 U8 U, I( T4 b6 u 这段小代码肯能有两个你需要修改的地方
4 T/ J; }1 O; v5 ~- d7 h/ A 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- p7 b% |# O( M5 E" r; R: b; P 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 n7 ?8 T# e7 z! j( s0 p# ^. j
|