此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 K, K/ _. O" _0 y5 U+ f0 M
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 z+ X/ x v+ V. Y 方式一:
. M: b# J! Z/ }8 t! V 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 E7 H/ ?* `9 p 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: z* j0 ?. d4 {4 B0 S8 Y# m HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* ~# H% D4 K+ {1 g
方式二:
; s# j+ K* Y: `( V( h 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* g! x. N2 b5 S
SetTitleMatchMode RegEx
$ e' j3 h; z% m0 ^2 { return
" d8 |, ]5 v- U ; Stuff to do when Windows Explorer is open) U) l# N0 R- V E1 M# m/ [
;# y$ P0 s7 d' }& e4 k
#IfWinActive ahk_class ExploreWClass|CabinetWClass5 _2 S2 f. J. H1 a8 U6 `
; open ‘cmd’ in the current directory
8 P& R/ ?. a' s! ] ;' ^: N$ }: c: O: A2 U z( i$ v
#c::
9 Y" W% Z8 i! ^2 `) \7 j OpenCmdInCurrent()5 t# ? z% q- i O' s8 m+ S3 C, T
return
4 x- Q; ~0 K! Y( c) X #IfWinActive$ u" p+ m; h0 A6 w7 ^: [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; \1 S/ \2 S7 Q9 _4 X ; Note: expecting to be run when the active window is Explorer.
. a2 i3 k- f. ^, [0 U S" r ;
) o" Q8 a Y) [+ e$ }9 i OpenCmdInCurrent()
# ^2 r6 z' h- C9 ^8 e) V0 c {
/ i, M$ u4 X. z3 O1 t" n+ D" b ; This is required to get the full path of the file from the address bar
C" H( X" x$ b. ^ WinGetText, full_path, A( w3 h2 M: K1 o* S1 B5 h: d
; Split on newline (`n)
, e7 H. f! a8 {/ d8 Z: g- r StringSplit, word_array, full_path, `n
- F$ b; y- K9 F' G* T' o ; Take the first element from the array
0 u3 U. w1 W" | full_path = %word_array1%
; i6 z/ k- b" j3 y8 z: t+ ~ ; strip to bare address% Y, h2 Y! x& M' Z! o4 `/ G
full_path := RegExReplace(full_path, “地址: “, “”)
/ [0 ~' M2 }1 Y' i ; Just in case – remove all carriage returns (`r)
- V4 V @4 r! y0 e3 @ StringReplace, full_path, full_path, `r, , all
$ u1 Q$ ~; e# E6 }8 ?" z IfInString full_path, \8 j0 z1 V v8 y' w
{
* g' z I/ G2 o Run, cmd /K cd /D “%full_path%”+ G# q; @0 b' v; J: S
}$ h6 a: w d; x$ y+ c' c. _- g* y1 f
else3 d) E7 u5 ^0 b' Q/ W! g3 l
{- X- u- x, ~ K$ b+ r
Run, cmd /K cd /D “C:\ ”# H8 Q( [+ H4 v$ n! P g8 |! i5 W
}* S. W7 L7 e+ h- [2 |
}% k, V- P# Y! x; o: x8 p, L: ]
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! u$ S6 r: R9 m1 ] |6 {9 r
这段小代码肯能有两个你需要修改的地方
! E" p1 Q% F- y3 @0 F5 k* {8 c 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 E5 p9 y5 P7 a, i1 H9 N2 A 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 Y9 H4 W# ]* t% y& q
|