此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 M: ?: r' Y) l- {. X% A% A6 x/ i- }) K 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 Y+ c7 @/ t2 _# _
方式一:) `5 d6 |# w( }
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 J/ y: b8 c; F+ ` l6 t. t# v3 L3 I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; X4 H$ m4 e2 y3 ~, M9 a4 A) @) S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 ?7 a) c% c& s3 j0 _
方式二:
e0 e' N r: W 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 Z& ?7 L( Y, o8 G6 b, b* A+ ]
SetTitleMatchMode RegEx
?$ M7 Z2 ]1 R return
7 L2 H1 @: D0 S! U" b% ]* a) {) K ; Stuff to do when Windows Explorer is open
, t) G f4 Q. [% l; e# v ;
8 S r+ L! F: i8 _) u- D+ W #IfWinActive ahk_class ExploreWClass|CabinetWClass# z$ O) Y6 N9 k4 p$ v. ?( R8 N
; open ‘cmd’ in the current directory
. o2 D' q% j7 I9 h4 C ;7 a7 J) W$ x0 k$ I1 D
#c::9 ^2 v% K' B3 @ X
OpenCmdInCurrent()
- X: w' ^; C7 h' P return
9 a) B/ [1 J; _0 E- O$ ] #IfWinActive
+ p, a. M' t; M4 U; g3 Q ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& C( A7 p" f* m/ z% r; V. { ; Note: expecting to be run when the active window is Explorer.: o! {; s9 B: s0 a
;
& x" m8 ]4 R5 u$ L3 A4 m, f OpenCmdInCurrent()6 ]* a& O Z0 |6 S# Y" b
{1 W0 z; R' S9 A$ h
; This is required to get the full path of the file from the address bar
( |0 N/ C1 s' h# O1 G. I WinGetText, full_path, A. x* X) ?4 L0 A- P3 G5 x+ j- K
; Split on newline (`n)
% b$ v4 G6 Q& j! O+ `; W StringSplit, word_array, full_path, `n
4 u7 \$ f( c; S I7 A$ `1 G) v0 B ; Take the first element from the array
2 {1 P! \( K$ k full_path = %word_array1%$ u' |5 o( m0 w2 z6 o0 G; I& a' w
; strip to bare address P0 j6 }3 Y$ G
full_path := RegExReplace(full_path, “地址: “, “”)
" |: w( \" C! k; y! B/ @ ; Just in case – remove all carriage returns (`r)
# D H9 Y0 |7 U8 w StringReplace, full_path, full_path, `r, , all
* t, [) ]" h- N! e6 M) S IfInString full_path, \
; X$ ~/ h+ S0 ~3 y" p: r. p. S4 \( |8 y% w {9 A: ]6 w& ?" }& [$ z3 H7 e3 n
Run, cmd /K cd /D “%full_path%”4 b; S, p% N( O) U; |5 `2 X. {
}
- y" }* R8 [2 k$ T# T; _7 { else% ^5 ]& b% Q% x2 T- d' d
{
+ w- I; }+ T# H' {/ G" l; h Run, cmd /K cd /D “C:\ ”
9 t- J0 z2 c3 C6 k }
0 S3 R5 B# Y* G- Y }
: `- g. J9 P6 l. u: d 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
, h# ?0 E- R1 A) J1 x 这段小代码肯能有两个你需要修改的地方
8 _$ N* O' l/ l 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, K9 _' x( e, F- b9 {3 h 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 F' T$ }5 R! ? D3 k2 _
|