此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 J9 }# }) e s+ R
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% ~2 \1 Z B+ f2 ^# D
方式一:
7 P! d( S2 u7 x; T 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! k: X# ~& G) [* m% {4 g
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% l9 k$ o- f) `; h3 w HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* y$ h0 ^! S0 E f# C
方式二:
, y2 f- w' o8 m) s2 F9 N5 m 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 C; s/ P; s" V# ~% O
SetTitleMatchMode RegEx
' m6 [$ g; g7 y! v8 o8 A4 ^ return7 i5 \9 ?. K3 j3 `6 x3 K
; Stuff to do when Windows Explorer is open# k! }2 j: q! U& ^# n% X- {. ^+ y5 v
;; n: J, S; s! S$ X$ E
#IfWinActive ahk_class ExploreWClass|CabinetWClass
' j, ?0 [6 {7 U1 f1 v6 X ; open ‘cmd’ in the current directory$ k- T# C! C5 t" E' w6 Z, K
;6 c. }9 p3 k( V2 \$ M
#c::
3 C* a! @& m2 [6 p OpenCmdInCurrent()
, {' g. r6 e* Y return
& q1 R O8 Y& \+ y4 x #IfWinActive
& u2 L( H: u9 \ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* {! b+ b' m1 `* _
; Note: expecting to be run when the active window is Explorer.
& {; u/ `9 Q! W6 s7 ?" V3 C9 N ;; ^2 {2 U2 r/ R
OpenCmdInCurrent()
' j% u+ u2 b3 h0 c' X' { { ?# d) V# d8 Q- E" B3 n
; This is required to get the full path of the file from the address bar" L# m1 O) D) j
WinGetText, full_path, A" @8 P9 u" ~* x7 R6 J
; Split on newline (`n)
/ g, t8 s) O9 [4 D. R( J/ w StringSplit, word_array, full_path, `n
; _8 k# o' c8 o! z ; Take the first element from the array
; W; `. }; F3 z4 v* {/ o% S* ? full_path = %word_array1%5 r* H# P! J* c
; strip to bare address
; T; [- X+ v j" f6 N full_path := RegExReplace(full_path, “地址: “, “”)
* z: o0 V. V' ^8 Y; J ; Just in case – remove all carriage returns (`r) Q8 i. J4 }' |# D% E
StringReplace, full_path, full_path, `r, , all
) m7 r3 W0 |9 S. _& x IfInString full_path, \
* L' B7 h( d7 u3 {3 l' q: q {5 Z2 G" f2 ~& X* |: K% I6 d. n7 |
Run, cmd /K cd /D “%full_path%”
# L& v! R% D, s( b$ w" {0 ~! s4 H }* Y( o, ~. s2 D. G, [6 X* I$ J4 d
else# A3 l$ n( g ^ @4 d) a
{
0 |2 @ K! W- g; K. {2 c Run, cmd /K cd /D “C:\ ”
; b( i# A+ B; ` }
( \9 j* F/ R) F" f0 I4 o( L) j" z }9 h3 B! z# [, L7 u- T
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: o0 ]- u$ Z q3 H5 D/ C
这段小代码肯能有两个你需要修改的地方9 A: e( p( q! L
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. v: U$ |5 A" p+ N 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, k8 P* ~+ ?% k |