此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 {* Z9 k+ X2 [$ l/ f) {! q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 R: R3 q3 x- f4 S/ p) ~: Y% _
方式一:
* ?; ~ B# c H 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) x' T2 q D+ ?0 D 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' ` _% c5 _; r7 h- C
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# Z. V5 t% Y# C& t( Y* w) ?* i7 {$ X
方式二:
5 y$ v! E3 O* x2 S 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# l" F- P3 \ ?; K0 n SetTitleMatchMode RegEx. m& u9 q% W Y( l( ~' Q. |* a* S& ^
return
3 M" t. X+ g4 a% j7 b9 m ; Stuff to do when Windows Explorer is open
- F; j2 R. A4 s3 Z& H" z ;- b- ]$ v) ~+ }$ t0 I
#IfWinActive ahk_class ExploreWClass|CabinetWClass
6 M* n# x" y5 C/ p) j: V ; open ‘cmd’ in the current directory: U0 J9 r) E5 [7 K6 I
;
0 Q* U+ q6 t6 `7 K #c::& Q2 t% Q. z( q& d7 @
OpenCmdInCurrent()
+ v( u9 }$ ]2 j( y9 z" V) d return
; L: F9 \2 q" L$ z/ u% h/ P% ] #IfWinActive
7 G. a' [- ~! s i8 n* \! J ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 `- Q& X# S) f [! B
; Note: expecting to be run when the active window is Explorer.% O7 u9 s- ?3 r: ` J- _3 j$ z- I
;* L) K( y. ^7 z. Y( t
OpenCmdInCurrent()' a" e o5 b2 ^3 u8 N- x5 V7 D
{. r( E: [- `, H3 ?- x
; This is required to get the full path of the file from the address bar6 c, ^7 }0 I6 B3 }: `3 F" N
WinGetText, full_path, A) k' B( A6 [: H1 c5 ?3 @* a; X& e
; Split on newline (`n)5 V: W/ }' r7 v1 L# n
StringSplit, word_array, full_path, `n
+ t A5 e+ ], j, \1 p) R4 a ; Take the first element from the array
6 S0 k7 g3 A/ y! x$ p$ E" \ full_path = %word_array1% V7 Y2 d* |* P" M- v: a8 c
; strip to bare address
2 D$ _9 V- V2 f9 ~3 I% u full_path := RegExReplace(full_path, “地址: “, “”)
# k `1 q6 N6 Z0 q- Y ; Just in case – remove all carriage returns (`r)$ t& u# } t$ t( W
StringReplace, full_path, full_path, `r, , all( m# y8 }: t2 s5 |! N4 N
IfInString full_path, \' d t, ~/ F: S: w( Q
{7 \2 `. t7 i R* i2 i
Run, cmd /K cd /D “%full_path%”
7 P0 K+ L$ r. ^+ L; Z }0 X7 [ K, ? Q; T: W/ U
else: R8 e6 k: G8 @, u" L% t; a
{4 C0 K6 n+ ], M2 u4 u9 c' S& s
Run, cmd /K cd /D “C:\ ”
' t- {4 {/ N. m( o. B }. \) M7 a+ v" Q1 b+ r* G
}
' C* L% f# _; U 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. A; ^ u- G% l5 ~: b2 B0 I# | 这段小代码肯能有两个你需要修改的地方
2 h8 Z' [ G2 W 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 O9 C$ N0 E+ v5 U
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, w' C+ u7 j, Z- y# y |