此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% @3 a( X) g8 n5 o 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 k8 T! @; q0 k* M3 T
方式一:
2 D6 ^, q# R) W% I) |! i, e 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% ^& M+ i7 h, M2 Y- v" v
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 ^4 s1 R5 Z% M0 h2 B( v% H; f' d HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ W% `, A; t* \% e
方式二:- e: u5 c" L1 j$ v4 Z: _
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& X8 c/ o9 G5 r( x+ g. {- { s6 i2 u SetTitleMatchMode RegEx
c% y6 F0 b: y0 @8 t& {) u/ U return. P( V! }) a5 X+ C/ o, ~
; Stuff to do when Windows Explorer is open
8 Q( Z) U; v, Z) e% ` ;
; v; w9 T: }% {$ l. O0 r) N #IfWinActive ahk_class ExploreWClass|CabinetWClass3 W ?' `8 e; l8 K: d( l/ V% |
; open ‘cmd’ in the current directory* ]- L# M# h* B+ U' i0 d h
;; r: y) p! D5 H+ o! c
#c::. u" U" J3 w: `$ g1 F1 `: H
OpenCmdInCurrent()
I. i% \6 N' [/ S return* }: c& |3 R$ Q7 u/ ?7 B
#IfWinActive( F+ O9 K6 g+ J3 v% y1 `
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
( m- \2 w, o% { ; Note: expecting to be run when the active window is Explorer.! D- V, f# Y, p3 ^! y# G0 N
;
5 r' D5 l% u* Q" F$ O OpenCmdInCurrent()
! c& z# W9 j$ V( h) D6 \1 f {
5 S: f2 a+ f3 T& H) } ; This is required to get the full path of the file from the address bar
! `8 L4 z/ V5 @/ I2 e7 m WinGetText, full_path, A
0 K4 q+ w' o9 M7 t+ N7 V ; Split on newline (`n)
% Z, e# h; L! j* @/ c StringSplit, word_array, full_path, `n
1 T, t; b3 E! {) g8 I2 X: V ; Take the first element from the array
; Z/ ^* }# E( k# |6 ?. y7 N full_path = %word_array1%* ?/ P; g' c6 |4 d% P
; strip to bare address& A9 m( Z* h& {& D0 Q5 t
full_path := RegExReplace(full_path, “地址: “, “”)
8 k ]1 n+ W" p, F7 q- L6 | ; Just in case – remove all carriage returns (`r)9 c4 l6 a! J& a( n" k2 h
StringReplace, full_path, full_path, `r, , all9 ?3 E }) \. J' h7 K, E' ~0 n
IfInString full_path, \
4 m( v* @5 L3 h$ |0 b5 s {& G& b" F; w. M& J
Run, cmd /K cd /D “%full_path%”! {1 H# _! ^& J9 s
}3 [; i( V6 ~; X, G
else* S. r+ ] D3 Y7 p% G+ i7 X
{3 ^+ d. K, N, @- M$ N/ j' Y+ F7 `
Run, cmd /K cd /D “C:\ ”
2 C1 L' p! `1 c }
; e8 k, F2 o w8 J, C }/ s2 q! ~ R8 N/ b+ }' }5 k
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
6 j9 P s% G$ V& R 这段小代码肯能有两个你需要修改的地方' H9 P2 q [6 [) _9 _
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 w7 P s3 v2 S" B) ?4 h9 o
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 O6 c- s7 ?* Y4 ~: T& | |