此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 F9 F3 _ s( G5 ]9 p7 r9 F! Q n! w 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。7 E, d( h* X& M) [
方式一:
- c* x/ m7 A3 N K; j% z+ u 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ e4 S. p, e& u. {# d$ [* m% T3 v. E
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& g' t3 B6 r2 L/ A, i# J% M
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 y) c n5 O+ O' M6 s9 ~8 v8 \ 方式二:
: P4 P# Y+ `& D! U 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
b! U* f4 z* ?4 B6 c" C5 g! P SetTitleMatchMode RegEx
& T, _: z! j, B4 R return: g4 p% P0 n0 z2 F F
; Stuff to do when Windows Explorer is open
) W, ?+ s. |7 z+ p ;1 p5 `' ?; l0 ^, @# E! [
#IfWinActive ahk_class ExploreWClass|CabinetWClass$ V8 i8 ^6 }& p; `
; open ‘cmd’ in the current directory
j6 F' p' v0 U7 ` ;
+ r4 d' C- w9 N* f #c::1 @6 e3 I1 t! o$ u/ o, P
OpenCmdInCurrent()
0 u& n( r& g1 Y$ v( j return
, n! A6 l+ [8 |9 I! z- S0 | #IfWinActive4 O: N9 g7 M5 g+ |. }
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) @% F4 t9 k) h. m1 c# c4 {3 Y* N! R
; Note: expecting to be run when the active window is Explorer.
+ u7 t( j) [1 _# K$ X) o/ s ;, G% u" {% K) @" T
OpenCmdInCurrent()
! r/ O1 Y! x u0 l" X {
6 Y6 ^6 o. u4 ~ P4 I ; This is required to get the full path of the file from the address bar
, A! m! X! G* Y WinGetText, full_path, A5 q0 s7 y: N$ [0 {- t5 L+ o
; Split on newline (`n)1 \! r1 o u( P* w; H5 x U
StringSplit, word_array, full_path, `n
2 V5 Q, C: {8 W8 H# l$ { ; Take the first element from the array3 r, I& x+ H/ o! @( t% D- e m
full_path = %word_array1%; e1 x' n$ O* E, T* @$ p5 B1 g
; strip to bare address
6 x; e- Y7 Q+ o. {- k' M) s, l full_path := RegExReplace(full_path, “地址: “, “”)
( z0 e6 q# R3 j, l6 b7 B ; Just in case – remove all carriage returns (`r)
7 p i3 Z7 B' A @ StringReplace, full_path, full_path, `r, , all
- G' W, O+ b2 D) B0 D IfInString full_path, \3 X: a( X/ I4 ~% e; h% g- D$ z
{! n- n# B5 a' V$ ?/ m
Run, cmd /K cd /D “%full_path%”
! g) t) r( w. }9 E }
5 T3 @" |$ V- p% q1 D$ J& ] r' w else5 N2 U0 R) s- g1 n- x S3 r
{! h# x e1 I) o" i8 ]- Y
Run, cmd /K cd /D “C:\ ”
w, y9 L! d$ C# O }
8 \. [" W4 v5 j3 O }8 r& Y E V3 |& z/ |2 }- p
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 L" p7 {) ^1 n# b- d. s* u 这段小代码肯能有两个你需要修改的地方, d/ ?- I( \1 \7 d& L
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; O6 m4 W; B( p8 h2 Z9 a/ a: U A
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “7 h. ?8 m6 [. Y) m) e+ Q8 [# X
|