此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& R# I \* Q; k! U/ b 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" A+ m$ j% i# X R8 @$ M. L) }7 K+ L 方式一:8 E1 v/ {& w3 q7 B; h
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" _ `: z: V; r, K: ~; g 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* J1 u4 A: ~2 T# O1 {( e HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 p) {' C2 V% W, M- ^1 x4 p
方式二:% S) ~5 |! o- p6 N' l* h
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 {6 y% @# y# C, m
SetTitleMatchMode RegEx
4 A) ?+ d6 p7 ~ return; W4 y' M- L7 `, a0 C( t0 a5 V
; Stuff to do when Windows Explorer is open4 c* y2 k( |! Z6 ^/ U8 Q! ~, s
;8 ~" l6 z- y' F ^: Q4 J
#IfWinActive ahk_class ExploreWClass|CabinetWClass, E% ^/ T. @( H$ }( ]& M
; open ‘cmd’ in the current directory1 [6 x% y; Y0 G" p
;
8 p8 l5 Y- q& y0 u" p t, a #c::) p7 Z( @# O) R H
OpenCmdInCurrent()
, [) f$ q) ?' C8 `# ^; i! c return
5 @( } F0 k! n2 t& i1 x( N- e #IfWinActive
* H$ u; |+ s" d S ; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ m8 c6 L! C) K, a: z
; Note: expecting to be run when the active window is Explorer.
, d1 o, R/ }2 _5 j; P ;
G M2 Y: z1 o' J! D) `) b0 R OpenCmdInCurrent()2 M3 l( [# g8 U/ o
{
3 M" Q2 x, E# l ; This is required to get the full path of the file from the address bar7 K0 D0 `5 n) D- G' p' ?5 P
WinGetText, full_path, A
! H5 @9 U- U% B& i ; Split on newline (`n): A& w2 [% a$ @: i( T
StringSplit, word_array, full_path, `n# _$ u, o& Z% ?! d5 k
; Take the first element from the array
! W1 \7 ~# j7 N6 g full_path = %word_array1%
/ `& r6 m% u( R, `: O" B) o) G ; strip to bare address. A3 y b# a$ [6 H, i
full_path := RegExReplace(full_path, “地址: “, “”)
8 w' R: t* s1 D/ _# ~. m, I ; Just in case – remove all carriage returns (`r)
, E( O( \6 g2 d StringReplace, full_path, full_path, `r, , all/ W. i8 E# R; a& d' T0 Z6 [9 F
IfInString full_path, \% J8 @2 Z8 u: k/ W* [
{
4 D' f1 P0 O0 h Q( I3 t0 w. w Run, cmd /K cd /D “%full_path%”
& I5 P* O7 c0 F8 x9 n1 B }* B# o P: ]" A, K
else
4 y4 b$ K: _# A {4 D$ w) ~6 ~" H% w {! m( Z0 q& }* n! ?9 L! f0 K
Run, cmd /K cd /D “C:\ ”
1 z3 c F, ?7 v2 \* ] }- y4 i3 i7 p8 D8 T
}/ v, v6 P' F# n4 H* A
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 i$ [& K0 v8 S+ s0 g4 u 这段小代码肯能有两个你需要修改的地方4 N2 P4 L/ z+ V( m
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% `- q, D( K" I0 K$ U 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) _ T4 w( O: {1 ~. t2 G+ a
|