此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
! E% W" p, a8 ?9 l3 B5 M3 }. u 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 y$ F8 n5 \3 x2 r7 L
方式一:
: p1 z) o/ {1 F 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 B$ T4 y" ], Q: W& M4 z
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 F! @. z' }- m HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ b2 P5 N+ d! [% x
方式二:
& C! z9 h6 Y( W5 W# S- r 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( q5 F1 A% E% H$ h3 n SetTitleMatchMode RegEx8 N; T Y9 }+ j# M# [4 I
return
! [/ m! h0 V: u$ @$ G- ` ; Stuff to do when Windows Explorer is open2 P _6 J6 v% K# L# h
;6 s* X$ a& M) f0 w' u& m
#IfWinActive ahk_class ExploreWClass|CabinetWClass
7 C. H0 x1 }) z* s# z: U. s ; open ‘cmd’ in the current directory
, d. U1 A1 M/ q, G ;- Y6 n7 w; K1 }) F# @2 j; c
#c::
0 H/ d. U6 g$ j8 J$ T+ T OpenCmdInCurrent()" ]7 p i! p6 o$ o- z- d, _, t
return
& ~5 W* G. J P7 |& c! }) j/ f! B #IfWinActive7 [8 Y! N, W- Z/ h9 t+ G
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.3 M9 b9 ^. `2 Y
; Note: expecting to be run when the active window is Explorer.
( U, k, u( \# g; f8 R" e" l* W ;
3 `0 p& G* r+ i" M3 F OpenCmdInCurrent()
0 s. R7 R8 V. r' c" U1 o8 ^ {
. B3 L( ]& E9 O& ^4 h- @ H. U ; This is required to get the full path of the file from the address bar
1 P& Y* F8 K/ i9 v! w' P WinGetText, full_path, A
( U, i# \( K$ l* [2 Q ; Split on newline (`n)
9 `3 w8 n% d# l( |$ q StringSplit, word_array, full_path, `n
$ B, B9 f6 M$ Y+ r* } ; Take the first element from the array
0 A: r) H" p$ B2 T6 r6 I full_path = %word_array1%
8 a* V( C' Y# D! V- n ; strip to bare address
' A0 m0 ]* _3 s, N z! J( M1 T/ v full_path := RegExReplace(full_path, “地址: “, “”)+ I/ W# i* F% S9 h
; Just in case – remove all carriage returns (`r)9 f' l W- d, i
StringReplace, full_path, full_path, `r, , all
* L3 Y: f/ t0 f- I* z IfInString full_path, \
1 F& H4 E2 i4 K! a {
$ r3 R% U3 N5 ? Run, cmd /K cd /D “%full_path%”
5 O4 g. `, K" d }4 U; S: X( J7 X0 N' k
else* G8 D( c& F+ L$ j, `# Y
{
, l! `0 i& X7 T& S3 a- Y/ d Run, cmd /K cd /D “C:\ ”
# c& A" m. e% u }
9 f9 r& {4 @! I! B1 [! ^ }/ o3 H/ K8 a$ R, b' w; L' g! k
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
5 f0 I) T: @! _/ p- j 这段小代码肯能有两个你需要修改的地方
: Q* g2 o8 K1 W/ v 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 K; s5 M- O1 m( y; O* l" b
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 @/ |' f! B, ?2 L- h1 v7 I |