此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
) x( X4 k, ~, k' R4 T( } 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。' K* t* I) b& L5 n, s: U
方式一:
# V. G$ _- f/ ^+ o; P, c 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& ?% N' S; d& d& T* `4 s 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 b4 ~) p# c! [( _+ V, A HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! z! d' v/ R' Q 方式二:
! z- S$ B& b+ }1 C1 V 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' `- Y6 ]9 y5 y# S" a SetTitleMatchMode RegEx
/ I$ c4 Z& w, S# E6 U3 r |! @ return: k' ~! N, ~9 `) h/ d
; Stuff to do when Windows Explorer is open
" I0 W4 v8 @4 _' j ;
+ i+ R3 G4 C- o8 y6 ~9 G #IfWinActive ahk_class ExploreWClass|CabinetWClass
8 N2 q7 e3 |% |: { ; open ‘cmd’ in the current directory+ X1 y1 c% _9 e! X
;
, ^2 u( s1 y4 T. n" i! x/ f7 R& W #c::
0 w5 ~* ^, A4 N' O OpenCmdInCurrent()' k( f( \3 k0 I3 m _* j, h3 {
return
& X8 u/ B+ _2 G+ ^4 S, a7 ^ #IfWinActive
. ?1 L: U v* J, ?" B4 s ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- q( W! B t# a V! b ; Note: expecting to be run when the active window is Explorer.
: A3 b, o; T! E ;' }7 u0 k: H: J/ [
OpenCmdInCurrent()1 c; T+ j+ C8 Y$ ?! u
{# K% {$ B2 c, h
; This is required to get the full path of the file from the address bar5 L% S4 l$ E. S4 r
WinGetText, full_path, A
$ ?: j1 h& y: y- D ; Split on newline (`n)$ Z+ P% A# ~ i2 ~ e1 B
StringSplit, word_array, full_path, `n
6 y* E' K* M1 z$ u ; Take the first element from the array- U1 {! j C8 {9 n
full_path = %word_array1%% Z3 l8 z4 ~- q* [/ O# ?' G5 s
; strip to bare address
3 J: b$ u0 ~) _( K. F! I full_path := RegExReplace(full_path, “地址: “, “”)2 s' C2 R+ K; Z+ q3 i- c
; Just in case – remove all carriage returns (`r)
: H G ^' }" p& j( Q StringReplace, full_path, full_path, `r, , all
$ r* j# |; W1 F+ S+ z5 Q5 X IfInString full_path, \
9 ^5 t* `7 e8 s- b- @' {5 x- K. _ {( _" C8 _8 M3 D% Y- V
Run, cmd /K cd /D “%full_path%”0 J3 \: ]6 ~4 P1 [
}
2 n, Z9 e1 [6 {' g else- @& p5 z! D! @* E3 y! a" Y0 s
{
: }! V5 f1 ?: w9 Q9 ?& e$ | Run, cmd /K cd /D “C:\ ”- g1 a6 h5 m; a" M
}
7 ?7 m$ w- k4 X6 w }! m3 _2 X% y- e, k0 }5 n
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 `: ?3 t0 o6 F0 X$ y7 s/ \
这段小代码肯能有两个你需要修改的地方5 [" ]4 w" t7 d) T
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' e ?# s# t, n4 Q: i
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, K- A* r; m* u3 D% T
|