此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- f9 J- E5 `8 F. c9 X* k 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。; [0 T) M# O) q; `% ]/ r+ b) t
方式一:0 G% @2 l% T9 o. N q! h; T$ ^
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( x8 B$ e- `* d7 N. o
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 n& c. |9 D \% ^ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& s! ?5 o9 I& P, ? 方式二:8 }% c2 b* m4 S
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ S# S' Z4 B5 [; i SetTitleMatchMode RegEx
6 `. D7 g) q/ G0 d) q$ F return
; q% O0 r6 S9 }8 _" m( { ; Stuff to do when Windows Explorer is open
/ ]) x3 ~$ q( N0 f ;* ?* Z+ ~7 U: J2 g
#IfWinActive ahk_class ExploreWClass|CabinetWClass/ d3 p. E' w& y+ L, C: p- K/ t
; open ‘cmd’ in the current directory
4 X: P8 l$ s. \* U ;
9 F9 R% p) s1 F9 q' L& } #c::! Y/ a/ Z$ U7 s9 Z
OpenCmdInCurrent()( T) x3 D) }& o4 T( e" c: F( K! {
return
4 C9 W0 |4 ?3 o, K1 Q9 T4 t8 q #IfWinActive
& Q! m5 C" f. x3 F: Z8 x ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
" }; u8 P; y5 Q4 t4 q. K ; Note: expecting to be run when the active window is Explorer.9 B$ k1 ?5 |& w' M
;
/ K2 m! t* W& p OpenCmdInCurrent()- o0 Y1 | `" q% d/ H7 o
{
' l" ^- U3 S6 g: `% y6 o" p ; This is required to get the full path of the file from the address bar
% X9 r' Q5 N! H. ^$ s+ ^ WinGetText, full_path, A
; ^# m2 K N( c) X( g, I' E ; Split on newline (`n)( x' _; N# t! O& o3 m: {
StringSplit, word_array, full_path, `n; c5 ]1 G$ R' B/ G- y7 S. U" E r
; Take the first element from the array
& r8 ^' a6 F+ s* w9 J full_path = %word_array1%
+ X3 w- T7 @, i" R) t2 M ; strip to bare address
( [0 K& [6 H; Z/ {" o full_path := RegExReplace(full_path, “地址: “, “”)
; S0 q/ o2 g- O ; Just in case – remove all carriage returns (`r)
}" B$ V8 i0 U! ]1 ?( d6 o StringReplace, full_path, full_path, `r, , all
! j. L# {1 h$ N, F$ u$ }2 P IfInString full_path, \
( Z+ M9 u3 {: r( F# l {
( y4 X8 D+ s8 g Run, cmd /K cd /D “%full_path%”
/ C6 t4 v- R5 c- ^ }( R T+ f" s4 U
else
+ J T8 d9 n9 t: M! O' g2 e {
! m0 ~* N( y9 i2 T) _& U$ f1 y- f. W Run, cmd /K cd /D “C:\ ”7 V, G( ^: n" u
}# w" \1 I, c- v9 x" u8 H/ O
}" t4 t6 n! ]9 d/ `# q0 N( k
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 f) E) h5 o q. `! @4 e 这段小代码肯能有两个你需要修改的地方
$ H7 _- ]0 s' ^4 f2 } 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
; B4 ?& s9 [! \5 O' H# A! M 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ u. {; r" Y- k4 B& ^
|