此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
g9 Q1 Q4 P. [ B h8 _ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 Z$ D8 |+ O H3 j7 L( `0 f' ?- @ 方式一:: P( t/ j8 t, z& X* v N- F
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,; P, A) U. Z9 u8 Q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& A' q. r* H( I
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 E' ~5 t! m% ]9 W- X! g& @ 方式二:, V+ w, {0 U+ z: Y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! r6 e$ H+ L( N) A. \. _! J4 E SetTitleMatchMode RegEx
7 B7 m! q8 w8 u8 k9 l0 Q return9 f8 Q3 S8 b; C4 I
; Stuff to do when Windows Explorer is open. H7 C8 l5 O) R3 ^
;7 p. \& `$ \3 H7 K( ~, A! b4 A
#IfWinActive ahk_class ExploreWClass|CabinetWClass) L% w9 t+ x5 r8 V6 a. i
; open ‘cmd’ in the current directory
/ h- x E5 k0 j F" S+ F0 x ;9 e$ r, |% q+ K
#c::/ n/ m' }3 h% n1 p% W5 n5 q
OpenCmdInCurrent()( `9 g7 P. ], e( ~: ~
return1 Y' u0 i+ t7 i1 A( h" \) ]) b0 U7 M
#IfWinActive
! [# v/ I% d" {6 D! T ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' b) y s$ Y- v4 K9 c$ S. ]" j
; Note: expecting to be run when the active window is Explorer.; S. b* M0 w! q. n
;' G f2 C* R: g' y* C
OpenCmdInCurrent()
9 t. d, s% k" K8 R3 M2 | {' h9 R& f# L% V& a+ I$ X. t" a' {
; This is required to get the full path of the file from the address bar
2 b6 F# H8 j8 {9 F2 p; N- L" w WinGetText, full_path, A/ {$ B w4 O% ?- Y
; Split on newline (`n)1 A3 @4 j* T( R2 {3 U$ v- r9 d
StringSplit, word_array, full_path, `n( p6 }7 j7 Q) M
; Take the first element from the array
' X. T! W X+ P j; g full_path = %word_array1%& X$ F/ R8 G7 b! m% [
; strip to bare address
p5 q! M1 s) S6 a2 a full_path := RegExReplace(full_path, “地址: “, “”)( R! M) ]( O$ u3 k
; Just in case – remove all carriage returns (`r)6 x8 q/ m) H* t B2 D6 m4 Q
StringReplace, full_path, full_path, `r, , all# i' }9 P3 }4 j3 f
IfInString full_path, \
W4 m! T: N, B6 M5 h' k' h( k {1 i5 ?/ ?$ E: Y P) R
Run, cmd /K cd /D “%full_path%”2 G+ p+ E# s2 _( P
}6 X6 I! O' a" x( I- Y
else+ t! ~+ h9 b4 a6 \5 x8 F
{
h* E. u7 s \/ w2 A$ u Run, cmd /K cd /D “C:\ ”
- |/ R$ D# V5 [& t$ G( ` }
5 C, {8 Y* U: L/ z. x6 o. X: s8 Q }8 G7 @. m' S- W# ]* @6 ^
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 c# N8 M% h# a) I8 `) H6 ^2 u 这段小代码肯能有两个你需要修改的地方/ ?7 }( B/ v: Q" E ]2 Q7 S& I
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( P: |5 n- Q0 _* ?
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
@4 Y( V' I0 t* c4 C. d& R0 K |