此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( Z, A2 b8 n5 ? 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 J9 b% \4 O8 f, r
方式一:) C/ a. W3 K/ W z
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 j# c3 ]0 [: K 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 y, R* U: K8 }2 L% K HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! Y& y/ `8 o5 S 方式二:
% ]2 ?3 R: |" ~- R4 P 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, ^: g4 ~( f, e
SetTitleMatchMode RegEx$ U4 G$ @4 u; F+ s# S. b
return- t! a: ~$ ?$ v- \- Y6 ?7 ?9 ~, W
; Stuff to do when Windows Explorer is open# z9 t, G; m1 @+ `4 M# F% a
;
# Q+ T( j& \, C) I' A$ `8 N/ o5 D5 t #IfWinActive ahk_class ExploreWClass|CabinetWClass
9 l/ f) h" T# w" g/ i1 D ; open ‘cmd’ in the current directory
$ w8 n. ^* I' r% d- m ;
; X0 v; B; Y( P4 T6 E #c::$ o% q" T9 @# @- \$ m# Z! C% w
OpenCmdInCurrent()! u. _ q5 n' {! e# a1 I [
return
2 ?, A& n( k$ o5 l: ~ #IfWinActive* A7 z& c) K- E0 e. s* E
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 w# F/ f3 g/ ~1 [ ]/ t% G% Q* { ; Note: expecting to be run when the active window is Explorer.
& e7 H% \4 l. Y; Y# g4 @4 K' v/ v ;
# v5 q" z0 P. l1 r' l3 k% W OpenCmdInCurrent()' E$ |2 J# i- q
{
. o' W9 X' Q, f" c ; This is required to get the full path of the file from the address bar, `7 G2 X* g! i( g
WinGetText, full_path, A
6 I+ L, y, ~+ }( G ; Split on newline (`n)
' Z8 H/ q% b8 s6 a StringSplit, word_array, full_path, `n
9 r6 {! |. H0 S+ T# o9 o% L ; Take the first element from the array
; R5 A( ^6 r- s* W) b! F& R% n: u full_path = %word_array1%
$ a! a& W" F9 y. L2 {; { x' ]" l3 } ; strip to bare address6 B, u$ g5 v Q( d
full_path := RegExReplace(full_path, “地址: “, “”)$ l! H7 k: l- Y2 E
; Just in case – remove all carriage returns (`r)& ^/ n! |. x) A1 x3 i( n1 b) F. v
StringReplace, full_path, full_path, `r, , all$ ]* s5 G2 `. c; D9 S( t
IfInString full_path, \
6 Q( s/ z# T+ d- q8 k& M9 F% H: w {
2 G1 I0 w- n4 T2 K Run, cmd /K cd /D “%full_path%”
, W0 [5 s' }% T2 a5 q, T }
+ i! m" i! O% D' Y else
9 ]$ g0 z8 }; i {; Z: n) u. }$ ~( u* Q/ c+ X
Run, cmd /K cd /D “C:\ ”
1 H1 J" U& u- M, F9 I# _ }: Y2 ]4 a. c' d& u& S- H7 \/ o+ i( J
}
- ]1 \6 O9 e4 \4 y- z9 g 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( M; z- _. x# b7 H" x 这段小代码肯能有两个你需要修改的地方
7 E2 r+ Z/ e w 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 D& V4 K. M) W1 z6 ]
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: |3 s9 |% \, C O$ h$ t0 t
|