此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 C8 H% @, M7 i3 K0 t& z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
. l D; Q+ ^$ X" p+ f* O 方式一:
7 @' o. H) f8 ?! L/ ] 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 P6 I, E0 p3 j: d: `4 {
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" k; j4 f4 R& ~7 y* n6 v" r9 d/ B
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) d% L$ s- `2 q/ n
方式二:3 n) s# j% j; ^' g& I5 b
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
B- _! O5 m6 g: z SetTitleMatchMode RegEx
8 n; p$ g9 w0 b% E return
- y6 R; z+ O% q ; Stuff to do when Windows Explorer is open
" t, j- I: }; p* I ;% v3 ]* s/ |' i6 v
#IfWinActive ahk_class ExploreWClass|CabinetWClass
( g8 g2 o& A) P8 _4 ? ; open ‘cmd’ in the current directory
( q# m4 ]' k8 i' b' X) t ;
" a; u. b2 P3 o2 H #c::" ?/ _1 I- l: `+ H# }
OpenCmdInCurrent()
5 Z. b. W8 c$ H, S ` return
3 B4 M' ]' P' d# K #IfWinActive1 O5 y! ^3 j" ]- H0 i* ]! l$ f
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% r3 A/ w2 V7 F: f- x
; Note: expecting to be run when the active window is Explorer. ] ]/ I& l+ D+ c
;; \' r# @! w" J, B
OpenCmdInCurrent(): k( @( N" W s* d) L& L" o
{
$ \! P1 m! K+ z5 G4 `/ h0 t$ o ; This is required to get the full path of the file from the address bar" ]7 u! f# T& |
WinGetText, full_path, A- A, P: K' O1 L1 ?* r! |
; Split on newline (`n)% O: t! [' a6 y0 Y7 C/ w
StringSplit, word_array, full_path, `n
. t$ D3 D; F0 G+ h ; Take the first element from the array
) y) {$ V2 f4 [, p) c full_path = %word_array1%& s& P) w( L( N- q+ @% A9 U" j4 b
; strip to bare address
' [+ t# X. ?0 ?- Z( _( W2 W* L+ j full_path := RegExReplace(full_path, “地址: “, “”)8 R3 f0 P( f! P- g& `' N. T2 o
; Just in case – remove all carriage returns (`r)" L% `, d/ N N, m4 }
StringReplace, full_path, full_path, `r, , all
# Z( }( u7 r1 k1 q4 C& n IfInString full_path, \: P- {# t# O$ X# t/ y" `: D
{/ @& P* G4 e/ X" v$ X/ e" g) y
Run, cmd /K cd /D “%full_path%”
/ ?% |: U3 t" U7 c% ?0 f3 w }, N% N% I% Z7 f& G# G' v
else! o1 r/ |0 d- z4 j
{6 I5 p: h4 ^6 x
Run, cmd /K cd /D “C:\ ”
1 g7 F0 U; {. m }
& _# j( [4 `9 X' k" V$ K" R }8 Q. W1 v$ i" p1 M( q$ E$ Y" F
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
L1 q: J$ [3 W6 |# F 这段小代码肯能有两个你需要修改的地方! j9 [- Y2 x5 q5 |
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 S& F# e9 {& n2 I7 i 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ ~- s( I' o3 s7 o7 h' P. j& y
|