此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 e! Z* y* d% n: y' w. V% C 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 p: O2 G7 ?- r2 H) d. h% N# w, T! ^ 方式一:- U& m8 D6 b4 X% w* R5 D
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 `8 O W9 `( A% U
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 E3 n. M; v" l/ z7 t2 W) a' @
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) T( O* m) p% t 方式二:
8 G4 _' b# Y6 R6 ?0 r/ M 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( w6 n1 k( w6 A% v) n& G( J
SetTitleMatchMode RegEx
! R* v% D# g: ]+ n; f" ] R0 c return
5 W) m# j. \0 |/ F9 P2 E$ y ; Stuff to do when Windows Explorer is open [4 f! N/ c5 `. ~3 X- Z
;
3 p9 [. s9 o$ K- |+ i( m" o# K #IfWinActive ahk_class ExploreWClass|CabinetWClass
( `" L' S) I5 p9 |6 @& ` h0 x+ @ ; open ‘cmd’ in the current directory
# s( I" u2 |8 Y ;
9 b0 n# {9 B }, N$ d! \ #c::# Q8 Z% [9 S! d( E4 c
OpenCmdInCurrent(): [7 h% T8 x2 j- ?/ m
return
' x% C2 k/ j' g. U' i0 @ #IfWinActive& d6 E- M% ^: u, z) s& G, ?5 K8 W
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% Q; r; e$ h' k2 |6 h* S3 z u ; Note: expecting to be run when the active window is Explorer.4 r* P0 y( O5 o; Q) ^) @0 J
;, P' _ h: \9 u- D) h6 r; Z
OpenCmdInCurrent() k. O9 l) H$ ?
{
$ N: k& w% Q" _ ; This is required to get the full path of the file from the address bar
; W# B5 o3 i3 S; [$ @* Q! S& L WinGetText, full_path, A: R! ^3 l3 E% ~+ P
; Split on newline (`n)! P' V# [1 U& S+ |
StringSplit, word_array, full_path, `n
D$ M3 N9 U2 c: L6 u M ; Take the first element from the array8 Q8 c R) K3 t8 d% g9 \8 L
full_path = %word_array1%
% u/ C9 Y5 ]1 e$ a! T) Z0 \ ; strip to bare address x2 W% C: u R6 d$ n9 o
full_path := RegExReplace(full_path, “地址: “, “”)2 E* F% f* }$ U( e" }3 K
; Just in case – remove all carriage returns (`r)
- W3 I% i8 V, ^ StringReplace, full_path, full_path, `r, , all: S3 G# T* y2 \; g7 A: N
IfInString full_path, \
& O8 L9 E: z3 @ {
* b5 p% b" t+ L9 W Run, cmd /K cd /D “%full_path%”4 n! X* b$ \2 l- ~ h
}- J P5 i5 G) k6 l8 Z/ b( A
else9 h; `3 A) P- W& Q3 u% C) N% k
{
3 s+ @! ?. b1 x9 n' v0 C; r. g Run, cmd /K cd /D “C:\ ”
* n/ @& a1 G) M. W }% V/ R ?) |# I* {1 d4 {2 t
}2 ^5 }& ]$ c* i' ]4 w6 |6 |
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- t d) {- y; C3 Y7 `' h 这段小代码肯能有两个你需要修改的地方% w; w# k' S2 k* O/ X
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ z- M% f O. s
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “) p. [' I: x6 H' k) N `# u
|