此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# c9 R) H) G# {, Q2 B9 F 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, [+ A% j$ G1 s
方式一:
/ P6 U! _- Z8 c M9 a6 z+ ^ G) f, V 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* ^ b0 ^# t" L7 b3 N" t 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) h; c/ W* R* t- ^& b3 \
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 f: H- }( [0 B- N) s; `4 @$ H
方式二:
7 a+ s6 Q" c+ n" | 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% A: Y$ U8 n8 a% }; l9 V, ^9 N5 H SetTitleMatchMode RegEx
/ z$ a2 W4 m4 E, v return
, I+ e$ A g& e: x+ B, W ; Stuff to do when Windows Explorer is open
0 |: t9 ~' u2 j1 {# X ;! p# N9 i* K3 Q4 C' R
#IfWinActive ahk_class ExploreWClass|CabinetWClass2 E( d3 K$ F' G4 l) i
; open ‘cmd’ in the current directory' a/ s& g; w. K) q( y
;1 z" q0 Q$ A1 u2 o5 k
#c:: Z' Q2 @' p0 Z" b: l% q
OpenCmdInCurrent()& t. e% o( m6 i1 G* |
return+ Q. _7 |3 D5 m8 s4 I1 L
#IfWinActive
8 }& ~7 d) Z5 e# Y- o ]9 b4 R ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 {5 ? c" F* V* }# s: w2 q5 d- [
; Note: expecting to be run when the active window is Explorer.- O3 D; q: ~5 a2 R, b: R
;+ ]8 Q- U5 O9 b+ ]* _; ^$ ?! o
OpenCmdInCurrent()
, n, R0 n. ?) o {/ @1 |$ m4 n6 u) p& l
; This is required to get the full path of the file from the address bar" L2 S: T8 N" z$ `& K% M, R; B1 n
WinGetText, full_path, A$ \ s& P. U. g$ L+ O9 C
; Split on newline (`n). r5 S7 V; ?" d( ^, C! A" Y
StringSplit, word_array, full_path, `n" G; P% r" {0 \, J5 K$ E' V O
; Take the first element from the array9 A( {7 t/ t m _. e6 f; K
full_path = %word_array1%
+ u0 a& ^/ u' R3 x/ C( Y ; strip to bare address
% c; Q8 q: m# }' g8 d full_path := RegExReplace(full_path, “地址: “, “”)
* k" p" U/ w+ I4 S2 r3 k ; Just in case – remove all carriage returns (`r)
/ t7 L% O" M7 F9 f8 j1 x: x! D StringReplace, full_path, full_path, `r, , all2 E6 `' \, ]! ?; J9 W! y: n
IfInString full_path, \- `( J4 j: ~) Q$ J) C A
{
6 P* Q4 J+ y' W {+ U Run, cmd /K cd /D “%full_path%”' z9 j3 p- {& g
}# o9 G) j3 I; J0 L/ o( m" A4 D* n
else
. \- @9 g. c- E9 Z* [' [ {' T8 m7 q0 B8 J9 b3 J- \
Run, cmd /K cd /D “C:\ ”
4 _4 D% I/ S1 W3 K }# D& j( i" d, }6 Z) T
}
! p# |: U; Q& F" u 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
9 O" X2 w1 R6 _3 Z 这段小代码肯能有两个你需要修改的地方
- \, `9 p3 G& J4 D) |5 B" }) i 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 ~2 G0 ? C) V" G5 x" {# j" c 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 P6 Y1 k/ n \1 m# N |