此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 j$ M3 |7 o; o8 w
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* U+ B. r) T W, g X& Z
方式一:
5 W3 f) C4 t0 S 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
! g3 |1 J- H6 E" C7 N) B" F# i 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ t! i5 a6 [2 } I2 | i/ U
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
# N) O. A: r% A6 @ 方式二:5 }# R4 S0 M& H6 Q, _
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 J9 m% E1 Y# \, O
SetTitleMatchMode RegEx: v1 P5 R3 |& B+ `8 e3 U
return7 n$ d0 y& B c2 s* V' }! a
; Stuff to do when Windows Explorer is open
) w3 |0 s; Q; E4 m% K4 c+ l6 f3 p ;
* t8 G+ A- q m6 J3 @0 P4 k5 J #IfWinActive ahk_class ExploreWClass|CabinetWClass, O' q, Y8 N$ H/ t
; open ‘cmd’ in the current directory, c! `9 ^7 {% i- B1 Y
;
& [7 h/ M) h, D0 K* g #c::
- ~7 j8 ^9 W/ v- Q OpenCmdInCurrent()
: W- I# E/ p2 y- ]1 g6 G return
6 E$ }, k, C+ P #IfWinActive
. d* h4 P% P, Y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& H. n1 u0 G: c3 C4 [+ W
; Note: expecting to be run when the active window is Explorer.! p( ?/ [. @3 o) u. d" F
;0 t4 u- W- F1 D2 {/ W
OpenCmdInCurrent() ~' p J7 o0 H: n9 s
{7 o- M) w& u9 e% b
; This is required to get the full path of the file from the address bar& m, q3 u" s) ~: @
WinGetText, full_path, A
% n3 v) K' E" C6 j7 f ; Split on newline (`n), B5 n$ |; s' Q5 J
StringSplit, word_array, full_path, `n. z; Y* ~, e* Q0 @9 x: U& q
; Take the first element from the array4 t( d& K; V! `) h/ ^* `: u0 c2 }
full_path = %word_array1%4 f$ O+ K5 d. w) E/ w! `
; strip to bare address* V4 \$ |, Z R( [
full_path := RegExReplace(full_path, “地址: “, “”)$ @9 Q* y. Q: b- ^ Y9 {
; Just in case – remove all carriage returns (`r)
; u9 C+ f6 h8 _ { StringReplace, full_path, full_path, `r, , all6 n* @, B! E2 _
IfInString full_path, \$ X( y& e& P) Y9 O# m" N6 u/ k
{9 c, w" k7 h& A! h c
Run, cmd /K cd /D “%full_path%”% g4 T s5 |" m0 _+ A6 {. X
}
* F# W" z% Q$ ?# J5 A6 `4 _! G6 I else
- @; I1 o- A" H6 D" G" Y {' R+ X; U& {" ~3 W3 h
Run, cmd /K cd /D “C:\ ”9 @" W: l. B* e+ O/ T) ^
}
y; }! _0 ?$ S7 ^ }
4 b& m& v& Z$ v: [/ ^% n 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 M; a; a6 L* @, @4 j1 L$ d; a
这段小代码肯能有两个你需要修改的地方. w' F% K3 @6 S! f- h
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 O8 j0 _8 D+ E5 F 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! ^" _6 n. H3 x$ d3 S
|