此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
4 S! }& T' J6 e3 Q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, n7 q* M6 S+ _. e& S7 V7 x
方式一:3 A/ Y7 T- s( _0 E
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# C% N" V! w O0 v; A 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 [9 X; E; s- j7 T# F HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ R+ O- f- n; }
方式二:
- e9 i4 H: p9 w* m 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" N% \! S9 ?! T0 M% D& ^
SetTitleMatchMode RegEx
+ z9 f: ]9 y B" l3 d' ? return( A0 n3 O( d0 q
; Stuff to do when Windows Explorer is open
5 y5 E2 [' R6 n ;8 J$ ^0 O% I2 P5 d) i
#IfWinActive ahk_class ExploreWClass|CabinetWClass% Z& w% a+ h1 t' x, p! Q3 u
; open ‘cmd’ in the current directory
. R" i8 _' [7 P$ v. {! m8 w5 z ;3 E) `1 f3 G- C% y6 L3 p8 K
#c::
/ T& k/ H2 I# |3 w( S: J5 e; ` OpenCmdInCurrent()
9 c1 m! q& j( x! V return. g2 x# q" v0 e6 D, H( [
#IfWinActive
" {7 r/ @' d/ L ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 j" }5 r$ a; i# Q: X3 | ; Note: expecting to be run when the active window is Explorer.3 D8 P9 G4 V o s) N
;# J$ E7 l7 {1 v/ z7 ]5 t6 k
OpenCmdInCurrent()' d4 ?/ ?5 t& q* M
{
- {- f. M/ R) A8 s; v! } E ; This is required to get the full path of the file from the address bar
- _: s# _, S+ I e3 x" R, z WinGetText, full_path, A# ~$ J3 \9 D# W" c
; Split on newline (`n)
/ t% B4 T2 p6 \" G+ N* I StringSplit, word_array, full_path, `n- `/ ^ e `4 M1 L8 D0 B6 |
; Take the first element from the array
- R# i# u& ~9 c( Y full_path = %word_array1%& r) M, z$ n* p, G9 [7 P
; strip to bare address$ K+ K+ Y" J: W
full_path := RegExReplace(full_path, “地址: “, “”)+ Y+ U( h3 Z2 V2 U6 X
; Just in case – remove all carriage returns (`r)
9 m+ [ T, ^; x K& ^3 i9 @1 D7 b& m StringReplace, full_path, full_path, `r, , all
$ e6 ^# z7 p# O8 b3 S6 c# j" | IfInString full_path, \
/ d' L. b" S: z' L. Q) D5 l {- F1 }& n' N* r' B+ T; T; e6 D6 x
Run, cmd /K cd /D “%full_path%”
* v/ u5 D$ r% o" S9 D8 \ G }
, K7 B" z& q* x- {* f else
E* E6 y$ w' o {% {: P( e3 v) C0 v0 i# y: U! V
Run, cmd /K cd /D “C:\ ”
/ B( S+ A8 h$ p }+ K5 O7 e4 I4 x0 K
}
) @0 l2 G; z/ A: ~7 g 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
; e: \& y# W8 M: J2 g+ Z 这段小代码肯能有两个你需要修改的地方6 O% @0 d2 K# w+ O
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( |7 S- y4 Y+ z% s% a2 l
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* _ k# X7 P+ ]6 O% N |