此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ a2 [ w3 }) K4 Q" X 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 ^( J. m. w& E; H: @5 E 方式一:; u# z8 O9 ^! H
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, G* W2 c0 J# y7 Q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和4 E( |- ]5 P" W }
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) B* z, O& a, O8 h
方式二:
/ e4 ?1 Z; L" H, E4 z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ ~! C0 ^* b9 j+ X* b3 ]- z SetTitleMatchMode RegEx
$ [7 r' _5 Z# _* m, p return
1 v6 v9 A7 s1 n8 C5 G5 p7 J$ B ; Stuff to do when Windows Explorer is open
! q( D. t' Y7 Y( C ;
' q+ \1 ? t+ b4 }! n: _$ ? k #IfWinActive ahk_class ExploreWClass|CabinetWClass
- \- ~) {) {3 `% V( k; K G ; open ‘cmd’ in the current directory
. K1 J) M' r$ H1 l ;
, A8 r4 f' ~4 B5 O( ~$ S( w- w #c::- R( j- k/ }3 y& _# f s- G
OpenCmdInCurrent()5 s: l0 t" `# @8 j
return
: E$ g7 e" n9 Q/ | \ #IfWinActive
5 \2 j. W& Y# W; c ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( Y5 l! K6 L- ]( u ; Note: expecting to be run when the active window is Explorer.
" [1 C' @3 |6 ~% T1 b1 H0 w/ s ;
+ Z; a6 G) s9 U/ A0 V. m) l9 P A OpenCmdInCurrent()+ s6 u: l# H0 y7 d4 @
{
; X; H; S6 n% K, E, N( u+ o0 s ; This is required to get the full path of the file from the address bar8 ]( X5 a6 ]" i: A' T( r
WinGetText, full_path, A
: F2 X& D7 ]% W, l1 x* J. u ; Split on newline (`n)* y( j _0 f1 ^% K' W( F
StringSplit, word_array, full_path, `n
6 o/ ~. y9 k1 k% ^+ r ; Take the first element from the array
: K# s0 ?1 D; p, I: a full_path = %word_array1%
7 A/ j- {- n: Q+ q) u ; strip to bare address# v! h# D/ s1 Z; q( I- e
full_path := RegExReplace(full_path, “地址: “, “”)
9 v7 E- ?4 k a( q! y4 U$ p ; Just in case – remove all carriage returns (`r)# I0 _0 {8 G# |6 U5 a7 N
StringReplace, full_path, full_path, `r, , all, ^! V& {1 Y7 k: W B
IfInString full_path, \8 C' ]# q% x5 u
{% ], P0 j. ^. ?8 x! c8 U
Run, cmd /K cd /D “%full_path%”: i* E. A7 n& m: s; }8 J2 N) g2 q
}! C" h" f" r& v5 v7 [
else
* f) K S/ d8 @( @( |% _ {! }0 B! v; A+ W9 i
Run, cmd /K cd /D “C:\ ”0 `) o' k& m* n0 E4 l$ p
}
w6 P9 O" U* n6 J+ p/ j5 | }
, F5 X1 E4 U7 E4 W* F y# Y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 c4 c) {- ~7 \: S$ P- [ 这段小代码肯能有两个你需要修改的地方* T6 l* R7 ?) \3 ^- G$ }5 U
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 `8 Z% e8 m: S& [1 R/ l( r, b
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' ]0 Q4 j" j- A; c1 z! b' k2 f) _ |