此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! A; ] q0 ]7 K. {
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 m# K3 L0 @3 N! R( D+ c
方式一:- }8 U% I/ W' Z& g$ e. [
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, @8 e) o& i( U: G- l- `( c. M& M
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* N7 R% ^. i( Z4 H7 W
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 t% p# I; ?) R; ^, k 方式二:
' C+ h1 L! k( E" d 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 k9 T7 @- `% {
SetTitleMatchMode RegEx! G! Z" K, E+ ~( s" T( @
return
) F# R$ c& [. J ; Stuff to do when Windows Explorer is open: _6 c6 D% l* [$ y
;1 ?0 A$ `8 E9 \. \" A+ b
#IfWinActive ahk_class ExploreWClass|CabinetWClass
/ V% o( S( M2 ~) R4 i8 Z' D; n7 i ; open ‘cmd’ in the current directory3 w% G8 R6 ]# O; h
;" Z/ Q& }: v6 s. X* [2 E, @ K9 }6 i
#c::( l$ r+ l2 M* o6 x V z
OpenCmdInCurrent()" [" [6 u2 p9 n
return) S# N! h, N1 ~# t
#IfWinActive
% u0 G9 u' ~$ S. t ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* \/ \0 T: x! \. ?3 a+ M ; Note: expecting to be run when the active window is Explorer.
' w* [, q9 s4 Y& x ;
) f$ C6 g2 t2 m/ F- G3 R/ s OpenCmdInCurrent()5 q9 Y, \! m$ S$ \/ Q
{
5 a" {5 T1 L5 M. S8 x* h: O$ \ ; This is required to get the full path of the file from the address bar
. f" [0 Q8 m) O* Z( ^5 R, } WinGetText, full_path, A
. L m9 h9 c: d) m ; Split on newline (`n)
4 D4 W' e/ g3 W! F$ l StringSplit, word_array, full_path, `n
8 L2 h, K5 Y' n5 P2 ?/ o$ c6 [ ; Take the first element from the array) A8 h: v+ ~ n& Z0 ?2 @6 O
full_path = %word_array1%
, Z9 I4 W. d1 r7 s ; strip to bare address
6 ^. k/ w m- `; I full_path := RegExReplace(full_path, “地址: “, “”)
( P% F$ U0 T& i) ~- z ; Just in case – remove all carriage returns (`r)
2 l7 E/ C. t8 T, u. Q StringReplace, full_path, full_path, `r, , all1 G% M' V8 S; P) C; F. c2 b
IfInString full_path, \4 `( x# y9 m6 d1 I0 b' N$ H& M
{
( V9 `' u. q$ E6 Y Run, cmd /K cd /D “%full_path%”
! q ?# t. x, Y9 ?. n }
7 i1 B. i# S0 g9 H0 a else$ u5 l9 |+ ?. Z/ Q3 O
{
. i h3 X' L& u, ~# i Run, cmd /K cd /D “C:\ ”
N0 R6 O, y" ?1 r# D8 k& h0 H }$ e% v0 g+ H- Z. j* m
}
8 d, a; L5 G+ C2 ~0 y9 u6 a 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: Z9 ]# X% _* v; u/ S0 z 这段小代码肯能有两个你需要修改的地方
6 H7 w9 t# z/ U, j# n) T 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
P$ q) E1 E7 m& T6 U2 d' \/ y 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" o8 F% o( F# a5 H: B! J) s+ Q/ k
|