此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。7 I7 n' _+ V. b# l
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ n# y2 m" L0 ? Y4 G8 N 方式一:
' N5 C6 S7 J! L' Q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& p" Y' r7 M }6 ?9 K 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 q# N0 O$ D! `6 M) d
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 _. Q2 j' `( O
方式二:3 \6 {6 ?" T* @ ]2 o
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
9 A2 b* ~- U2 O* j SetTitleMatchMode RegEx
6 k6 |" H7 y- d2 H. T1 ] return& I" D4 \3 ~9 \( i4 a* U
; Stuff to do when Windows Explorer is open
4 {5 g8 I$ v# q p7 ^& @ ;
9 z: b' @2 h- O# x( `, u! E5 J #IfWinActive ahk_class ExploreWClass|CabinetWClass
4 T4 _, G* K9 h6 ^ ; open ‘cmd’ in the current directory' i+ G! f3 a% l$ ~: X7 Q
;
" ^6 K3 z" R" B8 t #c::1 y' G2 g4 s8 x5 V
OpenCmdInCurrent()
- z0 U& g5 e `& s return
/ c" \) j$ E" x; S' I #IfWinActive' q$ V# }; E) N$ k
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( Y! @5 R* v% Q; _7 E- G( ?/ g ; Note: expecting to be run when the active window is Explorer.
8 `7 t5 c q% Y I. }' {3 Q ;
3 K* S. o- g# D; S OpenCmdInCurrent()
0 K7 t1 S: d9 g {
& K4 R) R# M- m8 A0 Q+ k! c' w- e: a ; This is required to get the full path of the file from the address bar4 J8 |9 o9 _. {/ c: K4 O
WinGetText, full_path, A9 D7 q* y$ Y1 H: |- m# d
; Split on newline (`n)7 |( i! Z, y# Z- M
StringSplit, word_array, full_path, `n
3 o5 G+ a( O. ~+ R& ? ; Take the first element from the array
1 E, x; o! m" N h! p4 W" f full_path = %word_array1%
% N1 F4 C9 B5 s; D F0 q2 X ; strip to bare address
" P2 ~' g, i: z& i9 ?& b! n full_path := RegExReplace(full_path, “地址: “, “”)
" ?& B+ Y8 P- D/ k3 [/ o; o+ a ; Just in case – remove all carriage returns (`r)
" [, L6 s- C$ m& U2 o# m# y StringReplace, full_path, full_path, `r, , all# k ~/ ?5 o5 g, {
IfInString full_path, \: ^# y# y/ H3 W
{
) g' j5 T+ o# z- | {! ]! f Run, cmd /K cd /D “%full_path%”
# T7 C$ b6 t% g( {4 P/ C9 H% Q- N }3 S' u! w* `1 i
else
" q9 e" ^4 }6 ^2 X {
; o, O# L5 {0 ?; O, c& t Run, cmd /K cd /D “C:\ ”! q5 p: U" I- b- r. m1 u% k0 K9 p" p
}9 {$ L1 y* O4 j; G
}, H- u8 j9 `) I% O: e" \
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# N% s/ ]' C3 y5 W c
这段小代码肯能有两个你需要修改的地方
: w5 t( Z" E2 e 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ E. M! [( I& x. i+ ~8 O( Y4 l
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 i2 o; ]3 W; h- ?0 Z* ] |