此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& y& d* t/ c0 P0 c& K0 I
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
) r- d- U$ X" z+ f0 w$ p* y 方式一:
3 n3 r5 f, [6 l8 c3 d' \* x 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 W. @" x3 q' \! Y8 n1 F& [ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: u1 c. l, \ |3 R
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, @2 x/ k- u! M, }$ ^+ H5 j
方式二:' c8 w9 u; j4 y$ a0 \9 X. k
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 ]- T1 e- Z0 T$ e" H+ j1 M+ w SetTitleMatchMode RegEx
4 H3 \) x/ w J3 O) o P return. e" }6 s+ r6 W! b s0 c
; Stuff to do when Windows Explorer is open
- t w- [( G9 ]/ H4 G ;
4 z* n) g* z$ I! {, [. Q% l' U #IfWinActive ahk_class ExploreWClass|CabinetWClass
, f8 U0 w4 l2 r5 T ; open ‘cmd’ in the current directory
. @1 _2 o; a$ N ;
+ c, L9 Z$ o: p) f( i- d' F #c::
$ }, [! J; `2 \# C9 G OpenCmdInCurrent(). S6 N5 Y/ V9 M9 x5 p6 f/ v# w& Q- {, S
return
, k- K3 M' B9 C, { #IfWinActive" t7 c* n" L( ^3 H* `- W# N
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 I$ G- Z, S$ y. P" E3 m ; Note: expecting to be run when the active window is Explorer.
X$ R+ w% b- k: p! \/ \ ;$ V* t+ Z# n$ W
OpenCmdInCurrent(). S+ `! D) `# C8 L( s- _( J
{- r& @) h7 S% d$ D9 b9 O* U
; This is required to get the full path of the file from the address bar
4 W8 U# X" k; W- h% g0 Y WinGetText, full_path, A* X" H( W; F" \
; Split on newline (`n)
' R% B% D% z# l2 d) \: ^8 K3 V* z StringSplit, word_array, full_path, `n& Z+ H- h) L- m0 ]5 |0 r- O
; Take the first element from the array
, r1 v) O: E4 B2 G2 S! ~ full_path = %word_array1%( Z1 M$ g) c3 j# Z9 s& R6 V
; strip to bare address
3 c, r- [4 H8 r6 [1 } full_path := RegExReplace(full_path, “地址: “, “”)$ j- w0 Y3 |! c8 s+ B) t5 k5 W
; Just in case – remove all carriage returns (`r)
/ X% _: R% T3 D9 Y StringReplace, full_path, full_path, `r, , all
3 n0 o' \' D" D8 B7 N$ Q IfInString full_path, \9 V9 Q; v$ N+ c6 ]# |; ]
{
3 ]$ |4 j: h2 s _/ L) c/ q" w Run, cmd /K cd /D “%full_path%”( g1 ~; z2 O V1 Z
}
* @" f% }0 c: h- `/ y0 o7 A else* ]2 K/ A% |; Y! @6 a, S, s
{8 t! c- ] H, D, J6 A
Run, cmd /K cd /D “C:\ ”2 v' s5 }7 A; D7 j- _
}
0 @0 z! @: k2 Y" {/ H* s, }8 | }4 u2 ~3 M! q5 ?. I9 g
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: y4 u) K3 j6 b4 D5 e4 u% \# J
这段小代码肯能有两个你需要修改的地方+ p+ U& T3 u& \. r& S5 Y0 F
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, R" `" @4 Y! }; h3 l# f8 e* o& s0 x! z3 v 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' @7 d: m/ ^7 X |