此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' w6 B9 v! z/ S: W+ U! I 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 ^8 i5 ? ^! k7 ^
方式一:' H" B% a+ m/ q7 ~- [# v
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! @' `0 h( s" j4 u9 g) d
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 i4 g' P& a0 i1 q& y4 \4 H7 K
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; M9 k6 X3 }% F3 @- _9 ~ 方式二:; W2 t1 m. V. ?3 S& ^$ ^
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
K+ F2 @6 T: A SetTitleMatchMode RegEx
8 g$ P! d) k- x' d# e; m" j return
6 |- B' ~/ N, V) @7 H. ^$ y2 P* S ; Stuff to do when Windows Explorer is open5 v' w! H* b4 j; K7 T
;, i# ]: v1 G$ N' o0 [
#IfWinActive ahk_class ExploreWClass|CabinetWClass U U, z* a8 j' d. k8 L' [6 a
; open ‘cmd’ in the current directory! P% E, y' g" C% D0 ~* i
;2 A) d7 }7 V& x% a
#c::1 H6 q5 x* z, Y: O; {5 b
OpenCmdInCurrent()( u* Q1 h0 q* d. b
return& B" x, O/ c8 z
#IfWinActive
( Q) W, a+ z6 S5 f' O6 A" O& [ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- L; ?" i, H$ i- ?, B ; Note: expecting to be run when the active window is Explorer.$ z8 S7 s/ h: G
;: W$ G8 `! T7 @
OpenCmdInCurrent()7 |9 @1 k, f! Q/ s& a l' z
{0 k2 t7 R) a' Y) ^
; This is required to get the full path of the file from the address bar* L$ y8 n l& M# l$ O
WinGetText, full_path, A) j5 U# ]6 @$ w6 o8 r
; Split on newline (`n)2 u4 G8 Z7 g+ j- @
StringSplit, word_array, full_path, `n
6 S' [ n$ g& `0 j9 d ; Take the first element from the array
) {' ~- X1 o; ]# I8 h6 U. Z$ l full_path = %word_array1%
8 z/ i& T" k- c% } ; strip to bare address/ C% [, k7 }# g w& |- C3 O" N
full_path := RegExReplace(full_path, “地址: “, “”), a9 J T$ q* O+ r. _& }) ?' T4 A8 U" q
; Just in case – remove all carriage returns (`r)
0 t* b2 T5 w% x% W* F StringReplace, full_path, full_path, `r, , all
. t0 i# _3 V$ n5 L4 {; X! | IfInString full_path, \9 b% D: w* W) a6 C
{
; P* ^/ _% ~1 C& V5 [ Run, cmd /K cd /D “%full_path%”) j% q' i$ Z9 {% F+ ?% W
}
6 X: G' {! A* ~7 A& u0 N6 x else/ s0 [" \6 u7 N$ |5 y
{6 z, N. c+ ?# V
Run, cmd /K cd /D “C:\ ”
- ~) l& a: ~: o }
& _7 y! j. u3 g }
; ~' J. V; A6 H) r7 b8 i 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
% d( | M7 x! g) S7 M' W4 V9 [ 这段小代码肯能有两个你需要修改的地方( g1 G1 E1 K- K, g; R
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 b. D* M8 {* U! d! L
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 }( G% F& d' A& h5 O
|