此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ Y6 U/ K; p0 J: L% D" o% Y 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 h# F$ j& g$ Z1 U# {# X% e 方式一:
5 `$ _0 Z7 e, G7 A3 W6 \% f1 v 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% @! W! n0 m2 i# h7 y- _' M 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# }! c- a( J" D$ X3 C( e HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ H2 p" K: K0 k& C8 f
方式二:
* {/ c; |/ i8 B- ?1 g 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' D8 P% y7 H$ G3 v# @) q SetTitleMatchMode RegEx
5 A" @1 A3 M- W, n return" |" ^" T" @# U% D0 J- M C
; Stuff to do when Windows Explorer is open- m) L' V) s$ j: H3 \
;7 Y% x# U2 s1 v% ]; z: n( Y4 r
#IfWinActive ahk_class ExploreWClass|CabinetWClass
6 d% n1 C) d# W ?$ G. n! c Y ; open ‘cmd’ in the current directory/ t _ z' Q2 E- Y
;8 G! U; f& D3 Q
#c::4 X/ J8 S8 @8 D* u* u
OpenCmdInCurrent()" V) r. C6 K* d1 E) v6 ~
return
& N, n- _! N! A* s" G& Q #IfWinActive6 L! Q, \! m7 P' b; {/ r; o# @
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 T* F! h0 B$ y
; Note: expecting to be run when the active window is Explorer.) \# z* Q+ b0 @9 Z6 o3 B
; [* v( s/ T" T5 D) a# x. m1 w
OpenCmdInCurrent()& J. Y3 @6 o6 z. E) C
{
3 n7 {( H9 I) [. e ; This is required to get the full path of the file from the address bar
6 m' g6 { X- S1 X" D* K% m4 H WinGetText, full_path, A
) b) [' r6 u7 _ ; Split on newline (`n)
$ h6 r" e1 u D' w' I0 i* Y" _" Z: z StringSplit, word_array, full_path, `n0 C0 ^' }. x @, M( ~
; Take the first element from the array
- `8 J) \- i+ Y) R8 l full_path = %word_array1%1 @% k* F5 e0 P7 `
; strip to bare address
4 g/ y/ V) g5 b! w/ ]/ u) w full_path := RegExReplace(full_path, “地址: “, “”)
& }* Q; ]2 z4 v ; Just in case – remove all carriage returns (`r)
8 v3 ^+ X6 z3 a4 r" ` StringReplace, full_path, full_path, `r, , all
5 Z5 N4 o0 b% Y' ~4 f% {$ A IfInString full_path, \6 k5 ]! c* M) x3 ~$ M$ k4 H
{
( m K, Z% I! U- a5 v( n Run, cmd /K cd /D “%full_path%”
+ n S/ h' C, J; b9 Q( \& _+ ~3 H }
, p( m0 i# B* y# A$ L else0 K1 y$ o& B* x, E5 W% r* O; H9 \
{
; E3 u) [* w; B; }# ?) ^) `9 K Run, cmd /K cd /D “C:\ ”
5 S. Y7 E* `; h) X) Z# b }
7 O4 r, s7 \8 L& S' q } A8 O2 ~# C- Q, R& G
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
l) ]. O3 `, q% O+ @ 这段小代码肯能有两个你需要修改的地方6 w/ N' ^( z. Q' Q) o
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ ~4 e/ d& P! ?( |' ?
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, b) d# m% p9 f- k' K7 ?1 C/ m( n |