此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。9 u' q4 q/ f4 M2 [ e2 _
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 F: x' S* s( m5 g) _( N4 N 方式一: P9 {9 S7 F4 t; Q0 z6 P
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. ~' C) ^/ P, L# ~* m# u
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" q; i, N* O" q/ H& |
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ `, A0 ~& g- |( v2 p- }9 E, Y
方式二:& D# t1 J+ g4 {: p8 J6 ] r6 L
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ Q1 `& {$ {: l; y! c: k6 [ SetTitleMatchMode RegEx0 ]0 {8 T7 O) y- [9 R. |5 L. G9 Q
return
! k& D' Z1 Y6 V ; Stuff to do when Windows Explorer is open
5 I7 M, q. O6 {! t4 N, r0 ]9 R6 W ;
" ~! T! c# Q0 Z5 ~ #IfWinActive ahk_class ExploreWClass|CabinetWClass
; o, D+ Q& U! u# o4 c7 F9 q. r ; open ‘cmd’ in the current directory4 W$ `: f& A4 l, w; P
;! s% z9 N( T( }
#c::: s0 D% N3 B. [9 r9 Q
OpenCmdInCurrent()' U* N H1 R* R$ h
return
7 R0 d" W9 Y' d O6 L #IfWinActive
8 I d; C- J% Z' o% B ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# K8 d3 A4 e: m9 U, f
; Note: expecting to be run when the active window is Explorer.2 J2 F9 y: Y/ U
;- @$ [+ T5 s5 A p" J7 z1 B2 G+ m9 O
OpenCmdInCurrent()4 ]7 b! z0 R* s; w/ z5 v
{( e! b9 y/ _5 r# o( r8 o$ v
; This is required to get the full path of the file from the address bar
9 S, h- A' {- u1 ~% [$ n WinGetText, full_path, A) n; L5 [! R9 r( c/ h- Q l2 Y
; Split on newline (`n)4 q7 C$ I% M+ x/ g& @0 ?
StringSplit, word_array, full_path, `n
& e* Z" [# R: G' p! k ; Take the first element from the array' D+ v4 p8 [! T4 a( S3 @2 T
full_path = %word_array1%1 \5 D ^( k" A1 d& }1 }7 D
; strip to bare address
% ?6 ?% D) w$ W% @ x full_path := RegExReplace(full_path, “地址: “, “”)6 D! [0 w/ ?$ X3 E2 @: t
; Just in case – remove all carriage returns (`r)
) L7 z; q: w Y* U1 V StringReplace, full_path, full_path, `r, , all) [, k, ]$ p8 n
IfInString full_path, \( L4 @* U7 ^% D) o# U4 G1 S
{+ t" O$ j3 o& r% k6 L
Run, cmd /K cd /D “%full_path%”: a. ~! D2 u6 k3 W# R' F$ X7 {
}
% Q7 c5 T ~1 M else
! i) u- ~+ X( m! q. i {; F0 Q% O3 z* C- ]7 c
Run, cmd /K cd /D “C:\ ”& @6 t1 i/ J) N7 j0 {
}
' m( F8 K4 b$ b; Y$ Y }1 n* z& C7 J: b! q9 T/ f
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ f* I" M) F3 E: l# y# \. ~/ I$ C
这段小代码肯能有两个你需要修改的地方4 K! V. d( k! }1 i0 d. P+ A
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 D; E9 H& h5 d$ K$ ^5 N8 u) v' J 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 }. d' d a+ r s" ~
|