此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 o* t. J: \9 {1 n3 R2 d; V: p! ^ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! a0 v! z) R' j 方式一:
1 ?& j8 j/ {4 H: }' q# ~7 R 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,; ]! K5 X8 K" ?
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% }8 \( Q) x- p( y3 j1 G3 M* A& N HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* A* O- l8 z' N 方式二:
8 u% N( Z& p, }, o 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* @% y% T: u/ b! H0 f SetTitleMatchMode RegEx
3 l: {0 p* G5 B+ V2 z8 I" F return" \% \ n) D7 |% Q* p* _) _
; Stuff to do when Windows Explorer is open" m5 {/ ~; B* e E$ v
;3 D( g& v% h' p
#IfWinActive ahk_class ExploreWClass|CabinetWClass! Y7 U6 ^8 P% t# S! S$ L6 i
; open ‘cmd’ in the current directory
0 ]' l3 ?$ W, f& p- ^ ;
- i9 ]+ {. j. H2 u4 h #c::9 |9 V* U; z) y* v7 A
OpenCmdInCurrent()
; _: `# A9 V S7 z: [/ \5 p: A return; y: Q' k2 { N/ E5 W* ?$ f5 w
#IfWinActive
' T7 t1 z" b/ B4 r [6 j+ Z7 l ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
/ D: O0 f& P3 ~ ; Note: expecting to be run when the active window is Explorer.$ @/ F0 r$ c6 x5 ?7 d
;
- Q: l5 W, p m+ h% c OpenCmdInCurrent()4 G/ @. ~# x5 y
{
5 k2 S5 |' ]7 \ ; This is required to get the full path of the file from the address bar0 z. W6 o) t( d, [
WinGetText, full_path, A4 I7 E+ y( G5 \) w1 ?
; Split on newline (`n)
{) c. |: U: t$ e& f9 f StringSplit, word_array, full_path, `n
, i5 z, i/ D( P+ P ; Take the first element from the array# b( U1 |, \9 T
full_path = %word_array1%9 U6 c" U5 {8 P/ N% G
; strip to bare address
1 e/ _+ q2 h3 Y, L7 c! \ full_path := RegExReplace(full_path, “地址: “, “”)- ^+ T Q( ^0 U ^+ e( k
; Just in case – remove all carriage returns (`r)
$ W; v* M5 F- w6 m. T2 k StringReplace, full_path, full_path, `r, , all' u O% L! s0 ^& F
IfInString full_path, \, m" l* n# n& ^- D& N
{
* b( I2 |6 `* Z& _: Y! ` Run, cmd /K cd /D “%full_path%”
* t7 J5 S8 X1 B1 J% ~; B: s }
" B: m7 C0 r o else
; _# X1 l7 n- ?; w$ J {8 t2 h% c$ y( E( q( u. u% o
Run, cmd /K cd /D “C:\ ”
: l. g4 Q3 F* [ h: f* S, p- m }
& w7 ^' F9 p; {; N( h }) i/ j, D0 k& k4 x6 _$ b3 ^
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ ]& b; X3 K5 k# C- n8 T8 ^
这段小代码肯能有两个你需要修改的地方
{* R' L* Y$ |% [5 \ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键. u; |; |9 \" D+ [# X k0 w: D7 u
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ t- k7 y% p( A$ M2 H
|