此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 Q0 w- ]0 v! V N; t 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' A( ~ ]$ a8 X3 c' i" \0 ] 方式一:* I% x% C9 o5 R/ ?. S
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# H/ p# Z% m: }& X `9 r
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ u* I% C/ I6 y; D% V @ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. u& H/ T7 r' ^3 q' U 方式二:
( B% H( t3 S/ v0 M1 n ?" M+ ]' U 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 H/ X/ [# |6 p
SetTitleMatchMode RegEx. o2 F* }' b( \' u& ^- ~; j& R7 j
return8 K) q" d5 T7 v( E- A" v
; Stuff to do when Windows Explorer is open
# p1 g/ O; @" I ;
- Y% o( o% u/ B" Q3 L, ^ #IfWinActive ahk_class ExploreWClass|CabinetWClass0 ~2 G _0 @1 A& N3 E- U4 P0 Q
; open ‘cmd’ in the current directory
6 J# I. F8 Q9 [6 O4 W ;+ s' r5 W0 H! `
#c::
/ T1 b/ F0 ?) O OpenCmdInCurrent()
+ H9 Y9 S |$ }: e return; Z. c. D5 `# T. _1 @. p9 L1 E
#IfWinActive
- G, X y% j7 g/ P; H ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. O0 L; k8 \5 p2 u
; Note: expecting to be run when the active window is Explorer.4 ^2 z" `" d9 F$ E1 F
;
/ _; `9 A) g8 G" s6 M: F OpenCmdInCurrent()) m4 g- \$ F# B5 g; @. R
{
4 w# a8 z9 u5 } ^' U+ {3 H- n6 ^ ; This is required to get the full path of the file from the address bar# F% v3 h' t) \) R' D5 s
WinGetText, full_path, A8 S' u1 e4 {) A# u1 R
; Split on newline (`n)
) f+ C5 O# @7 X4 Z0 g StringSplit, word_array, full_path, `n; M: D. U! f( _- E. ?
; Take the first element from the array
& a& D0 P8 C5 `# Y2 R6 [ full_path = %word_array1%
" R {9 v4 F8 S- L& } ; strip to bare address
* O4 D- U; p; C% b' D full_path := RegExReplace(full_path, “地址: “, “”)
: c0 u6 o- m1 d9 T3 g/ u! o1 y ; Just in case – remove all carriage returns (`r): a& O9 [, v% I( M( E% c
StringReplace, full_path, full_path, `r, , all
4 [5 W. g: C) a- A' Y( V9 q IfInString full_path, \+ M" I/ Q3 }8 H, O* F# z) D7 p
{
# G" F" Q5 C7 y* B' ^ Run, cmd /K cd /D “%full_path%”# z% }: g! @( p
}% E& j$ _1 o1 C, _; e
else
& ?1 n" E/ D9 L0 D! O. v3 h {
( W, [$ W$ T- H* w/ O8 i+ t8 N Run, cmd /K cd /D “C:\ ”3 A6 ?0 l/ \* {0 T$ P( l5 d
}
& W, R" b5 a8 Y }
! D4 Z; x7 t9 ~7 F! d 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 R; y9 L, R. Y, ^- [9 w 这段小代码肯能有两个你需要修改的地方: U$ G$ z! o+ W7 o/ g; b
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- z3 q7 L" O3 s( K0 O! ~+ T8 {( H
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
d7 _: `4 ^9 O( F3 K" A |