此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# t& b B6 a7 N2 C 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 b! @3 h9 B3 h# D- n! ~* h' {3 B 方式一:
& x. |1 C# ^& I5 T- t9 U0 v& y( } 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 L0 r, N9 P1 }8 p1 m
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# N0 r: G* @1 c
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* q3 ] k% G1 F: r 方式二:
8 y3 L% E8 _- n& A" q2 Z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. V: z- v$ L+ D% ` SetTitleMatchMode RegEx
' ~, T" f) t+ J# w2 e& ^+ T/ l return9 K. D( k9 |, U% U
; Stuff to do when Windows Explorer is open/ A' N: H, j4 m! n8 A
;3 e+ p- X4 Z6 V, W h* r
#IfWinActive ahk_class ExploreWClass|CabinetWClass+ ^$ Y/ N. b6 b( U) A4 R6 r
; open ‘cmd’ in the current directory S% |2 v: H: ?( Y1 k4 u3 p( _
;; Z1 \% M. R# X+ t
#c::1 O: l5 s" T4 w" a. r
OpenCmdInCurrent()4 D t: D/ O- s# I2 V: X' n
return1 \( \0 J' Q+ G5 Z$ ^
#IfWinActive
: W3 k+ j9 L& K- l ~ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& h0 ]& k8 e0 w2 k" u ; Note: expecting to be run when the active window is Explorer. M5 \: W6 V3 g) [
;1 p- x Z# H$ _4 Z7 q
OpenCmdInCurrent()
1 \/ \4 i( \# l3 A {
+ L2 a% i( x: x: S8 [: F3 ` ; This is required to get the full path of the file from the address bar
. f$ r, _$ Q9 @& e1 m WinGetText, full_path, A
3 G/ Z8 p. V( W ; Split on newline (`n)* B0 G8 T# @" t. ~& A
StringSplit, word_array, full_path, `n: p: {; d' |- V3 t' A; T+ _) l
; Take the first element from the array3 e4 o3 a$ d5 |% T" Z
full_path = %word_array1%3 U4 t6 p, `3 c' w2 X' T
; strip to bare address
" u3 r( a( j5 Z4 `& x" d& G" H full_path := RegExReplace(full_path, “地址: “, “”)' y' _3 k6 Q4 V* `; [
; Just in case – remove all carriage returns (`r)/ g# ^7 g! b: F( }# G6 g6 a* X* n
StringReplace, full_path, full_path, `r, , all
& d% P) @6 a4 m& ^ IfInString full_path, \
" c' p! ^5 n9 u6 b( m {5 k E- E0 {" W- y
Run, cmd /K cd /D “%full_path%”
8 j. ?5 s5 V4 v- S. D/ ~* _6 ^ }" y0 M0 n4 u; H3 z7 s9 O
else( F- U* K# C |6 z9 U
{8 v) H5 O* P7 _: F
Run, cmd /K cd /D “C:\ ”
, q: f( N4 N; I8 Y } f$ ], R. A6 y5 k; e* m2 i8 A$ J- h
}' Z8 r$ A) f( c4 F0 x. u; j* y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" {# I# z8 k0 D; a) S
这段小代码肯能有两个你需要修改的地方( p0 i+ i; M o. s. e+ X6 A9 x9 z x
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 l+ @0 A. ~/ L) z! R2 u 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 @( e. B9 n2 c, _! Y
|