此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) S9 d% n! I# S: l( S! l* J) k
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 t7 l* N4 V! Y1 F0 o$ U 方式一:; `: Q8 L: _+ l1 A/ Q ?
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
; ~6 s3 |& @- T' S+ q$ X& d 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* D0 Q0 s" w( i9 A' ? HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" q6 Z. m% H6 @; D 方式二:
- N& S5 i! s+ r% D# e' p5 o, K5 ^ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" K6 j. i. t& N$ W; U8 k
SetTitleMatchMode RegEx
* m1 ]! \5 U7 d# z9 d return
# b6 w! W. y$ E ; Stuff to do when Windows Explorer is open4 H8 ?, @7 ^$ z2 r/ ]
;# F6 D8 T' l/ T# c
#IfWinActive ahk_class ExploreWClass|CabinetWClass
- r. _ u2 t8 I1 K+ ` l) J ; open ‘cmd’ in the current directory. ~" l9 A* G2 r+ E+ \
;5 g, `6 m6 G1 d* M' U4 B
#c::
( R1 D0 z5 X6 ^ OpenCmdInCurrent()5 z$ _7 `6 ~. b* y
return3 @0 e6 p2 G! {/ F
#IfWinActive9 N+ `# O9 e* }5 O2 l C& ?
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# M" |. b/ S0 R3 x
; Note: expecting to be run when the active window is Explorer.: f8 b- s$ L& T8 a& V3 |. a
;' [9 h' [3 c$ T! ]2 g* H) c4 C
OpenCmdInCurrent()
# f0 a+ N% \8 P! F. G8 ^ {
. h: M3 c+ Q% a! R6 ~4 t+ ]+ C ^ ; This is required to get the full path of the file from the address bar
2 ]: J5 y; R$ M WinGetText, full_path, A
7 Z% ~0 R& o5 D" n& N ; Split on newline (`n)
8 o- p2 C& B- f* c; o' Q) ^1 A StringSplit, word_array, full_path, `n
7 g3 d) K& A, e ; Take the first element from the array
# B6 b, I& v/ l1 u! S' k# z% s full_path = %word_array1%( Y3 W/ j' G9 o2 ~8 `. {) ~
; strip to bare address
5 U9 t0 A: F3 Y* Y! A full_path := RegExReplace(full_path, “地址: “, “”)
0 W3 ]+ \4 ^0 e ; Just in case – remove all carriage returns (`r)/ P3 {* { A, x+ |
StringReplace, full_path, full_path, `r, , all# Q9 P! f3 t8 ?4 ?6 p- }
IfInString full_path, \8 c* L. w: S+ t/ k z
{7 K. l t8 Z" W3 _9 @) Q$ U
Run, cmd /K cd /D “%full_path%”, ?: N t! D; k* `5 {
}
# r1 L! S; O5 P else
- x. T! d: f9 ^# y6 U {8 @' B! l& I# K+ b5 q; Q
Run, cmd /K cd /D “C:\ ”) E3 j% _- D9 G2 _5 V" m
}
4 q& w+ c! g: N7 e9 d0 ?. U }4 y: c! _" ~# U) Y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' `# |% o. n$ F3 k4 ?
这段小代码肯能有两个你需要修改的地方. E* [( ^' h" s$ c
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
4 i% d. m2 ]& |8 `4 A2 H% K5 s 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ R" Z! a. s! `! O6 n; q8 m5 Z
|