此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- a! d% ]8 y) I3 f5 K) r6 G% u' } 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
# \/ C' {3 q$ ^8 ?5 u/ Q 方式一:
3 d# C& A$ z* `& G8 o 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- t( G. E; F# t8 Z2 d# P" D: i 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, [- w9 S# E9 c) y2 L. \0 p/ y$ d
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 Q# u, b0 x# }) K" r 方式二:- ]1 z2 Y; d' t1 Z: J
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 G$ `3 q2 z8 ]/ s& v6 Z* h+ ` SetTitleMatchMode RegEx
- s, L1 f# G- T; @; q5 ^8 S return
' l8 y! d) o. I/ N ; Stuff to do when Windows Explorer is open! s9 Y+ W8 s! G4 @3 r# m& @ W
;4 J( l/ p0 T4 U+ w
#IfWinActive ahk_class ExploreWClass|CabinetWClass
4 `# h# P6 n+ f6 c) h" n) h ; open ‘cmd’ in the current directory
- L+ D% h9 q J8 h' L4 q( h7 @ ;6 ` f8 g5 U. J* Z& G$ L5 Z& L
#c::- ]; {4 }1 F' J( Y3 E/ B
OpenCmdInCurrent()- O9 H! [( c, w7 Z$ z! ^9 X
return
; H( s4 g1 {7 Z* ~ #IfWinActive
$ M# W4 e/ N: K' G# p! J4 K7 [, _ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* Y( G3 p/ L! Q
; Note: expecting to be run when the active window is Explorer.6 o, i0 ~. q0 q. x1 {
; t1 g1 b1 M; l: R
OpenCmdInCurrent()+ G" N. n( Y0 U" K
{9 R% S; S0 K, A4 }2 I4 o4 q
; This is required to get the full path of the file from the address bar
+ S z% X: c+ ^2 r# V3 P WinGetText, full_path, A
) `$ d, V8 c: o2 f# ^) P3 [ ; Split on newline (`n)
' J: @5 g8 C9 o1 N StringSplit, word_array, full_path, `n
9 [0 o" e% [7 r" R- k5 a4 o6 Z' P ; Take the first element from the array
- n8 H8 L. d l2 y- N3 a2 \ full_path = %word_array1%6 u* ?5 ?/ W4 `0 B
; strip to bare address
, s. k+ @4 n' U0 T% o0 P! ^+ s full_path := RegExReplace(full_path, “地址: “, “”). {, |" H" r( R! J# v, s
; Just in case – remove all carriage returns (`r)
1 k9 e" P2 N0 R/ X( ]. y8 A StringReplace, full_path, full_path, `r, , all
+ O7 K9 |5 j0 u: v IfInString full_path, \
: \ l, G) E+ k( J) L( A; H {" c4 \1 T9 |' {7 u( C; ~/ L
Run, cmd /K cd /D “%full_path%”) A2 S- Z% P* \: r
}7 e: v# f+ Y, a. K8 g
else
p! k% h1 w+ h, {, J- `# i T {
R3 X4 I) w j9 y/ n Run, cmd /K cd /D “C:\ ”
8 [2 A$ n* `$ O x/ I4 H }( W5 s$ J) {" K6 I
}
; P9 F; d( a7 T8 A& z! q3 H 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ L# ?& }! n! R5 [, c/ L 这段小代码肯能有两个你需要修改的地方9 R2 t$ S0 j' l# _* C
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 e+ J/ t+ B0 q2 t7 O1 Z
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! V* p0 n; d; T) C9 q |