此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) e, P0 a( w2 ^ U
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) [$ k I1 o3 _* Z; {5 z
方式一:( f; v6 o6 ?# ?9 `7 E2 }$ D
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 u" L* A" b1 D% B" ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ ?; e1 h% r# Y P% @ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ H1 ^( w3 C9 m1 a 方式二:
! L. N4 c1 P- G9 M: ` 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
1 q/ r/ S4 I+ L% h+ f6 ^1 R SetTitleMatchMode RegEx
$ B, P7 g& y' f6 r5 \) E# W" l* q return3 d& E ?% J9 |" h0 [1 }
; Stuff to do when Windows Explorer is open
/ W# F5 ^" ?% ]' r/ I$ G ;
& e ~2 H: @: y; Z' m4 s* D #IfWinActive ahk_class ExploreWClass|CabinetWClass
% o( ?/ z/ o A; e& b ; open ‘cmd’ in the current directory
8 R# K1 `2 ~9 ~ ;: ^$ f1 h! X, \; Q+ z
#c::! i1 ]. P' ]" A7 x) m- l8 ]( t1 c- F$ p
OpenCmdInCurrent()& Y5 `+ S- L6 V: A+ ^2 a7 |2 w
return
8 n7 k6 t/ g: N- x5 [2 A3 ` #IfWinActive( L' n# v3 ` g% K
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. I3 m0 w2 _8 P4 h3 M7 v, I3 q
; Note: expecting to be run when the active window is Explorer.0 Q% v2 @0 U1 h! D9 }, {
;, N8 H _6 w$ A& C, B* b
OpenCmdInCurrent()
+ C* V5 c7 u. j: S7 s {8 `$ g2 J! Z" ^( c1 T& A% N
; This is required to get the full path of the file from the address bar: k! ^! g7 O* W6 p5 h3 `
WinGetText, full_path, A; |: V- W9 q s0 R; m0 X
; Split on newline (`n)9 m' ^! T; s, M p* K& V X% R
StringSplit, word_array, full_path, `n& f) I; c1 [1 M9 ~
; Take the first element from the array
: _% C1 O& P$ q" Z. G full_path = %word_array1%
7 t; {2 c- |* @; b ; strip to bare address* J7 e- T# @ {3 P: d
full_path := RegExReplace(full_path, “地址: “, “”). T) H: O( |9 d
; Just in case – remove all carriage returns (`r)% b$ r% q( Q% [+ N
StringReplace, full_path, full_path, `r, , all& r' T8 [/ C' }: `! Y3 W
IfInString full_path, \
5 n* q; g$ u* T {
/ j; Y4 s* B ^# b+ f) C: w Run, cmd /K cd /D “%full_path%”
9 @8 Y' P" S. Z* L/ ]+ e }6 d8 N+ T6 Y' S/ `7 u4 @1 q1 j
else
" |4 t+ i( c' o& O8 n+ S- I" J {
) {9 \! @& O* r& ^ Run, cmd /K cd /D “C:\ ”1 E k3 Z5 j8 T$ c% P4 e
}
) Z& C. Q- J" a7 B( F! v4 a: Z! q" ^ }
( |/ `) h* H7 Z. C; S6 O 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( q$ r8 _, k: {" Q! s. f5 o. r 这段小代码肯能有两个你需要修改的地方
6 G3 B0 k& z1 c8 g# a0 q' W h 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, F: ?4 q9 y$ w9 u" I$ r5 D' @
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; A% R1 G; B! c7 k- U e" }. \
|