此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 o9 L. u8 [' b/ q+ s
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 |+ e* i! Z1 ^( F% f# ~* d& A
方式一:
# G& o9 Z( z5 N$ J 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, U) x, z7 Q# o3 a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 B w7 [9 Z7 U7 Q) B HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 x; z+ |9 b3 v; L3 I
方式二:
0 h* {+ L: d, f/ b* U; W 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 v" J8 N3 k: K4 F8 a2 ? SetTitleMatchMode RegEx% Y# h y- L7 P+ h
return* D$ f; r v; m
; Stuff to do when Windows Explorer is open
1 x* c B) x' y* u5 D ;
% g8 \% m5 v* y0 y# N I! U #IfWinActive ahk_class ExploreWClass|CabinetWClass# [8 S; ~8 l5 T$ o' {5 N6 z, Q
; open ‘cmd’ in the current directory
: H4 p1 F; j8 c0 s4 l ;* b( Z' P6 N! R. U. e: e
#c::
' E, N9 e" Z i/ M4 u OpenCmdInCurrent()
% Z, T% b) y1 f8 y6 u8 [/ q return
3 Q" k8 Z6 H, w% v' V/ R #IfWinActive# W) ?, z) `& O' l. f8 C1 D
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
/ \, J& Z- D! N0 @1 P9 U ; Note: expecting to be run when the active window is Explorer.5 }5 M! e E- E5 l; H" f1 J; Y
;
8 M* E' [$ I# @" j; n; Q5 e, V+ ^ OpenCmdInCurrent()
( o" z$ w& j* S' F+ v {
" f5 t$ T% d- M0 } ; This is required to get the full path of the file from the address bar. G. @ E) ?/ T+ M0 o
WinGetText, full_path, A
$ ?; i5 ]1 M4 e7 @ ; Split on newline (`n)9 e" z; R' G7 n2 B& @( a5 h3 Q
StringSplit, word_array, full_path, `n# C( A- W, I- y- q) o( ]
; Take the first element from the array# y. K" F- p; T! g; z9 ~$ \
full_path = %word_array1%. c" l4 C9 b$ d* P% g6 L
; strip to bare address" |# |& U8 r& I- \ \7 R
full_path := RegExReplace(full_path, “地址: “, “”); n: C; m4 c9 g1 `# U# N
; Just in case – remove all carriage returns (`r)
. H2 z9 R( z% L2 L6 y2 P8 Q StringReplace, full_path, full_path, `r, , all' s' C) ~) A* J A" X: t/ y" {
IfInString full_path, \
* B. D! m9 d; D4 A0 P {
1 J% e; C+ m/ Y! j0 d8 E: { Run, cmd /K cd /D “%full_path%”
) t& }2 P3 h1 e7 Q }0 k2 k! W9 w5 Z* c2 Z
else
$ w1 }/ r# m2 @- H8 Z {
& D. T7 Q9 }/ A Run, cmd /K cd /D “C:\ ”
+ e# z! z1 g, T. A4 k }
% ]. M- T; C, X2 ]) V }
/ n7 K% U: Z5 Q- N) _+ w 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 V4 g! I' h" g1 U* B8 u6 n 这段小代码肯能有两个你需要修改的地方# | I) |4 W5 y% R/ @! l& F
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ g9 \6 i5 Z7 G6 @ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ Z" I" x+ ^, r
|