此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
$ N- r/ q# p, _- Q: h- W( n 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! ]7 a) X# a: d 方式一:5 E' W! R B, ]& G! l5 m- Y9 F
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 B& ]+ h) I9 d 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
0 c3 V9 j1 `! \$ { HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。$ b+ c- `, \0 W, l! D, P8 d
方式二:
, ]* \. {; }6 \! T3 X( \) N, {4 n 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 |( J" E3 |6 D* `( F SetTitleMatchMode RegEx
& }' \# y4 }, n: L: Y return
/ X6 e$ a8 @* E0 w8 \7 H ; Stuff to do when Windows Explorer is open1 A! B/ B: m$ [
;
' C6 ?* _( s: t+ z #IfWinActive ahk_class ExploreWClass|CabinetWClass
& s1 y; ~0 X9 N: t9 I3 f ; open ‘cmd’ in the current directory
% ^# ]$ Y3 u, A" _/ r7 Y ;
N: @& Z, d3 x" n' p k #c::
& ^% v6 d0 ]6 ` OpenCmdInCurrent()
9 a; M' K9 c, J0 a) D/ z8 I) e return
" c8 D( T4 L" J6 J+ n& s #IfWinActive
) O, v. [$ a& ?1 r! H3 \ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* f6 O& w9 }9 X. m ; Note: expecting to be run when the active window is Explorer.+ o+ a' W2 J0 ]+ B; P# P
;; e0 Y3 J! p" M! y2 I' [
OpenCmdInCurrent(), [! j: D7 @# x0 ?# J" H( b
{3 A. \' _! z, M2 t4 p& i
; This is required to get the full path of the file from the address bar
8 i# |& j5 i% R0 e' I2 M WinGetText, full_path, A t2 r# V: o/ B
; Split on newline (`n)' N2 e+ e; l% V( t
StringSplit, word_array, full_path, `n& ?; q- E0 L* A- s4 y" W
; Take the first element from the array z; K; ~% `+ ?$ ~' l% {9 v9 e
full_path = %word_array1%
; G u4 d; ]& Q4 X ; strip to bare address
5 q# U, t0 z s! J! A i* D) o full_path := RegExReplace(full_path, “地址: “, “”)( ~: Z5 ]6 T/ l, @- f( ?* {
; Just in case – remove all carriage returns (`r)% j/ j6 q% _/ N8 b
StringReplace, full_path, full_path, `r, , all
$ E& t7 n* c& N1 ]& w IfInString full_path, \& ]" o4 W) @, ^
{7 Y! }( x. |8 D. O4 J$ H& r
Run, cmd /K cd /D “%full_path%”
9 m) A. M5 \9 K }
" S% X2 F# e3 H( r1 ~ else
9 m4 ^* m/ B$ I7 \+ P {
1 B$ [, ]" p" a9 w3 Z Run, cmd /K cd /D “C:\ ”
. d0 |" s% W0 V2 _ }
7 {! _. \$ _9 l" ?) Z1 t }
$ J3 f" G+ A" B _- V5 t4 G5 n) Y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 R& |# r) e' p$ x0 ^ 这段小代码肯能有两个你需要修改的地方
6 G0 n' j9 |$ ^) O* w p 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* [* b [+ D. T. f9 a
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
' f B! r$ \, {+ V. d |