此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% \8 H+ M0 Y8 g: g! C% K3 k0 O0 b 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* b6 l) z- v* u& j* g4 F 方式一:: i! o/ M- u/ @
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. {( l+ B% }4 k% s! h, B, l* d
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. U4 x9 F* q/ p) ~5 E0 F HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ B. J2 U" B# f4 z# T: o
方式二:3 E2 D% a* O' g" U3 L* X
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# r K( S, E/ H SetTitleMatchMode RegEx) O4 B4 \# G1 @3 R
return
5 c$ w8 F5 _/ ^2 d ; Stuff to do when Windows Explorer is open: l( v2 s+ u" y5 j+ Y; v
;
+ m4 ?0 K+ c$ _6 ^: {5 K- S* i$ E% q #IfWinActive ahk_class ExploreWClass|CabinetWClass
3 y1 G+ P7 S3 m3 Z ; open ‘cmd’ in the current directory
# _3 ]7 P1 i4 G2 c3 d5 x: c ;. ^' j$ M2 [; f) r% j
#c::* _. u) `. V8 a1 x- ]
OpenCmdInCurrent()" M. h$ Z* P: V( b0 G
return
8 L+ j- [( V3 M6 R4 t1 | #IfWinActive
6 E" `" G+ C7 N) U& { ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' s9 o6 {0 ?2 @" x5 [
; Note: expecting to be run when the active window is Explorer.
. A+ ~( H( G3 n% C! Z ;
! q5 b1 F0 W- A4 Y9 d OpenCmdInCurrent(): W, C' b$ Z" }5 x) ^2 L
{; B3 e) Y- x, z$ P$ \( h
; This is required to get the full path of the file from the address bar
( `- p0 Y' x) j1 O/ L* s& O WinGetText, full_path, A" ~+ l1 a4 X: f6 P$ z, }
; Split on newline (`n)
" B' @5 H9 {# \9 |$ u StringSplit, word_array, full_path, `n
: q+ X' ]6 T7 A# B* ?. `& N ; Take the first element from the array
- D$ ]; h T5 ]1 A2 v2 N# v S9 j full_path = %word_array1%
" }' @( e4 ]; ` ; strip to bare address. S0 K- F+ o. x2 l
full_path := RegExReplace(full_path, “地址: “, “”)
9 G$ r6 W. t, |; Q. t ; Just in case – remove all carriage returns (`r)
4 l6 h5 z# [5 b/ F StringReplace, full_path, full_path, `r, , all' W/ s3 k1 p" Z2 s% K) d& z
IfInString full_path, \
4 V4 R* L, e2 ^# b3 r( J) \ {
5 S4 C5 o+ C, m; l( h2 W Run, cmd /K cd /D “%full_path%”
2 o5 }$ I- V5 @/ A }
* R @" e: C8 g# Y# ^ else6 ~! r+ Z& b. R6 X3 M0 x
{
3 Y- I/ `2 d% L7 ]$ ` Run, cmd /K cd /D “C:\ ”; J. w2 }0 j& Z9 D/ }! |! V
}& L- f; }: H5 A; a+ e' [
}3 J3 O2 R3 K/ l$ r" c
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! P- Z8 s6 b- Z# a
这段小代码肯能有两个你需要修改的地方6 n2 Y0 I( ]+ n+ e
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
T/ W2 t- ^" f! D. O 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
0 O: \( v$ N7 n) R M% s0 i |