此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
* K. L! k' ]- H5 o( Y2 h 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% i' b0 b. n" ]
方式一:: P! f8 k# F/ K% d+ W; l; _3 v& j/ N
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- s! a7 N1 M$ ]4 E 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- U3 ]: s" \. \1 T+ O) i/ L$ @# z3 a
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* Z0 l" x0 N J: j; H
方式二:9 z/ N. D5 f" L* u, g6 n% o N
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ [ N3 g( ^3 \- E* p8 W- i
SetTitleMatchMode RegEx
5 P1 P" ^3 ^7 E- O9 I! L% o return
! U+ t0 Q" o1 T8 k ; Stuff to do when Windows Explorer is open3 s9 D- g) T3 @8 i3 \% }- w# ?# T- v) v
;
: F' G9 y& S+ J, ^: f6 M #IfWinActive ahk_class ExploreWClass|CabinetWClass
6 E% X. g- _3 q ; open ‘cmd’ in the current directory: ?6 o( J8 c! {8 {
;
7 q, m' }& b# O! I4 |7 f" a+ ^) f #c::- G/ D; q0 c( T0 x( c
OpenCmdInCurrent()# O6 H; P ^ j9 I- b
return; a; K5 V* h g6 h$ r, v4 [
#IfWinActive7 U% t ^. O5 f n1 E! P
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% v b2 N# R$ N& F4 d5 m ; Note: expecting to be run when the active window is Explorer.2 [: I0 y2 A9 q8 C9 I, H
;. d; d6 _% a5 T! Y) {
OpenCmdInCurrent()8 s: D" E- s6 |! {$ D
{4 Y& G+ ~/ k: n, ?
; This is required to get the full path of the file from the address bar: m1 C1 C# Y f! |: A
WinGetText, full_path, A9 _1 z2 d" Z6 u' c+ N# D' j1 r: t# ~
; Split on newline (`n)
: f1 ?: g% u4 u/ ]) C5 K StringSplit, word_array, full_path, `n
$ z# L# q% f+ s& B0 I2 q7 m ; Take the first element from the array* {9 U. U& W' B
full_path = %word_array1%
& h7 f9 F6 t$ h5 z8 v ; strip to bare address# j5 ]0 I8 G ]3 N! s5 N4 z' W$ ]2 R( u
full_path := RegExReplace(full_path, “地址: “, “”)2 Z6 ]1 |1 R: Q& v
; Just in case – remove all carriage returns (`r)
- j4 Q! {0 Q0 t9 u2 x0 B, E StringReplace, full_path, full_path, `r, , all$ c# |' G) ]0 ?- Z
IfInString full_path, \& z( T& Y/ \- j! X1 S5 K
{3 h$ b) p+ Z' U2 [ J# i- i
Run, cmd /K cd /D “%full_path%”$ f M+ q7 e# Q6 h7 ` u
}
# }( l/ V% @! W/ Z _3 G3 m3 w else+ ^- Q: c/ s: b. J+ P5 ]$ h
{
% Q- C, n/ ?- L4 e# @ Run, cmd /K cd /D “C:\ ”
- x. `5 U& c+ K/ n& H' t2 f& A, J }8 B2 g. I% R) _3 `- X& B5 o
}
6 i, h( E" V7 L i 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" U. f2 \! L, [ 这段小代码肯能有两个你需要修改的地方3 ?; _& B( Z( k2 h
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# V9 n. \) g5 j2 p6 \( y 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “5 P8 e; A S s# K+ B
|