此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
) a2 r! h$ R5 I3 e/ K 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 z! T9 @& A; ]( i/ @; k X D) ^# G
方式一:8 ?4 d3 ]& @9 P3 L. w
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, @6 M$ o' v N3 e& A. e* T 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) q5 d' P$ T4 V, l% R" U4 S) {
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* W9 H, e" c4 f0 }
方式二:' p, H! [# s% d1 X. _0 J0 z
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ a7 Z; x5 x5 i
SetTitleMatchMode RegEx
. m6 t( |4 t% j7 f9 Y return2 f; a) K! b) ^& q2 C8 {/ m
; Stuff to do when Windows Explorer is open
+ n2 @' }# C. x X7 Y9 R2 Y ;
5 D1 W T7 b# j0 n, Z8 s #IfWinActive ahk_class ExploreWClass|CabinetWClass
$ }/ h* H. |$ R5 Z! H) ` ; open ‘cmd’ in the current directory- d* }- p/ {6 y$ Y* P# m: E
;. C h: x3 C2 s: P5 Q- K4 }4 A( t
#c::/ w- ]' D [0 ~7 D) E w1 W4 e
OpenCmdInCurrent()
" D- h+ b0 \! g e& T return9 I E4 ]2 }9 T( E6 c& u
#IfWinActive3 t& N8 ~( W& m1 u
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.3 D9 n3 y5 F ]0 K0 y: h, u& [4 N0 o
; Note: expecting to be run when the active window is Explorer. T p4 q4 T' l* w
; D% g) d; K8 A; ^6 G1 }
OpenCmdInCurrent()8 c- P1 ?9 d% R
{
- n4 R* i0 n- Y% S' ` F. E ; This is required to get the full path of the file from the address bar. Z5 C! n0 ^2 E. t9 ~
WinGetText, full_path, A( q9 e8 X! G) U# M2 Y1 T+ E8 f8 d
; Split on newline (`n)
$ ]3 {# f! k1 g/ F8 q+ a; W StringSplit, word_array, full_path, `n1 d: t9 d5 \# K5 z2 P
; Take the first element from the array; \! L4 ^1 I5 w) |* }, D# o7 A- y
full_path = %word_array1%( A" C* h+ d0 S6 k$ I
; strip to bare address
: |1 v% V+ k# o3 m, e0 v full_path := RegExReplace(full_path, “地址: “, “”)+ |1 y9 u J# s4 e
; Just in case – remove all carriage returns (`r)
; b' {/ O7 _1 a' {2 `9 R6 J( g5 y+ Z StringReplace, full_path, full_path, `r, , all0 \6 h; v& W5 r- N( D& m! h
IfInString full_path, \
3 s- A: y) t* B% D" l/ l {
9 O, @' w9 [/ b& F' B Run, cmd /K cd /D “%full_path%”
9 Y Q* s1 \ c+ x+ v& N }1 E5 [- ~* ~# G( D# }' {
else; p* E/ r; J( g4 }, l8 L
{
' d7 x" c9 h% `8 y, l Run, cmd /K cd /D “C:\ ”
5 r! t* N1 Y* O+ \1 l3 R+ q }
0 J0 k' @5 r- O3 Y }1 k0 j) }' s1 e; n
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# E2 M0 l+ H9 G; E, j8 g/ V- V
这段小代码肯能有两个你需要修改的地方! ~. b% h/ ?, C7 n
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 Y( q: K5 J1 ` L 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 q2 F7 \( e/ n9 |+ n |