此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
7 ~5 Z0 v/ e7 X, a8 s 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
) L6 j {/ J' o& m# b1 J4 i 方式一:
2 u- S; G5 {1 G6 t( ]; k 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: Q u& D# z; O4 W% {
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 M3 r" ]1 u" o
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) x6 D* l+ m6 J# e$ ]! V 方式二:
/ R% C) N- T; j% {3 P% S- [ E2 j 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" m. }' c8 a. n3 j7 F2 m
SetTitleMatchMode RegEx4 e6 o K, f! J9 Z( n. I/ `
return
+ Y, ^3 X7 z f% v1 k ; Stuff to do when Windows Explorer is open
: [9 P, o3 J* x$ i" {% |1 j! ~ ;4 @' O$ c) Z+ W6 n
#IfWinActive ahk_class ExploreWClass|CabinetWClass
% [; u( o) T7 Z2 [ ; open ‘cmd’ in the current directory; _1 Z* L, a3 j* ~( f1 u
;) ~3 B k: S* ]' H/ z+ @& Y% S
#c::
8 q/ q) j. @4 |2 I T0 l. p% X OpenCmdInCurrent(); K" ^( w0 d- v( z+ y0 l. |
return
( o# q7 z$ q" ?# A, l/ S8 j #IfWinActive
8 o1 Z% v6 w9 E- ~- T- I- a ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) a. j: W8 p5 g* M8 h. U
; Note: expecting to be run when the active window is Explorer./ r% _# K$ X/ [& e! O
;
* i/ ^, k+ V7 C' e/ K. |/ j OpenCmdInCurrent()5 K3 K& e% `, P0 w- m: O A* m* {1 T6 z
{
4 l ?* l) n2 Y" j ; This is required to get the full path of the file from the address bar
' \5 }1 S/ \) ~0 i2 X1 y6 T WinGetText, full_path, A
' J8 ^. B7 X" N- a; I ; Split on newline (`n)
& t9 W9 e) @3 F- B9 b$ J StringSplit, word_array, full_path, `n g+ p% \# y% P4 _
; Take the first element from the array
. ?) _: v& Y( n full_path = %word_array1%8 I3 S1 U* D/ E& ^- {4 W- m
; strip to bare address5 U* @; B9 g+ k4 V$ K
full_path := RegExReplace(full_path, “地址: “, “”)
. H8 p5 @( _9 L6 @9 o4 z ; Just in case – remove all carriage returns (`r)
! ]- E; L3 R% t) k; b5 P$ Y StringReplace, full_path, full_path, `r, , all
2 A% ^% t7 c% h9 G* z) {# i# y) _ IfInString full_path, \/ Z* [ J; r/ ?. @( Z% b# Q
{1 c# E3 I; N% A1 n3 E3 w
Run, cmd /K cd /D “%full_path%”, y! P! s$ {8 l* d. b }, S% X, x
}
2 w* O; s, Y) L+ W( R+ @ else" H, T3 P4 x) B% l' g, S
{
# v3 z, F- |0 {7 f; D Run, cmd /K cd /D “C:\ ”- S8 X$ [4 ~6 l
}, f$ d. \% H0 D" Z0 y' ?5 Z
}1 n9 Z' M9 ]7 ]; h" q; n$ ~9 S
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& n) U4 }: D9 Y5 [: X O
这段小代码肯能有两个你需要修改的地方
. } V! _) L% f! l 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键 A" q) Y$ I; W- z5 V$ s6 e
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- _$ ?0 [% E/ S, K$ }& c
|