此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 j- `# t7 u* N% h5 Y# u/ r2 | 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
( [3 L7 n# z1 G. ~& W0 ~ 方式一:
) x1 Q" G6 O( ] 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 y8 @8 z! S, L! c/ H! E( G
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 r1 O3 _1 y% e) [# B HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 s$ p' F) c* n; V
方式二:7 T! e: u/ a8 A
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 ~: ~8 m6 a+ [# G- ]
SetTitleMatchMode RegEx$ p5 H: m4 Z3 ]$ D' E C. k5 s9 ~
return+ r9 @# c% T, M+ y% S7 D; P8 h
; Stuff to do when Windows Explorer is open3 W/ C7 ^; H7 U. u4 f# S. Z E* g, i
;* F2 q. n% s! ^# r5 C& s/ U6 b
#IfWinActive ahk_class ExploreWClass|CabinetWClass8 J* p& v" B* w! }0 N; e5 D$ h
; open ‘cmd’ in the current directory
3 Q4 V7 ?' V9 U* E- q! x( k ;1 c' y7 Z5 s3 V- m
#c::! \. D, H( d1 K
OpenCmdInCurrent()
3 m+ ?" S/ I( W/ b2 F) j8 m) { return
! g/ @8 p; E! F |- j6 v& k #IfWinActive
8 q' h, E( w& M% z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 c- N% p9 h: k& v& k3 H9 \
; Note: expecting to be run when the active window is Explorer.. \' c9 s( B/ T
;, L s3 b2 T ^1 `1 a
OpenCmdInCurrent()
, L/ n% c6 z1 v3 M {' V1 u" j# L5 C
; This is required to get the full path of the file from the address bar1 O" {4 u: c4 S# v
WinGetText, full_path, A
3 q6 S) s: m2 R5 Q ; Split on newline (`n)6 @# X. Y1 S9 [: s; l1 Q4 |0 z: i
StringSplit, word_array, full_path, `n
R7 y' K+ f- j7 } ; Take the first element from the array. K% z' B. b1 F- Q$ K
full_path = %word_array1%
+ u8 `/ w1 }5 ?7 m& W- e ; strip to bare address1 ?+ t% D$ t" @! F, Z( h
full_path := RegExReplace(full_path, “地址: “, “”)
* ?5 ]1 l9 v1 i5 f% M ; Just in case – remove all carriage returns (`r)
) R- @7 P* U6 `9 y* {. x StringReplace, full_path, full_path, `r, , all
& P& X- f" ^* y8 Q IfInString full_path, \& o0 }' p R9 _" H2 b# G% p2 ?+ A
{
4 G8 P N4 ?$ t$ p3 H Run, cmd /K cd /D “%full_path%”
$ B& K( r- |. c2 Y& B }
1 b# O {" P6 W0 L6 w: K else; r5 w, N7 A- N9 `# e
{
! e& v! y( j' ~3 N Run, cmd /K cd /D “C:\ ”8 [5 Y1 I% z2 V6 l: ^1 Q
}+ p) \* P K7 i
}- P$ z, S/ n( C* h% s
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 ^* V* n( _1 Z2 {3 T6 `
这段小代码肯能有两个你需要修改的地方
" C' W' ]( f( ?+ r- _+ @1 } 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' H! ^8 o$ p, J5 t% [ h 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! K$ _7 T- ~, G5 X6 S( i+ H0 M) N |