此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 `0 b! W6 u/ j8 ^2 l 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! o7 c5 [/ ]9 e- k5 D% I+ T 方式一:
! ~4 D8 H6 n* E% N 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, [( C" S3 h) [- c$ g/ `; H
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 I0 Z4 a, p# c( s3 I- o HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# t% d6 Y" O9 M3 v" ?+ @
方式二:
& ~/ ^: l% Q* F& K+ O: a9 ^ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. b3 P/ z" D7 ]/ Z% x( `4 b/ {3 g SetTitleMatchMode RegEx
; R) z; e, _8 ]! `" ]. l/ r$ ] return
7 x. w- v8 i" b1 A+ k( C- ] ; Stuff to do when Windows Explorer is open
2 Y1 P) N% Z& e3 o& O ;5 z$ W* k6 r' E2 {% ~
#IfWinActive ahk_class ExploreWClass|CabinetWClass" l! x' L; X# A& l; T1 Y& w
; open ‘cmd’ in the current directory( h! i3 z# j+ i$ R, k# g
;- k( L3 W) }4 O- ]
#c::
, H8 H% w0 F0 Y' t# w# H6 d: D OpenCmdInCurrent()
5 d( V6 B! Z o5 a& h return
0 v- i( Q2 V4 b7 O# s& E" B" R- E #IfWinActive
- P0 V0 x7 O3 q& A7 D ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 O$ Q# Y1 H) a* X5 \6 r# W ; Note: expecting to be run when the active window is Explorer.% e1 t# @$ D' i) R, [
;8 U7 ?, S( R: ?/ ^4 z* l- |( x# f
OpenCmdInCurrent()8 G- s' Q: ~% A' v- i9 s
{
2 R) K4 ] D8 S+ N3 E+ } \ ; This is required to get the full path of the file from the address bar% g8 g$ }' T G
WinGetText, full_path, A
: X, l0 K, O. z4 s3 d ; Split on newline (`n)4 Y( F1 j$ V% s' M# _( z' C: I
StringSplit, word_array, full_path, `n% p! b- W4 h: m
; Take the first element from the array1 C0 x6 r( T8 {
full_path = %word_array1% |$ K3 M2 g$ c& l
; strip to bare address
- t8 r8 d; \3 | | full_path := RegExReplace(full_path, “地址: “, “”)
9 |; o& {' x$ g2 W) p) R ; Just in case – remove all carriage returns (`r)
3 m+ q4 R3 ]# p" i1 K2 v" p7 R StringReplace, full_path, full_path, `r, , all
6 @. R o5 t- t& g" U6 x IfInString full_path, \
* t3 t5 L+ p1 g! u8 F {
, i0 v8 q q' y+ P7 Z Run, cmd /K cd /D “%full_path%”
3 H2 f* b- I9 C4 t! v7 \7 v1 ? }) A6 c5 g, {( |
else
' D6 h: L! M" h% O {
u5 ~* a- K; E Run, cmd /K cd /D “C:\ ”
' B/ _' Z. L9 {: b. _ }
5 [% g) c' T, q6 `! v }: ]3 o2 b$ Y2 j$ s4 a% p# n
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& F4 [% l X, K1 [9 [ 这段小代码肯能有两个你需要修改的地方: O" o: y7 s5 i+ |
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ L+ v' D+ d/ U3 Q8 ]1 `
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 J5 K: b+ U; D, V# j/ L5 m6 i
|