此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) c) |& A. R8 I0 y# O5 }
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
; x% ?* J7 q6 Z3 Q- ?$ f 方式一:8 ^: I. G$ n% Q3 T% }8 E' X; c3 `
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 o; {, d0 F% S; x+ m+ ]
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& I% j2 Y+ L! d0 \: Y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- ?- \( k3 w7 \9 Y/ L' P
方式二:- P$ s$ a9 B! W7 L% M( }& l- f
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ B* q' w( h, g4 Q7 j SetTitleMatchMode RegEx
5 B, ]" W" Y7 r1 a return
2 J t( e7 ?: m9 Z ; Stuff to do when Windows Explorer is open; a7 t. @# O2 V, t
;
5 v- R$ C& r/ w" ? #IfWinActive ahk_class ExploreWClass|CabinetWClass
! m0 W0 j' @# b7 e" n' p ; open ‘cmd’ in the current directory
# }8 H$ Z* P% I3 C5 D- g. B ;3 }2 d8 j% H" [3 f0 N- e" N
#c:: U& S3 K* k/ Q
OpenCmdInCurrent()" p; {' L! @( K+ c6 D1 n
return
% a* w* V7 E P/ z" j: }7 [ #IfWinActive
/ h+ R% U0 {8 v0 ^; G+ Z: c+ U1 v ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 A: X; t( V8 N3 j( Q: q' M
; Note: expecting to be run when the active window is Explorer.
( A4 j4 D$ C+ l% ?% I ^# P1 e5 V ;' r# ~: B$ j$ q3 O3 ]
OpenCmdInCurrent()
; q% v0 [ ]3 ]6 O6 d& R" ] {/ H& h6 h% v! D" V' P% Q$ k! e
; This is required to get the full path of the file from the address bar
; Z6 j$ i- O* {/ G0 @/ z" q5 N WinGetText, full_path, A' A$ ^5 |: y# G1 d- n. w
; Split on newline (`n)
3 W* ?* U* z5 }* S StringSplit, word_array, full_path, `n/ @6 v6 U: V2 m! V5 o" w$ r
; Take the first element from the array' M4 _- c1 M% [& J
full_path = %word_array1%
W0 D# b& U; x# F$ ~ ; strip to bare address$ c* l y0 F/ M2 v7 N# {
full_path := RegExReplace(full_path, “地址: “, “”)
A6 v/ K8 s$ V. S* E( J: `% E ; Just in case – remove all carriage returns (`r)+ u6 j, J; b( l" P$ s+ l
StringReplace, full_path, full_path, `r, , all$ o& f- }( f% i: z% d' `
IfInString full_path, \
$ Z5 z$ l5 A8 K6 J; E$ f {& ?7 w3 G( e( N
Run, cmd /K cd /D “%full_path%”
/ A! u# j( ^2 O$ p. U+ Y }/ s$ {; ]2 Z; K8 x3 `. W5 V9 l
else) |' J5 I; ^% T7 |% s) k% F
{! ~, R$ O8 L. ? a$ w4 [
Run, cmd /K cd /D “C:\ ”
: C8 g/ Y+ A# o& y* L }
: n& U( ]# g5 B' b7 ^ N0 x }/ L, b) a2 D9 q- C, t& y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 Z6 P- `; h% t. k/ |
这段小代码肯能有两个你需要修改的地方
* N* j+ P5 U9 E1 {* D9 z+ {7 d 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! z$ i* N' E/ B4 G6 y5 x
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 w8 Y8 G. r- v7 ] |