此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 H" Q3 v% r0 P; M7 g# D
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ c2 V& A8 N: w6 P" n
方式一:
' \8 a3 ^1 s5 Q5 C( n2 @7 K1 w 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& m* Z! ?1 W1 k 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 z& T; @8 A* X' x( Q2 W
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
. A8 d2 R9 `) g( I! d; R% e 方式二:
& v N) X1 D7 [: n, B0 c 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 w3 l% n1 Y9 `8 B8 L$ g* {* b SetTitleMatchMode RegEx
7 |6 L5 R; s! C1 m! q return* U Z- _0 {5 A( b: x
; Stuff to do when Windows Explorer is open! l9 v3 c' \0 m0 h4 X( [0 ^
;
! e" E1 c }7 o$ d4 Z9 G# O #IfWinActive ahk_class ExploreWClass|CabinetWClass. N0 {, j' ?" a: ?# j4 V( {
; open ‘cmd’ in the current directory8 }2 |6 n: O. `7 y7 i3 s, T1 D3 b
;- R( o% k* \5 }. l; p
#c::
, M+ `! d) o+ z, k: B! g OpenCmdInCurrent()
8 a& f' S8 K: _% T; g' |/ k4 m return ^* B& M& w2 r& y0 s
#IfWinActive4 `1 i$ v1 ~3 D N: K2 e, B$ W
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 q/ L! M& u' _# l ; Note: expecting to be run when the active window is Explorer.
6 b2 u2 K6 c7 a! V ;5 O$ \- e9 Q) Q1 Z7 A( \' n/ g
OpenCmdInCurrent(); k+ p8 w; L8 i, ^
{
; B! X" \( v; m0 b8 u% m ; This is required to get the full path of the file from the address bar
* U4 c' D8 m* e WinGetText, full_path, A
0 f6 g: I5 X; y/ r* c ; Split on newline (`n)1 [$ u' H! P! C3 n$ o: K% a+ s+ y1 a
StringSplit, word_array, full_path, `n! Y) r7 U( I+ H, s
; Take the first element from the array+ r& s& l5 E7 P& T$ E
full_path = %word_array1%, l3 }$ s* X- P6 I
; strip to bare address) J2 |: m; Y* E* k
full_path := RegExReplace(full_path, “地址: “, “”)2 S" u6 n# _: M' S7 h y' z
; Just in case – remove all carriage returns (`r)
$ A1 l+ A- D" m. ?( E6 B StringReplace, full_path, full_path, `r, , all
7 G# R3 d' w+ N5 t) O& ^4 T IfInString full_path, \
# O$ ~8 X4 X! V {
. f) ~6 R% C5 l0 h8 Z Run, cmd /K cd /D “%full_path%”
4 _, L7 S$ y$ X2 i* A }; d$ w& }, ?5 R
else
8 R( W/ J, \4 L% s {; ^$ U- V" `1 B+ v( e7 B+ G0 X
Run, cmd /K cd /D “C:\ ”
9 p; ? O9 v6 C6 i7 R- F }0 q# q5 p# `7 K/ c; s6 R5 O! G
}% X. |$ t; _! Z/ c$ B
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 S& E% _: d% r( w6 u7 E2 O
这段小代码肯能有两个你需要修改的地方
8 X- b4 ?; k+ F# v 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& ]+ {) R( J& z. U
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& _$ ?. X0 w! F5 r1 D* C+ t
|