此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! y( v6 s6 H0 Q$ N
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 R$ ?$ b+ k) V+ ?1 |# y x( E 方式一:
& m5 E: o' z U! S; e) Y7 u 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ }3 D1 k9 A# N! v6 a2 n9 C* K 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, f4 M J6 }# N m( |; b HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 S2 @1 p2 ?1 v3 U6 ?9 b. g
方式二:9 d' g" y8 e/ ^3 n5 F: `
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' a! C$ s/ @' Z. ]
SetTitleMatchMode RegEx
' \- ~ P2 y% O, B3 {* K, k return- _& z2 r' l" b+ r4 Z2 r% N" {- B
; Stuff to do when Windows Explorer is open9 h5 H+ _3 G4 }! c: M
;2 W/ w3 @. }* Q
#IfWinActive ahk_class ExploreWClass|CabinetWClass- e; X( f/ |5 s3 V# O1 D
; open ‘cmd’ in the current directory/ [1 ~: k4 E1 S1 b3 s' F E
;8 o; D7 {: M0 k+ j
#c::
: @6 Z( E- d' [( T, U4 m OpenCmdInCurrent()
, U/ u& S: W$ u1 \& y return- ?6 c" C0 _( @4 Z9 a
#IfWinActive' K" ^3 d7 ? ~* L! d; z! c& P$ n/ D
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 W) b2 ?4 b) s- U) n
; Note: expecting to be run when the active window is Explorer.
7 Z5 u. N' ]$ h4 } ;/ }* K4 j0 c6 |0 J! Y
OpenCmdInCurrent()
2 x; q" c2 I2 D! ^8 ? {
9 o+ d+ o% l9 i- w* W- A ; This is required to get the full path of the file from the address bar( N( F5 T' D$ ?, k
WinGetText, full_path, A
- |6 @: S* w9 E ; Split on newline (`n)
2 Q- C9 }$ u9 D% r7 U StringSplit, word_array, full_path, `n+ z0 S9 ?9 X1 E; Y
; Take the first element from the array% F2 D) X) Y. B M1 I1 J
full_path = %word_array1%% U9 J1 C' z" B6 {) z: x6 }
; strip to bare address
+ k& ~; S. s+ g7 r& N3 b! W! P full_path := RegExReplace(full_path, “地址: “, “”)3 G/ N7 A4 s. T8 ^4 Y
; Just in case – remove all carriage returns (`r)
3 s9 ^3 F& A+ y. }7 a7 I StringReplace, full_path, full_path, `r, , all
- U& n# u) `( x' @ IfInString full_path, \2 e: o, V7 b' f1 ^: Y$ M$ b1 [
{8 d8 J3 x/ ?3 w5 E5 }- m
Run, cmd /K cd /D “%full_path%”
; U3 k; y9 A2 [ }
; t w: X) ~/ D else
! r+ Y% p h' D: f1 N8 Z {% h% r( F& P \
Run, cmd /K cd /D “C:\ ”2 i1 H$ p' R& ? `1 }
}
- N. _/ C" x5 r9 G7 k+ c6 ?. D }/ |! F9 w4 m: h
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 }7 O/ ]% g y4 U. v2 t& K
这段小代码肯能有两个你需要修改的地方
$ |, m& s4 z( I* a 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& \' R- J1 {2 |
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* \1 W' @$ ?: X# D Y4 q9 c( t8 M |