此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 g) P0 F1 D3 q1 U1 o 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 j% W S3 ]0 M( m* R 方式一:0 g# @3 V, p" z8 {
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 N [/ T" _ [* T4 E% Z, c N3 v+ ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和% \( C6 e, Q* ]9 D2 v/ a
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; j a$ {* Q- D% C5 H 方式二:
% @# Y9 U( o% r" U, p 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ B# r+ j6 `8 q2 w SetTitleMatchMode RegEx! k/ k3 u: _4 [
return/ p! M( L: n* d! d& L! v
; Stuff to do when Windows Explorer is open
: S/ f* }; t6 c- G# v ;
8 Z! h" [) c% ~ #IfWinActive ahk_class ExploreWClass|CabinetWClass
. B! K# ^! t( A% m0 [$ o ; open ‘cmd’ in the current directory
8 y4 @& {; o; | ;6 A* x: N o' [
#c::6 u: t$ ]" h3 C# \$ L
OpenCmdInCurrent() g5 o+ d$ M) |
return
# p! S4 V% Z5 O( F; F #IfWinActive4 a8 u7 R8 Q9 L7 b' c% i* |
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- y1 e% G2 G- _9 R2 ~3 J
; Note: expecting to be run when the active window is Explorer.
2 \8 V( U( B) ~" A+ [ ;, J ?, c5 t. T" F+ N! s$ I0 A7 l
OpenCmdInCurrent()$ V6 G) N4 V( V9 j9 f
{" ? @9 }. u9 d/ B# B7 d0 p
; This is required to get the full path of the file from the address bar
0 R) ?$ Q. g: A3 N WinGetText, full_path, A
: J( w9 H8 B, n- U$ q$ t" w0 { ; Split on newline (`n) i0 y+ q# {7 ~5 p3 K
StringSplit, word_array, full_path, `n1 {0 w ^$ H% Y: P
; Take the first element from the array) i0 t- j( Z' j' ^0 K
full_path = %word_array1%
% Z4 I& A# Y5 I ; strip to bare address
( }0 a4 z! b- f& v: p full_path := RegExReplace(full_path, “地址: “, “”)/ G$ f2 R8 Y- B7 o
; Just in case – remove all carriage returns (`r)
0 C+ e/ X* \- c4 G StringReplace, full_path, full_path, `r, , all/ J8 Q& \. x. o- u+ w
IfInString full_path, \
; D' [' y1 v, T' n {7 a6 l7 ~4 L( \# s- d& e9 D+ Q
Run, cmd /K cd /D “%full_path%”: ?- i7 z/ ?, z7 X/ }% s7 q
}- E4 `4 W6 s, m5 s
else
2 ?: w' [) W' y: K {0 Q+ m$ R( n6 E, F
Run, cmd /K cd /D “C:\ ”' Q8 M3 C. b- f8 v- a! i$ G! ?
}
2 t3 |1 q4 l$ J* m4 K1 { }" o$ _. S7 o5 S+ A& g
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& W. I: L# g7 ?+ N$ u
这段小代码肯能有两个你需要修改的地方7 h- _8 J. r! b1 O9 C. o
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 q( F: N: O! r: D 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 B1 _+ o( f1 y |