此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% F9 t4 y' k, B$ v- ?
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 x( [7 k" A3 B+ b% a1 ? J
方式一:( I. N# E* J4 H2 ~8 n
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,3 F2 [+ g! Q1 V2 S5 c% H6 z
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: u- Q5 }4 B9 e5 F3 V HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' o) j- r0 s& y! F% W& c 方式二:
7 C- d: F% G" \) z( S 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 b7 v9 ?3 P# E g SetTitleMatchMode RegEx
2 m' T' Y: I5 z; q9 f1 d return d9 `8 h5 K/ n0 _, J$ ~
; Stuff to do when Windows Explorer is open+ j7 z2 l; ~, z6 {8 d9 Z
;
% ]; a- z, J# t+ |+ j& ~ #IfWinActive ahk_class ExploreWClass|CabinetWClass2 W5 q& G; a/ [ u, |
; open ‘cmd’ in the current directory
/ ]( o: Y+ Y: H/ N ;
1 L4 L" n$ @4 d8 L" y #c::
$ T* S2 u @) s8 [, ~5 E OpenCmdInCurrent()
( G3 _: B3 u2 l( ^ return
0 ~" U3 K9 ]# h7 V, d #IfWinActive
4 B# i; b$ _5 P1 N1 y& ~ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) c/ I. j5 X1 Z* `
; Note: expecting to be run when the active window is Explorer.
~6 k& F9 @: r3 g6 o' V; H7 { ;
' z2 H i( ?, v/ |& l( @5 v8 h OpenCmdInCurrent()
% i1 m0 O" d7 M3 y, P1 L {" w6 `# d) L+ \ S0 m
; This is required to get the full path of the file from the address bar- a/ t3 k N! H. U# S
WinGetText, full_path, A
% q2 A v+ R" Y. ~/ m5 }& i. W ; Split on newline (`n)
% Q5 J8 M9 E5 d) o StringSplit, word_array, full_path, `n B9 Q, l' Z; I2 B" b2 O
; Take the first element from the array
8 _: Q3 O8 n) j full_path = %word_array1%" T+ e+ C5 k, }
; strip to bare address. z& m" p, [' {. r6 ]: s
full_path := RegExReplace(full_path, “地址: “, “”)
1 J) B/ E3 d" b ; Just in case – remove all carriage returns (`r)4 U1 D- r/ T: ]" o, W/ X5 t. n# y7 e! o* w
StringReplace, full_path, full_path, `r, , all
1 n7 x1 T$ P8 [0 {! o4 W% O IfInString full_path, \) |0 O1 s/ z$ c4 z, @
{
$ X) [- ]6 R' D* a5 g! r3 o! w Run, cmd /K cd /D “%full_path%”
% Q- ?' B) h" ]7 F: V4 E }
+ A) H( }- f- F7 X; z @- ~; @2 w else* r, W. i4 ]5 k5 t& q9 ~0 D7 j
{3 G; Y/ U' i6 C5 b9 Y. A
Run, cmd /K cd /D “C:\ ”
x# o2 j( w; t6 `; W- E }5 W; O* Q1 F1 m5 F. _% E
}4 c* P6 E. { y( {1 y$ J( l
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 U) v$ W; _# ]7 G4 T6 v8 Z; ~' Z
这段小代码肯能有两个你需要修改的地方3 d. I2 x2 e" O5 u# z( @- l$ S% `
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ \9 } j+ J6 C0 F+ e/ O( t 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 _( x5 p- L' `: ?5 h6 F9 @ |