此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 L: W2 x/ V, ]( D, k 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 T! p0 m& ]8 Z3 R
方式一:
) o7 {3 ^" i8 t; {1 |7 E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 B8 o. Q- I9 ~ G
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 S$ ^6 d0 ^! Y0 m HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 E1 b7 l/ |1 o. B1 j6 R+ r
方式二:( D9 L: t- {5 \' U C5 V6 F
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 h* B1 @. K' O/ ~4 A( u3 M6 [ SetTitleMatchMode RegEx
5 i- O6 O: G2 h, O; X- b return: i& s$ Y7 }6 s6 z0 i. W6 @
; Stuff to do when Windows Explorer is open5 L! r$ o" ?0 L( n- {9 W
;
6 G8 X. q# ^( ^/ K- K4 h" K, _* J #IfWinActive ahk_class ExploreWClass|CabinetWClass5 C/ ]/ {& K' C. }4 b
; open ‘cmd’ in the current directory) }' l# |3 F+ b7 K( ^
;; C8 t' e) `, l/ T9 x- n
#c::
6 b; A- i6 ^2 l OpenCmdInCurrent()
2 o9 H7 k7 t; B- n O( d2 g* ?5 _ return3 A- e0 I7 v6 h5 Q+ A+ ?6 n
#IfWinActive
8 W1 l. p0 e8 W5 D9 ?; p, n ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 R1 f* S3 e* L' L
; Note: expecting to be run when the active window is Explorer.2 Z5 A* F+ q) b
;
3 i/ @# T1 `$ }) } OpenCmdInCurrent()
8 g) k0 x. Q7 P {
# V! ~; L# c$ r/ ~5 |5 ] ; This is required to get the full path of the file from the address bar# U7 X! V' ~- K# |1 N$ {' i
WinGetText, full_path, A
" v3 B) f. w# ]8 A) E, \& }! h ; Split on newline (`n)4 S! \( r- ^* [: z0 B) l# E
StringSplit, word_array, full_path, `n
4 i. j; G7 H3 O7 e ; Take the first element from the array
m! P) A& C5 Q8 Z- ~5 h" [ full_path = %word_array1%
7 B+ c9 j% U* Q6 d$ e9 e6 I ; strip to bare address
5 ]5 D! ]4 r- L, C full_path := RegExReplace(full_path, “地址: “, “”)6 v2 ?! O5 ?, ?! _# z& h5 U
; Just in case – remove all carriage returns (`r)
2 Q7 F% U# C' x. a% I StringReplace, full_path, full_path, `r, , all* y0 S8 O1 i9 l- D: T0 q
IfInString full_path, \$ Q" \9 q# G. W) D& L" ^7 ~
{
/ {. j# {+ d( ]: Y; _/ \ Run, cmd /K cd /D “%full_path%”
6 X0 a7 x+ [& v: ]& \( N/ |; r }
- T; }/ c. W# H( B0 X else
- U% U9 a: c. E0 f5 z: j {5 |/ w% n4 f" z
Run, cmd /K cd /D “C:\ ”
- } i4 s% I. D# \8 a8 T6 o8 E }& X8 f# m4 _5 M9 u$ |( l7 v
}
& {+ `) J* X5 H# P6 ~3 ~. ?: _ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- X+ a5 q$ v6 n) e
这段小代码肯能有两个你需要修改的地方
1 J$ E1 e% r- e4 W 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; r8 @/ p- D% ]: w 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ w9 [- R8 q6 Y- g |