此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 r- b; ?, G: p( w0 Q' j
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
# \* l# {5 s5 l 方式一:
/ I+ t% q: g8 S* u- }( M- T 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
}4 P4 N8 f8 J: E6 R" A 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' t, {: F C' @6 e6 ]+ ~ u8 e3 D& e HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( W8 N" |6 e( Y3 P6 Z" Z
方式二:
4 F0 P/ g: |! m9 i, m4 P, R$ u 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 x; w5 \9 q1 Y, z- E7 w, h8 j
SetTitleMatchMode RegEx
$ S1 o" j% J! ~! Z" S6 | return
" }3 x% G9 x6 f/ j4 v [ ; Stuff to do when Windows Explorer is open
- J, H+ g. A4 f& r, a ;% q0 t/ V- r4 o- v- ~
#IfWinActive ahk_class ExploreWClass|CabinetWClass
; C4 I( q7 w- N! k! i l ; open ‘cmd’ in the current directory3 ?" h4 u% h2 V8 x/ B' ?7 [5 K- T
;
3 F5 o. E9 v8 e #c::8 V( L4 G- O- H' b7 X) R/ x9 p
OpenCmdInCurrent()% U7 o: f" D" i
return+ a% l; S% W' U
#IfWinActive2 M# l2 ]8 l( k8 {6 `# e
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 u5 a2 P) o& j1 ` D$ e$ a8 E ; Note: expecting to be run when the active window is Explorer.6 O! _; z# U' x9 i
;
2 U- V. n1 j: b8 \1 n OpenCmdInCurrent(), ^- E; r* a" R
{
, T: ^# d3 v7 X; A, t$ g ; This is required to get the full path of the file from the address bar; b, k0 c8 s, Y' {- o- ]- a
WinGetText, full_path, A- N/ x; p* v3 @1 h. n% \
; Split on newline (`n)1 g4 V: k& ~1 Z! U: l! X3 ~
StringSplit, word_array, full_path, `n
4 U, c3 n& C" d# m- a" ?( ] ; Take the first element from the array
6 E' a5 `! W, I4 d5 J9 C w2 W* e full_path = %word_array1%
: n$ @% U! L9 v7 D0 t7 P ; strip to bare address7 Y J3 |" V1 }7 n+ h' H# ]$ d3 U0 t
full_path := RegExReplace(full_path, “地址: “, “”)0 S8 k+ q: [# C: c! |
; Just in case – remove all carriage returns (`r)* U! V+ [' G; f: n
StringReplace, full_path, full_path, `r, , all3 r- } h6 \) }
IfInString full_path, \. J q4 q" x7 a9 t2 }
{9 F9 x' p# i( ~9 b! ^- S @+ z' ]- G
Run, cmd /K cd /D “%full_path%”6 c9 q" }3 ^: P; J/ l
}1 s$ W# h$ x+ F: R4 ]( d, v$ b
else- F3 \. I5 d1 P* \
{
2 g% C( b4 h: f' O Run, cmd /K cd /D “C:\ ”
2 h2 Q# D8 _; E3 }, y }
/ ?+ T/ S% s( k, Y% | }3 M0 a' c: O% M4 w! G
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' I @/ V1 p# j" R/ v8 L& m
这段小代码肯能有两个你需要修改的地方
" y+ Z, t. x* w5 C 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 f! s! p D9 C: j) h. k i 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; \% U9 ?" Q5 v5 x |