此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 K# i7 L/ G9 I4 \ k I0 ~ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: |' \/ K: B0 J" c; w3 c( g# a& t 方式一:
- ~' M$ w' m V$ K) ` 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 b/ a% p2 Z5 i4 V# y% T 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( c$ c) P5 k) ^ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; E) U8 {/ l0 @# ~2 d 方式二:' }9 q3 f& u! N5 N; U p
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! `. O/ Z. D9 T3 W) [
SetTitleMatchMode RegEx
+ \7 I5 |- A- H" b9 E( W: |/ a. _ | return- ^1 H- e8 Q* o" ?! e: d
; Stuff to do when Windows Explorer is open
# h# y/ O; Y/ H A9 M9 t ;) j8 e: F7 S4 P) ^
#IfWinActive ahk_class ExploreWClass|CabinetWClass
9 K. {# F" ]- y$ ?8 x$ H2 e ; open ‘cmd’ in the current directory- L0 |! f6 n6 j, C
;7 ~* e& F: v% D9 I; W7 y# g
#c::
3 Z2 h) ]. c& g! k OpenCmdInCurrent()
; V, b5 K/ U5 X8 A+ M& t return
, J q* P) \3 ` d #IfWinActive
# @1 ~# M( q- n! o1 W( j2 [- ? ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
) E" e) s1 p, m ; Note: expecting to be run when the active window is Explorer.
" K9 ~; M4 ] w0 H' q" u- m ;& m3 I, u/ k I! i- B9 p4 j1 \% m8 A( z, S
OpenCmdInCurrent()# a3 Y4 r0 E t% i" k4 H/ B
{
/ }9 V6 }' C7 Q: m N ; This is required to get the full path of the file from the address bar/ Y+ b3 z" l- Y; r
WinGetText, full_path, A
+ w. `2 `5 M6 [! y8 Y2 w ; Split on newline (`n)# J0 J; Q# ^0 Q
StringSplit, word_array, full_path, `n2 X7 a9 C8 Z. |3 _; O
; Take the first element from the array
: d- j6 Y3 e0 F full_path = %word_array1% `: }# Z4 C2 U! \& S! ?
; strip to bare address
2 v: v" M2 @1 K full_path := RegExReplace(full_path, “地址: “, “”)' ~# Q* ]9 w; Q% l' M( }: v* g& E. n
; Just in case – remove all carriage returns (`r)* `8 f" N9 m" b, f- V) H. L( D
StringReplace, full_path, full_path, `r, , all% I* F3 S$ k2 T7 D7 g; `# l: v
IfInString full_path, \# W' T) ~& i# L# K
{4 n/ x/ u8 i4 J' {, M2 o
Run, cmd /K cd /D “%full_path%”
# U4 D; E6 M( G- y8 i% `5 M }" q3 Q P1 ?+ V3 Z+ n
else
, D9 i# U; ~8 K. o; u6 d {
0 |6 W0 A! {6 [+ Y* V( g$ z Run, cmd /K cd /D “C:\ ”
& P v* W- \- E. j% F5 L% J) ] }
9 I& i; H4 u D# @- y }( g9 U5 E) c7 M& x4 Y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- c- t+ {; ~+ ~1 P% n
这段小代码肯能有两个你需要修改的地方
5 v& w' s6 O, D* F3 \ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 k: _. @1 E' c 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “* c* G& v$ w% o; O
|