此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 C- V& F4 |3 ~& R* h. t) Q2 x0 w. E7 l 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
+ [; g* a! T/ N/ ?4 H 方式一:
8 `: I, w, I0 K8 ]& Q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* [4 a' G" l7 s 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ d) j) D0 _. g5 V. U6 F
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( B$ _1 j: [& z) v9 N W5 M
方式二:
9 @7 m% X2 y# E( ?; I 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 h% f. ~* B4 Y f" Z, q7 a& v
SetTitleMatchMode RegEx
! \7 D" P) p- G, f* m: M2 p return" a6 V0 D/ {* o8 e" E7 W$ n
; Stuff to do when Windows Explorer is open
4 [7 k2 z% G6 G% C7 I0 s ;- L6 D- z. @/ `" S+ U7 ^. U; S
#IfWinActive ahk_class ExploreWClass|CabinetWClass I; O2 Y. ?/ K
; open ‘cmd’ in the current directory
1 t9 a2 z& Q: |0 V) x$ U/ C ;
# Z& e* b+ r: J' k #c::
0 c6 a6 M$ J4 Y. w; y( q+ c) m+ I OpenCmdInCurrent()6 v# @) ~7 J* l& \' c2 l( f2 }6 s
return+ ~% D9 p3 T* s; E; S" o6 |
#IfWinActive
* c( G3 ^8 h+ z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; M4 k7 ]0 y }; ~5 q
; Note: expecting to be run when the active window is Explorer.# R! c, Z& i a( ^
;
* }7 i h+ C4 s8 X6 ?1 G [0 s OpenCmdInCurrent()
u+ _3 T2 K' ? |- G& L {
; ?$ C! f# v( \ ; This is required to get the full path of the file from the address bar3 v1 z& z& i$ L2 N. n6 N5 j
WinGetText, full_path, A$ p6 ]6 V/ S% B
; Split on newline (`n)
* H- E- w7 _+ ~0 ]# k5 K StringSplit, word_array, full_path, `n
; Q9 _. ] T2 e, f9 Q; Z0 } ; Take the first element from the array
e3 O# j0 F" |/ D; h3 n full_path = %word_array1%" G* l2 e6 k7 j& o3 W/ b
; strip to bare address) _1 p2 Y N5 d
full_path := RegExReplace(full_path, “地址: “, “”)4 s' v) P" c5 C! }9 k6 G/ H/ e# M
; Just in case – remove all carriage returns (`r)$ G; f& O! K: e* ~- b* A
StringReplace, full_path, full_path, `r, , all
$ I+ d2 @2 D7 y$ l4 O: K IfInString full_path, \; _3 G+ y6 \& F/ B6 E, Q* p
{+ l# q4 V3 B2 C2 y6 Z
Run, cmd /K cd /D “%full_path%”
, G- O U. M- a4 l2 P+ ] }
8 m; R7 C N# s6 r/ i6 D else. }, O7 i! {' B) j3 X! |: q' T v* i6 [
{
) p: z, M4 n/ [. Y9 C Run, cmd /K cd /D “C:\ ”
" p/ N$ T n# j5 a2 ?( @ }
, N G6 j( o9 e) G: {, Q2 ^ }
$ @" z4 v0 H. Z6 P/ A 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. g# i4 o' _, Q! d" w- q( K* E 这段小代码肯能有两个你需要修改的地方
: H! T6 d% K6 o) P 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ z5 N$ l9 P) L! X1 ?0 D, R 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 G$ V( d% s5 J. X# q |