此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 P: ?& c+ B" z# I
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" R; g) N+ }- d( H \ 方式一:
8 Y: _' E" P9 g# `3 i# s( \ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ y- ?; d2 N }. z% C 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# ]& ^( x Z. h y) w
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! I, e9 L' l( e8 k4 O5 m 方式二:$ P- X9 y% C) v& d4 A8 B0 u7 `3 \
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) R, g) H" _& P( F8 R SetTitleMatchMode RegEx
, Q* e. V# j5 c7 ^, l return# ]& B/ m$ |* _0 t' B5 f
; Stuff to do when Windows Explorer is open$ T* p% G4 N& V4 K5 F
;% W0 |( N" o' B0 @
#IfWinActive ahk_class ExploreWClass|CabinetWClass" F1 j H2 ?& P* t6 R, D
; open ‘cmd’ in the current directory7 B% v7 ~4 e9 }. N; c: f: D
;
9 |5 t+ r3 o* b" V1 a #c::
0 D5 s; P6 L) W OpenCmdInCurrent()9 p+ L: {3 d) ? i {: d! r; T; @. A
return' a B$ q7 U% f# `: F- D
#IfWinActive
2 {7 m; }. n0 E) Z8 d ; Opens the command shell ‘cmd’ in the directory browsed in Explorer. i( p- o) Q8 W7 {, t! X. A
; Note: expecting to be run when the active window is Explorer.
' ~* C# T( |3 T8 `' p' V7 C ;
( ?- {/ V+ n; X6 x' S# Z OpenCmdInCurrent()+ r* q0 s: D; R" h
{! p9 _ q4 l8 h: v" u# X% z
; This is required to get the full path of the file from the address bar [( P& a, W" d1 E8 v( ]/ @
WinGetText, full_path, A. {4 s! [0 I3 i/ G! x2 O/ z. X+ p, u
; Split on newline (`n)
2 i, _0 g' x g$ X7 V StringSplit, word_array, full_path, `n
" P5 K7 x- ~4 |# N6 H; _. R9 v/ q+ S6 d ; Take the first element from the array, O \, N N$ m; ? G
full_path = %word_array1%( e5 \+ L' x* A& h9 ~
; strip to bare address
/ t, n2 }5 b1 n: |' N5 a. D1 ? full_path := RegExReplace(full_path, “地址: “, “”)
- \' F2 q% Y. T' r8 v* V! W ; Just in case – remove all carriage returns (`r)
6 K, `6 a; t' M5 v StringReplace, full_path, full_path, `r, , all4 b. z( |# j& B
IfInString full_path, \3 p" Z' |7 T% }/ _ o
{
4 m) S4 R" `4 b Run, cmd /K cd /D “%full_path%”' g9 p' o1 V6 {" F x4 V
}, |' Y# v/ e/ P9 b" ^, ]1 @ K
else
6 f) b! J# }% L. H$ `+ F {
* s: i7 o) l2 M _8 z3 a Run, cmd /K cd /D “C:\ ”
( Q/ s$ f2 |5 F | }
- c2 {2 M7 N4 w( D# a2 [" d! p }7 P# x( G- ^0 o" y- e: F! j D p3 y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 P- R+ d9 d' D7 u
这段小代码肯能有两个你需要修改的地方0 ` u& Y0 H" R& Q0 l9 c: r8 s
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% d* B0 g9 m# J& y J: I7 m# B7 T9 B
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 P2 U6 j: o9 T |