此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( `, k7 \- Y: U
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 c. H3 @) E1 \
方式一:3 O/ q* |/ a* J* ` V% d
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! \$ u3 [% P! F" X
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* E) J: q$ i+ p HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 d( i- `- O: J; f8 G
方式二:
$ G* N& O @$ _, p8 m 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
D5 M; j; S7 ] SetTitleMatchMode RegEx& q) p& h/ n( w4 q, v3 {) W5 @
return
, o, j% W3 m6 F' ?. K; u- T ; Stuff to do when Windows Explorer is open
& M( r+ ~4 K- @# {* e: p+ O- T0 Y1 W ;6 o9 r) k4 W. S- k3 F
#IfWinActive ahk_class ExploreWClass|CabinetWClass1 W3 C8 e/ C5 b8 j
; open ‘cmd’ in the current directory" Y) a7 H: ^# E2 V. y; a
;
- \2 S& a. ?3 b' d: I #c::
/ U% U) o% q3 {) j; W OpenCmdInCurrent()8 B" G8 h! Q. c# S% R8 Y k& ~
return
* ~( k8 E, u6 f/ T, I. v c) _' u #IfWinActive
& A J* e) V4 H$ A. I% w ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 @2 [9 G1 U6 |5 y. b* q2 n
; Note: expecting to be run when the active window is Explorer.: w. q7 K+ D$ u
;
8 J' {2 Z8 p! x) f; p5 T OpenCmdInCurrent()
5 q0 d$ M$ [' h# v0 M; B {( p( O0 K* m) g" t# w' J6 B
; This is required to get the full path of the file from the address bar
0 X, c: e' ~+ X7 l; x# o W WinGetText, full_path, A* Y# I# i* z& S, i- h
; Split on newline (`n)
! Z, j& {7 a& }' |" M6 w5 \ StringSplit, word_array, full_path, `n- p7 h# o, S3 O$ E
; Take the first element from the array) v' e8 I; X# ^- M: B" [, S& x' V
full_path = %word_array1%
3 t* ]! x! o7 R7 t: H ; strip to bare address
1 L, Y3 F% o4 H full_path := RegExReplace(full_path, “地址: “, “”)
$ @, _* g$ s% V: F3 V* [3 v ; Just in case – remove all carriage returns (`r)6 a3 s$ E0 r# h" R) C* R- f! y. u
StringReplace, full_path, full_path, `r, , all; J) Q6 N2 b% B3 g
IfInString full_path, \
2 [+ d" P$ M/ O6 {$ A) f1 V/ L { J2 F2 q; S0 O5 u& H$ r
Run, cmd /K cd /D “%full_path%”* [5 ]) U* s( ], M T8 S
}
+ b0 U" ^; L/ Q* K) X else
! d* D3 E7 r- y; h- E: [2 [. x, A6 [ {! `6 k' M0 R+ r" G: [
Run, cmd /K cd /D “C:\ ”
# h) t* S0 o. q$ e }
, F- L# x: ?9 X } c# x( L# y3 e
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" a+ D7 l/ z9 a; W5 ^+ K 这段小代码肯能有两个你需要修改的地方
* B/ n2 Y* F1 ~+ J% r" K 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ e: Y5 j$ V" A' w3 `! s9 h
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, d; P$ ~/ A! Y# |0 ] |