此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 R, n3 D$ X2 N9 W Z5 V) z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 O! e- \# y8 X, E) y/ w
方式一:- s) m M3 {+ i# w
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, b' {% C3 K6 C6 v$ N
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; P) J( Q8 a* K' b HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。' e7 D ?6 l' W* V4 Z
方式二:
1 q, @* b" O/ s4 ]# K! @ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
1 h, [6 Z) U! d SetTitleMatchMode RegEx4 b; f+ u/ [9 r; m. i; y F! [
return
6 P9 I* b% X& d( ] ; Stuff to do when Windows Explorer is open K g5 U5 X9 p# F( l! Q
;6 X$ y# O: ]9 T) w# X: s7 `) o
#IfWinActive ahk_class ExploreWClass|CabinetWClass
+ D+ F9 k* o$ ]5 I, X) U% _ ; open ‘cmd’ in the current directory
1 I2 E) }1 l3 G ;
9 W; F9 o3 d1 [2 F* e: H #c::
" T% j% E+ _6 y( p* W4 v6 O) h8 Q OpenCmdInCurrent()
6 m& S8 u, g7 X( F: @' N Q& P |" C4 j return7 o2 ~( E: _! s1 E$ Q P
#IfWinActive
4 Q# s' g2 s, t' I8 s ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 m7 T5 ~2 F% T( E4 P
; Note: expecting to be run when the active window is Explorer.
' \ P! T5 u! T/ P1 g# V' X5 F ;
9 O4 ~/ Q6 }) R# u+ j' o9 ~4 F2 B OpenCmdInCurrent()% I& I8 v) t; W/ R B. [( T
{* ~, D& V: w# Q. _4 Z: b8 s7 J/ d) n
; This is required to get the full path of the file from the address bar
* p' Q3 z M9 e# u* D* ~4 [3 l- o WinGetText, full_path, A0 `* ?( S: t1 i; X$ ]/ R$ `
; Split on newline (`n)
! ]/ D8 T9 i& X; ^7 A3 } StringSplit, word_array, full_path, `n! _5 O- ]; v n
; Take the first element from the array
/ V: [, {7 p0 `$ ^. {0 j- H full_path = %word_array1%; @. L! p4 o9 C0 U2 N4 ~
; strip to bare address( X3 I) o7 i3 D5 Z l4 g6 i
full_path := RegExReplace(full_path, “地址: “, “”)
0 w7 Q% @2 M- R ; Just in case – remove all carriage returns (`r)
" N2 l, W A9 R# s2 ?6 o StringReplace, full_path, full_path, `r, , all: j" V' m) T l4 y& |9 a
IfInString full_path, \' K& j) x6 U8 l
{+ H# ?/ i; Q" x; J0 d
Run, cmd /K cd /D “%full_path%”& D: M6 A1 N. D+ V+ R6 p
}2 T7 g( r, e4 n7 ~5 D; F- }
else7 ~/ e3 N" s% R- q% }0 G
{
) k$ x% R( L/ ~. r5 L* U J Run, cmd /K cd /D “C:\ ”
( i2 Q; o/ d$ G) K n }5 B6 D* {4 K, l2 {
}4 W; d/ a" K: b1 ^* a8 U, i! I; J2 o
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' h* n, b2 T# {
这段小代码肯能有两个你需要修改的地方2 u9 t4 E" ^& A J0 e w
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& X$ n/ }/ T8 Z8 T
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 N8 G! r& {+ U0 p. k) M
|