此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 m% b; A% ]$ r2 |5 \# `, B
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! E- a- ?: F" C3 M+ z6 t( [
方式一:2 h) W5 S$ M2 y/ b o ?4 h
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
; S; O0 i' j: y, Y9 l 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& Z) N5 J/ ?% a0 }! V* T i HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ D7 O r' L3 E 方式二:
' d. G% I( z- v! M6 d 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:; P7 D: |" c! ~
SetTitleMatchMode RegEx
: H% m- p$ v- a& y return6 ~9 S+ F- S ?, B& I" [
; Stuff to do when Windows Explorer is open% ~( d, e0 u# l6 ]; @
;7 K& d4 s6 S3 s+ W+ y
#IfWinActive ahk_class ExploreWClass|CabinetWClass* @; ?0 `3 p3 O2 i6 J
; open ‘cmd’ in the current directory
H d9 t! X3 t/ O' q ;
( r" O( C# z7 R1 f0 h) N #c::
8 N v' g6 @$ d5 H( J# N5 J OpenCmdInCurrent()
, b! v, \& A% X+ T: K) _ return
0 W+ i! [0 N3 T1 w) s, c1 I3 O #IfWinActive5 ]. o( R- z! f! [" {8 e5 P
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' L1 z l* l* d2 [ N ; Note: expecting to be run when the active window is Explorer.. V, ]0 |* ^0 F- c0 j! ` s5 ~
;
. b6 E2 m+ Q7 L" Z1 m OpenCmdInCurrent()5 o9 ` [5 g8 i
{
0 h2 P' l) m, V Z* { ; This is required to get the full path of the file from the address bar
& ]& `& S7 p: j; ~: e: l9 M% U) z' _ WinGetText, full_path, A. W2 X5 \8 }5 w
; Split on newline (`n)& w2 m! M8 a7 h' P' V) S% o* {4 L
StringSplit, word_array, full_path, `n
. @1 ?8 g7 ]6 p) y3 j: y: @; { ; Take the first element from the array
1 d! e: n( T( o4 L" d- D/ z full_path = %word_array1%2 h1 o3 a% v5 x+ e+ u
; strip to bare address
# `7 } @0 D" H8 l9 N! P" A full_path := RegExReplace(full_path, “地址: “, “”)
/ N6 t$ h& a* ~ ; Just in case – remove all carriage returns (`r)& r6 O) t! ]5 n# q3 x3 s, S! `
StringReplace, full_path, full_path, `r, , all
' i4 F$ u0 M' S: F, Z IfInString full_path, \
& m/ b3 m; T6 F5 F8 p {1 R! Q7 e% i$ O0 a
Run, cmd /K cd /D “%full_path%”9 _0 W* c1 R* J0 Z2 p
}1 j) @0 w( V2 R. L
else
% h; f8 K1 J( G. T7 Q: n6 { Q, E! _4 V {1 ]: ?6 `) V; D
Run, cmd /K cd /D “C:\ ”
6 B" r7 c, | I8 V }
2 K/ [9 x- m. z# Q }
, C d- ~9 Y: d3 h) G# w# f 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& r8 P3 J& h+ J) x7 w1 I
这段小代码肯能有两个你需要修改的地方
& h: \0 J: f( e' N0 B/ d9 W 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 E' Q( S# {) G4 L 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 D0 g* `: m, ]8 M% J, l |