此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% n; D' A" @7 A _% u
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 c& W9 S9 a! n 方式一:
* `' G9 u, E! Z3 K6 v2 t# } 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 `1 f9 r" } \% [8 T 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 u- w h. ?) f
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- g* Y, }5 C F# P4 V' b
方式二:
: K! m+ E( ^. `, N( a: B( g; r8 T* Y! I 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 L: {8 Y7 P5 ~7 e
SetTitleMatchMode RegEx
$ h( U6 r0 C" e" o return
. Q% r! c1 F2 d3 W& N3 R0 Y ; Stuff to do when Windows Explorer is open, l0 Q" t7 D6 e& l x6 Q l
;
6 \; G3 r0 `0 J, l- J( t5 s #IfWinActive ahk_class ExploreWClass|CabinetWClass
7 F6 }9 @8 u$ f; V0 y1 z$ L ; open ‘cmd’ in the current directory! p2 B2 \9 W$ B1 t9 t S$ v; q+ O
;/ N. V7 _8 p3 V( M3 p" ^
#c::7 U. }/ Z; J- n+ A
OpenCmdInCurrent()5 W8 J3 a2 e, G5 @9 s
return3 F O3 a* M* a v% n
#IfWinActive
# G8 b, Y9 N. H/ z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.4 B1 Z' J* \( k+ J7 m9 o
; Note: expecting to be run when the active window is Explorer.
- g6 J i7 \% ]1 C) B4 e ;
& m8 `; O2 _# G7 q# b9 e. f OpenCmdInCurrent()
( g, s' u- [; \( u( B% ~ } {6 P' a: k R' R7 ]* t
; This is required to get the full path of the file from the address bar
, I( f7 n5 [6 L7 z3 ] WinGetText, full_path, A' m8 j( z: ?1 ^: z
; Split on newline (`n)3 w- [6 t3 g7 l7 K8 |1 O! t6 g4 z: }
StringSplit, word_array, full_path, `n8 C" F0 a; K& @5 A/ k, \- x u
; Take the first element from the array
% d/ ^* u+ v3 ` c full_path = %word_array1%+ k, ^. ~! a% A( [
; strip to bare address0 ^+ x, [1 h1 v/ Y2 Z
full_path := RegExReplace(full_path, “地址: “, “”)* l ~/ x% O) l c7 F
; Just in case – remove all carriage returns (`r)
) s) V6 f5 d6 O4 J1 \ StringReplace, full_path, full_path, `r, , all, ]/ I$ k0 T1 L1 R9 d* f2 _
IfInString full_path, \
" _" K0 i" X+ k' f* a {; [* p C) c5 [& n8 d5 r- ?3 Y
Run, cmd /K cd /D “%full_path%”
6 J, @; e) p/ }) { }
1 X" i) A0 L) _ else- T+ S! ^4 w ?0 H2 `- T
{
( n( M7 H! U4 S$ i; S Run, cmd /K cd /D “C:\ ”3 s9 I3 o- D* d/ @9 ], B
}
4 s V( ? m! d7 G$ ^" n( T }
3 s+ r" O4 d m4 h. r' F3 D7 g 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 V1 {9 `4 v8 B8 |# D* E 这段小代码肯能有两个你需要修改的地方; J. |0 Y0 o/ J% n% T4 S) O
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# M+ [+ Y. `% r1 \4 k ~
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; X; _" X; b4 ~" e
|