此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
. c& @! _$ ?; @ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
: U# E% w$ E, O c7 S* H) W5 o 方式一:% E- [% I9 c/ s$ s7 q
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 O; @5 d; z8 L5 ` 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 d0 p: I' F* \6 N/ C
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) I" E- E8 P: `3 f/ ? E$ Y0 x 方式二:
- f x2 V: w+ x+ w' s0 {' r 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 a1 ~+ H; @, w) e+ }/ P& S
SetTitleMatchMode RegEx
+ R0 s* |: H1 l# E' l return* t* X* U, V Y" \% ~( _) T2 S
; Stuff to do when Windows Explorer is open b, ~8 d# C$ B) v
;
- f5 p A5 D8 A8 e5 [ #IfWinActive ahk_class ExploreWClass|CabinetWClass& e# ]3 U" p6 u6 B M7 w
; open ‘cmd’ in the current directory
9 P! A5 x4 |4 m ;- |+ i1 F/ M/ f2 r$ }2 D0 T
#c::. g, u! g) ?7 I' G7 r8 z
OpenCmdInCurrent()
9 i# Z5 g" Z8 k$ _# J/ G return2 g, R/ W8 c4 m) q) I
#IfWinActive
_6 h D& s$ G3 g& M$ q ; Opens the command shell ‘cmd’ in the directory browsed in Explorer." U9 r1 m1 e2 {, ^7 J3 i' |
; Note: expecting to be run when the active window is Explorer.
& ?0 E- F5 L/ B0 k ;5 O% K1 e3 z' D4 w' j5 g i s
OpenCmdInCurrent()9 A9 A; m. e& U' j
{+ {. A, [" u7 N6 A& B
; This is required to get the full path of the file from the address bar% m8 O# Y: p9 F) }9 S. j7 G' I4 j* {
WinGetText, full_path, A
$ A _) V! {' m) ? ; Split on newline (`n); o3 a2 i6 }8 n: g% W
StringSplit, word_array, full_path, `n
5 b. u* r/ v' R4 Z+ `& L ; Take the first element from the array G% ^& t* t4 f1 {
full_path = %word_array1%( r6 G0 I" K# R6 s4 m
; strip to bare address" q0 f! ]3 D) g) S" {
full_path := RegExReplace(full_path, “地址: “, “”)& {$ \8 C4 C* w7 q
; Just in case – remove all carriage returns (`r)( c4 J& @7 M9 A5 F# i/ z
StringReplace, full_path, full_path, `r, , all4 Z# O, z* {4 K" }: ?9 V5 ]
IfInString full_path, \
! J& f6 s/ Z/ J# \+ k n {
. o! b3 q4 C7 w w9 b5 l0 I/ g Run, cmd /K cd /D “%full_path%”
, r; v) q+ M/ }8 O- s, K }
1 U" z, `$ M! ~" X/ o; m else
" V2 }/ o8 V( O; B; s+ J {
( L* D/ O7 j: a( _ Run, cmd /K cd /D “C:\ ”
* `' F" m5 w/ v8 G3 d# M+ E$ Y+ T- | }
0 r& g6 l. m# w. {0 `+ M }- J# E x$ M, s8 ]
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# M( T, W2 h! s 这段小代码肯能有两个你需要修改的地方
- ?. d& ]) X' I 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& H: [, g0 T5 e+ h9 i w# y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ l/ n, q" `( W$ N! k. K+ ]0 @, n |