此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- R! Z1 r* Y! F& W* u; h 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 b1 ]# l; E0 W0 t 方式一:
/ b& N1 E2 V, r- ]) s) {: t 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' s5 ] b: Q4 F7 {
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, y. @, c8 b. p. Z% A) h3 q7 ^ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 s. H- g. D5 w$ j 方式二:5 D6 [6 I# _! N5 s$ c8 p
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; z1 Y9 T6 K9 Z1 M7 Q SetTitleMatchMode RegEx
: R1 X- k4 f) J# B return2 b, P. ?0 }4 |7 t9 o1 k! D: L
; Stuff to do when Windows Explorer is open' M; M) r; f/ d
;
, o7 z P7 V" c9 M e; t- m #IfWinActive ahk_class ExploreWClass|CabinetWClass
0 }$ L( E; {, h ; open ‘cmd’ in the current directory
/ y/ X; O/ k l: N U9 V% \6 t2 l ;/ v' I/ i! P: f/ j: b( C& Z0 r% z
#c::: L7 a9 A0 g' z6 T: p2 A: I( a
OpenCmdInCurrent()% Q7 N! @# n, W8 R z, v
return
% p8 u0 o7 b% d #IfWinActive
W! A3 u0 q1 v8 E ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, _. i+ p+ g! [ ; Note: expecting to be run when the active window is Explorer.! |* S% h0 X+ V7 C: j( n O- ]
;
: B' Y0 ^. L9 B7 ` OpenCmdInCurrent()
8 L( f( Z" l, |! a {
5 l5 x$ ?" z' [+ L/ o3 ` ; This is required to get the full path of the file from the address bar
. u8 d0 z5 ]# P. F* g4 d WinGetText, full_path, A3 O# ~6 F5 |' J- F) [
; Split on newline (`n)
* w8 D- I$ O) q8 ^7 U5 [( J0 ` StringSplit, word_array, full_path, `n
* t+ } Z( h8 ?0 P' W ; Take the first element from the array
$ W }1 B A% h( F7 I, A. Z' K full_path = %word_array1%
4 {" y' f2 t% w, {$ ~' l) X+ v* p1 \" n ; strip to bare address# T* s% K( B& O8 R2 o; o
full_path := RegExReplace(full_path, “地址: “, “”)+ Q/ M! r$ Z* x
; Just in case – remove all carriage returns (`r)
4 I4 j, S @0 e- L4 L; N StringReplace, full_path, full_path, `r, , all
' Q+ z" a) N2 m- }5 I; C3 N IfInString full_path, \
# H( I1 f# @% y {
7 }% |5 G# u( X3 O4 K Run, cmd /K cd /D “%full_path%”% b& M8 O" L: d) d
}
- v6 S8 j Z- b L& i, q7 x. { else
* D/ K2 \3 q* ~& {6 w {/ Q5 n& i8 J2 W9 v3 h7 @
Run, cmd /K cd /D “C:\ ”
7 U1 i7 n" C- ~5 I2 V }7 y2 U5 B6 w: V3 r) N
}/ l' n. T3 y- W: b( @6 M! {. n+ R
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" D" i# n8 X5 j5 e0 m
这段小代码肯能有两个你需要修改的地方% u3 C- [/ v# O+ q
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# b. v5 h" c$ W* ?8 Y5 f! R
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 i: {! _; V% s- p+ `; v- E) ?
|