此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, q3 u# a0 n0 }: q& }
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 c0 o5 _ S0 `8 [; W
方式一:7 R- o$ O# }$ c: U; C3 k
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ P* p. L( x8 [! \+ X5 G @
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! f. p2 b" I, D. o
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: ~% {7 Z6 ?7 i' h9 V8 B 方式二:
- U7 P6 Y/ }5 A/ { 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( S2 u' I7 p, I8 ]- K
SetTitleMatchMode RegEx
; w. W0 Z# s. r9 t5 E j; B$ D return9 ?/ {4 E/ Q" }( L2 R
; Stuff to do when Windows Explorer is open* Y: O2 T' {6 ^0 o" A0 o
;
9 f4 e8 r9 ~& _" j; g8 e% S+ L7 V% M; p #IfWinActive ahk_class ExploreWClass|CabinetWClass
9 |* J" t1 M( N ; open ‘cmd’ in the current directory
! }7 Y; ^1 n! L" m' C6 O$ | ;
. r3 g) u6 Z+ Z5 [ a #c::7 }9 ^; g# T y( }2 C3 n9 @ S
OpenCmdInCurrent()3 ^$ o8 ]# y9 `% o8 i K
return7 l( ?7 w9 o3 x1 P
#IfWinActive S. s! B3 r$ T; j- i
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- i9 S% a4 V9 R! z* s% ?' x( K7 J J ; Note: expecting to be run when the active window is Explorer.+ z' y) V" m& F Z8 f- v' A* _
;
+ A b0 Z9 @% O7 u$ J m. U OpenCmdInCurrent()3 z0 N8 @1 U* a+ Y" D
{4 J' k8 Y/ T3 I9 W: C
; This is required to get the full path of the file from the address bar
% m$ T3 z& B* |, \# E x WinGetText, full_path, A1 U$ m1 t: @" u" N1 z* e* b
; Split on newline (`n)% T0 [# t7 ]( k5 E2 G5 `
StringSplit, word_array, full_path, `n7 E X! P( F+ [" `9 f9 X: J7 x$ s/ U
; Take the first element from the array# p- E2 s3 \# a$ L* l. u: U# y
full_path = %word_array1%" q& `( z7 I) o% H t
; strip to bare address
( m) |0 P, j! T/ O& n full_path := RegExReplace(full_path, “地址: “, “”)9 ?7 Q7 H& E* t! W
; Just in case – remove all carriage returns (`r)$ e) `$ l: W- x$ e( E4 I+ B
StringReplace, full_path, full_path, `r, , all. a# F% b! m* S0 B/ W
IfInString full_path, \
0 N$ j c$ U2 w2 ~+ s/ P0 ~ {, i* f" A' v0 |8 z% ]2 m
Run, cmd /K cd /D “%full_path%”
& @+ i$ i- Y- n7 G3 c% X/ b }
$ O. L% @# N1 E* f. v& Z( p else
8 S u/ {7 q( m z6 l* W1 G {! T# l( m$ w* Y% {: u" ~5 q
Run, cmd /K cd /D “C:\ ”
7 l! x- ~/ ]+ X6 f }
1 A% r7 k5 f* ?1 Z }! `9 h- |' R* y/ `
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 h$ [; r* Q2 h7 |# f. |5 O8 Y6 B4 H 这段小代码肯能有两个你需要修改的地方
+ W4 `7 Z0 c4 T4 v6 h5 A 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 O- y4 c) T1 l8 o. {/ n
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 @, S1 d2 K* }( Q6 O3 ] |