此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。7 M3 f. ?$ P7 I/ B1 f4 f. B
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 c! S* V# C" n 方式一:+ C2 Y! i$ u+ _6 K
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 y% l" z# {5 A% M( W 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, ~3 c! O" o \% T2 d
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 _6 t+ R$ s+ ~# G
方式二:
4 J+ e* a7 S* r8 ?7 }6 ? N 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) t7 i$ X/ m; J, e& _/ t. X; s
SetTitleMatchMode RegEx" L- o: ]8 d) `& _
return
, h; U( B( I4 N) m8 T$ s- ] ; Stuff to do when Windows Explorer is open
0 o- U5 }- M- L$ x! Q ;! V- ~( C, U' q9 E) T
#IfWinActive ahk_class ExploreWClass|CabinetWClass$ i. ]. \5 {. F
; open ‘cmd’ in the current directory' Y) p6 v& q- W! D! b/ [% U
;% b# e. t$ D7 l$ k( t0 P
#c::
: A/ n& q/ {: S OpenCmdInCurrent()
8 Y! T& I R+ a. K5 ?6 x return% F6 M G* x' M6 n
#IfWinActive
, |4 o' r9 W7 R6 Y" d p ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; S- ]+ A3 Z9 ^+ z" q3 R
; Note: expecting to be run when the active window is Explorer.
5 a G& ]6 g6 {3 m ;7 F u! _# i9 I
OpenCmdInCurrent()8 k5 U N* B! x u
{( d! h+ N" p9 P C/ t0 [$ f* \2 L. d
; This is required to get the full path of the file from the address bar, Z7 R! n4 w: X Y" |) |) D4 N
WinGetText, full_path, A
7 F: V X, Y# f4 E3 V' f ; Split on newline (`n)
; U* J7 u1 z: S StringSplit, word_array, full_path, `n U6 T% k4 p/ E; ^' K
; Take the first element from the array
, S3 b7 Q6 W+ y+ m3 X9 |0 S full_path = %word_array1%/ f# p! c& z$ @+ o* D6 o
; strip to bare address3 P3 R& W$ L9 C1 [
full_path := RegExReplace(full_path, “地址: “, “”)
* p+ F9 [2 u* S ; Just in case – remove all carriage returns (`r)
4 Q5 b) X! O7 [6 a# o StringReplace, full_path, full_path, `r, , all5 {( t8 E2 q: M
IfInString full_path, \
" H' {6 K# f" ~1 w6 B {
; N9 d5 Y1 Y; O" l& w5 { Run, cmd /K cd /D “%full_path%”
[9 i6 c2 M$ u8 j2 r7 S% { }. M$ }( N1 F) _1 {2 V! C
else
/ g8 L# ~- N. a {" w( G- [7 j- R2 [
Run, cmd /K cd /D “C:\ ”( W9 Q3 O% u: ]8 g N5 p
}0 s: a# l/ L3 l# w$ A8 X6 o
}
; Q8 a8 k# S+ H# h: E 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. {# t6 d r' D* I. F3 A5 g 这段小代码肯能有两个你需要修改的地方
( X! a4 @$ ^0 _4 p6 g; H 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! O; s/ T4 E: `% z. E; i8 v 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& Y% `1 F( }$ x' a3 k
|