此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 D* Q/ g1 x" \, \2 }6 { 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
7 G* D" g3 ~" {1 D 方式一: \8 R4 [+ j. V! Y/ ~* b
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% w3 r+ X$ s3 E# i 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 s* w- M+ y0 p5 a. g+ n% {1 ~
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 ?$ m6 k- d3 Z9 {. B 方式二:
/ A6 d o4 S) s 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 f* v7 |- e5 J( H8 ^ SetTitleMatchMode RegEx
/ G ^5 E/ a0 d J# C% T return, j1 z* ~' a$ i: y1 |
; Stuff to do when Windows Explorer is open
2 O7 J4 v6 u) i h4 I1 F% L6 p ;. Y+ Z- f l4 A! G7 b. f
#IfWinActive ahk_class ExploreWClass|CabinetWClass
. W! n( O8 g+ n2 C, p# T% H# h ; open ‘cmd’ in the current directory
' m/ Z1 h: c7 `& N9 y, W# s% X! y1 F ;' O5 u( T. z. a" `) D
#c::
1 o& T8 H6 V7 J4 f. z; p; l# c OpenCmdInCurrent()/ l* i/ Y) _9 ~! I7 N: z3 A( p9 e
return6 R- q U2 I7 d
#IfWinActive
" a! _9 P% F& W ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, K6 F/ W- |+ A3 W n ; Note: expecting to be run when the active window is Explorer.
- S f# E+ y: j; ?7 y ;+ h+ M# z+ v' m% j
OpenCmdInCurrent()
# Z) m; j- H) K3 t {' X8 Y) ]& _; E
; This is required to get the full path of the file from the address bar
5 B( t' E: B$ s" A' Z* _ WinGetText, full_path, A/ K6 G2 `' y% ?, ]5 y
; Split on newline (`n)2 l% d. T4 W& ?5 T
StringSplit, word_array, full_path, `n6 i& V" X2 z' Z! j3 e
; Take the first element from the array8 T" b/ M# I7 n7 D( d6 ~, z
full_path = %word_array1%
, n, P/ M5 R/ D# q" ^) s0 z ; strip to bare address
8 Y+ O: ~! P$ E X8 e full_path := RegExReplace(full_path, “地址: “, “”)
@" m% I/ r O8 W5 d ; Just in case – remove all carriage returns (`r)9 A7 |5 B# w3 ]5 V4 b
StringReplace, full_path, full_path, `r, , all
& t) g$ k- S( q! i" y" R IfInString full_path, \4 l2 T( T, T$ |% m$ E+ R
{
9 g. S' A: d V Run, cmd /K cd /D “%full_path%”- g. C& E$ i# Z: B/ s/ y2 E
}2 J: I. K* | ?. `. o* h
else
2 [3 M' C9 a$ k" K( } {
1 c6 q$ S3 o6 A! o! ^9 v2 h Run, cmd /K cd /D “C:\ ”+ t* L' c& ~& \& f4 E
}
* {; P8 F" R' f }
5 q4 x$ x, l- L0 E X% |0 W; A- z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- Z2 B/ J6 F& t4 z) K6 ^2 [
这段小代码肯能有两个你需要修改的地方" J2 a9 a: @: m4 J8 Y+ p; c9 v9 G
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( N1 l, v3 r+ V! q; k# d& | 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) y) F6 O `% H- a) [5 E |