此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ R0 n! T$ R2 k# n* w
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 w( j7 {4 U$ ~
方式一:
+ C6 W1 L' D" f6 ]) ~- |1 f 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% a' ~" y- i" C3 I% A; I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
G/ I( h7 T% X: ?! T7 r$ D" M HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 v- O7 U! t9 }6 h" l z
方式二:
+ M/ V i! q5 p8 h3 T' @0 r 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# Z9 C @9 _; v% r' ^. {/ _ SetTitleMatchMode RegEx
3 o% r- ?; q" P4 A: l return
7 |/ F6 @/ b8 x5 ~ ; Stuff to do when Windows Explorer is open
7 `8 n2 \. o0 {( _7 Q! k ;9 N2 J2 Y; i# g9 J. }: D" |
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ y7 M" l( } ^7 r6 \0 Y$ I, q ; open ‘cmd’ in the current directory
( a2 w7 w$ A; s ;
+ p/ k; R$ y) ?9 g6 Y #c::
: N& l& \9 t9 g7 i OpenCmdInCurrent()( O7 T: o. R, p
return
9 i# P& J# ^; r* F5 M; {0 \ #IfWinActive9 p# W8 c0 t1 j! @/ k: n6 N
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& A1 a) a- q9 @+ s" Q
; Note: expecting to be run when the active window is Explorer./ U1 w' I0 Z, i& I0 K
;9 o# b5 E! h3 c4 M* _" G0 N! g$ I. d
OpenCmdInCurrent()* U, U! c7 _! C8 D
{- x: p0 i% m9 L( h
; This is required to get the full path of the file from the address bar
% w9 n9 Z/ M; q# n WinGetText, full_path, A
4 y& s& u: O% u9 Y5 _ ; Split on newline (`n)
* i; e! E1 [4 f6 ~) [ StringSplit, word_array, full_path, `n8 S X& O3 ]( }* G% \, z
; Take the first element from the array) {7 c% ~# ~0 }+ w% I' r
full_path = %word_array1%
9 h* l- b s8 i* p3 p2 l- U, g ~ ; strip to bare address
% h. z& z9 e3 J# J full_path := RegExReplace(full_path, “地址: “, “”)
, k2 D# x/ t$ }# S" N ; Just in case – remove all carriage returns (`r)
|7 y V* E. I2 e) s StringReplace, full_path, full_path, `r, , all- @& p7 X- i. B G
IfInString full_path, \
. |9 n5 v7 ^; A9 ~0 w; g2 \) i {# c- m* P* Y; f; j' V8 Z2 `
Run, cmd /K cd /D “%full_path%”
7 d" A' x1 X6 F }8 Q3 p$ p+ \! {# _9 g) p9 Y0 c, D
else
: x# K8 d3 O' F C- m1 \- I {4 B1 ?/ W" n3 w& b
Run, cmd /K cd /D “C:\ ”
, `3 G9 g: ?/ @* ` }
' ^6 ?) W; R' ~9 p, h+ @ }
3 H8 ]' T6 q! m6 C3 j8 w 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* ^/ r: L, H* p3 } G0 m
这段小代码肯能有两个你需要修改的地方
. S4 Y+ f$ O, Z/ u 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& y+ I7 w' A( z7 c 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “ d& R9 d" _" W7 l: M
|