此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
1 e% [/ @) A4 o. s, F Y* [ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: O' `8 P* {' M. w* C6 X, h 方式一:
8 S5 G K+ J' P+ I { 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 h7 Q' o n/ X) q, v7 P- t$ ^# ~) y 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" O! o4 ^- M8 | V, W
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 w- j, ?: U+ G3 y4 \# f$ B/ ?
方式二:( d! R6 ]; n% v
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- q& L0 I) B4 M SetTitleMatchMode RegEx" x& ` y+ `' I* [( j, ~ s
return
& f3 M0 W3 f; P) @# C r, j, y: L ; Stuff to do when Windows Explorer is open/ t: W% ?: D: f( z" }4 R% f
;$ ^8 d, d" e* q5 L
#IfWinActive ahk_class ExploreWClass|CabinetWClass! S/ H2 e! f/ V% E
; open ‘cmd’ in the current directory9 k% f7 z& ]' m/ Q+ ?
;8 Z& M5 H3 H2 {6 U' r; U' I2 D2 M* q
#c::5 y; l: h2 _+ Z4 j8 m6 @; ^% k# M
OpenCmdInCurrent()
! ^( e8 s3 F* P/ | return! q; `/ T8 K0 p6 M% S
#IfWinActive- k+ o! [( [! C% x) _
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! W+ q9 g: W# C1 G- V" c' y- I0 Q8 ] ; Note: expecting to be run when the active window is Explorer.- c- x2 [9 J$ B
;
4 F* E y( j' _- A9 J, P$ c3 D' u OpenCmdInCurrent()
N- j- V" k! N/ N- p {5 T! ]) U, a0 S0 S) k
; This is required to get the full path of the file from the address bar- O' [- N* H0 ?7 w
WinGetText, full_path, A; T2 n& V& |: _- _- o( G- U( M
; Split on newline (`n)
! ]( d0 v h3 k StringSplit, word_array, full_path, `n! W2 j; D! \) g! o
; Take the first element from the array
% G) W m' P6 V: Z- t1 ?: x" c full_path = %word_array1%4 u( ^ e p$ m J8 y
; strip to bare address
( n g- T: {/ o+ c# g full_path := RegExReplace(full_path, “地址: “, “”). ~( x$ v) |' p7 e' W+ J
; Just in case – remove all carriage returns (`r)
9 [6 F8 l. d$ b( M$ j8 Y( U, o# _ StringReplace, full_path, full_path, `r, , all
' N- L5 q/ u0 F5 `* | IfInString full_path, \
- A* Y, L. |6 V% C# ^5 z {
6 O* p$ `/ A6 {; K6 ?* Q: H( V- v Run, cmd /K cd /D “%full_path%”1 i+ _5 ~ R, T5 E' A8 m" _
}
- P& W4 O/ @9 ^ else: B+ }/ r6 W% `" c1 n( M
{
* u3 E4 W6 }9 I9 i5 E& Q Run, cmd /K cd /D “C:\ ”
# N, L5 G% H, u }
/ n' G5 {* B; i: I2 N/ | }
1 z5 l3 l1 k: R4 |5 L2 o1 n4 f 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: t5 \; G9 \7 J) o3 \) l9 q/ d+ E
这段小代码肯能有两个你需要修改的地方$ ?8 }# D+ j7 m8 j5 Z. j7 ]5 V
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' v S: G: |7 u2 d+ l' k, `7 G 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “/ E [. E& ^6 o$ }( |+ ?3 O' ~
|