此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 C. D4 D% A7 } 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。$ B: m+ D2 s' b# u6 i: L
方式一:
/ j* _( ? `$ h& h: _ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# `* J% h( I p2 z/ k# L" K ^& J
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. E4 H, H; ]+ u! C* c& Z1 u HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 {/ [4 o5 ~" B8 u" H 方式二:
3 H& \7 F$ h" z% i3 a" z1 C 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 V; \9 m8 R. z, o G SetTitleMatchMode RegEx
2 M& s- P* d6 w8 ` return+ {5 W1 V' U$ O1 _) h
; Stuff to do when Windows Explorer is open5 O" f& `+ S! m4 H; v1 F
;
% e1 l" H1 P9 A) s3 _9 m& v' i #IfWinActive ahk_class ExploreWClass|CabinetWClass' G) q3 G& \4 M$ c) r
; open ‘cmd’ in the current directory) J$ a: D; R7 u$ Y" [9 S
;
* _* X9 {) J6 z #c::; K) `" L9 G- r2 J* j1 }
OpenCmdInCurrent()* Z# K5 u9 i* [* x1 u
return
* Z9 g2 ]$ a. f/ I7 N: @" j #IfWinActive
9 r& h1 j/ }( P% j$ r. \& ^ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 }( A1 M, g, j( v$ X- n, i ; Note: expecting to be run when the active window is Explorer.
! x* x0 F, p9 P$ f; e ;5 F7 Y% s2 O6 Y# W% K( w
OpenCmdInCurrent()5 ?, B: x; C; m& F+ k/ T. T# x
{
* ~8 z w" m) o' C ; This is required to get the full path of the file from the address bar2 r: t- V2 G" K' J
WinGetText, full_path, A7 R* u% c- s& A
; Split on newline (`n)' r) s, p/ o4 {- ^; c; Y2 G' k
StringSplit, word_array, full_path, `n
; M! l0 P6 ?4 v* u4 K+ _; H: J. u ; Take the first element from the array, y# Y3 q4 N J( Q" s
full_path = %word_array1%
' O+ e9 i" P% ^5 \9 P/ l ; strip to bare address, K4 n( I8 ]5 t% U. o+ C
full_path := RegExReplace(full_path, “地址: “, “”)
' r' b: W/ T: A/ a ; Just in case – remove all carriage returns (`r)
* ^" w) k5 j0 ]) v- h3 k$ E StringReplace, full_path, full_path, `r, , all$ _! d/ M; S# a
IfInString full_path, \
7 p9 J- P+ b! e3 A- F {' x# Z. I3 E j
Run, cmd /K cd /D “%full_path%”
- y. O, H- K1 o7 a }% U$ R' W$ `$ K% E5 a' [
else# c3 {! h, Z# T3 s) G6 Z
{$ L3 R; i, i" }+ j3 }
Run, cmd /K cd /D “C:\ ”
' q! {- P8 P- A5 n% \6 E q+ l }2 G% H8 |; w* C% S' C* C% c
}: r+ _6 _* _; f! ^& H& |% F
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。 g; \) c5 H1 D- _/ L5 J
这段小代码肯能有两个你需要修改的地方
: V* R; f+ m- B8 N# C* i 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' u" t- q- d. q3 G+ l7 L3 j7 D
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “! f2 h l( X% t+ b6 i9 w
|