此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
/ w4 S4 b7 f$ e: | ]8 X% q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ j+ n7 ^5 }4 N6 M- L: F# D 方式一:
7 R; ?7 ^# w! n$ s/ { H 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, S" [9 z9 d$ j( z" T
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 G! {1 L/ L1 Y: I+ U5 B' c+ b HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* d$ o, I; i8 Y k
方式二:
' w% O1 ?3 w% w: C" h 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) n* z# G" ?: a0 G* P
SetTitleMatchMode RegEx
, g% M7 S5 U h' e2 Y% ?, R- E return2 t- e5 u. i, c7 U8 g8 Q
; Stuff to do when Windows Explorer is open
3 [& S7 T0 M! W8 k5 N! E ;5 ^; h' @* U9 |1 k3 J7 ]5 w$ `
#IfWinActive ahk_class ExploreWClass|CabinetWClass1 M. }! U8 G7 I' X
; open ‘cmd’ in the current directory; Z. o; W0 n8 U4 a
;
/ `* u9 b9 _2 M5 x: P& N5 `7 c& V #c::5 N; _' f5 e( _
OpenCmdInCurrent()$ K# l" P: g' z- N
return
: F3 S$ @. S& k6 U; R #IfWinActive0 q7 \: O' m! T, H
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 Q: g( Z' }. @% Q ; Note: expecting to be run when the active window is Explorer.& ^8 z, u4 k0 Q! s$ F7 }
;
; j) d* r2 G9 \( M OpenCmdInCurrent()8 R0 w+ u! X& C6 P
{
9 `. n! j" }7 h* i- q; A$ O ; This is required to get the full path of the file from the address bar
" I+ `0 A6 S* ]0 P3 \ WinGetText, full_path, A2 s. ^3 o" d; g* l, U2 o2 n% L
; Split on newline (`n)
% V2 \- ~9 j. D5 b8 V StringSplit, word_array, full_path, `n/ C( Y8 x4 }6 G' l5 m
; Take the first element from the array! `. \0 w0 z4 Z+ T8 a% z W
full_path = %word_array1%
3 d/ }, C7 H' m( }, j# Q8 v. t ; strip to bare address
9 ?6 x% a- m' t: @4 l7 _3 _; c. k2 E full_path := RegExReplace(full_path, “地址: “, “”)
' Z3 G& c9 X5 B. b. H5 ? ; Just in case – remove all carriage returns (`r)' L; B0 K8 @$ K7 Q( j8 R, S
StringReplace, full_path, full_path, `r, , all
( L g/ h9 i5 }3 k IfInString full_path, \
% a( q, h0 e8 K9 H9 r {5 x7 a* ?+ P( A3 p; C
Run, cmd /K cd /D “%full_path%”
: [, B- A* u; k+ u+ R: d8 o }& G/ E- N& z0 g7 L
else
, A8 r$ A' v `0 d) F/ {4 T+ t1 V {. C( `4 I0 s% A* F/ o2 V' U7 ?
Run, cmd /K cd /D “C:\ ”1 R% t% y8 L: u$ c* t/ O) F z; L
}
+ e N# s+ a/ |* W0 p }
! p, |* v# d) N- e+ Z ~! ~* \ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 [$ |( S3 C+ I% \1 W3 y" f9 R 这段小代码肯能有两个你需要修改的地方* F( f2 L3 `2 _" q" z/ g3 M
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 \) e( T3 K& B3 F 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “ g9 m, W8 d7 b& `
|