markdown AutoHotkey的脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown AutoHotkey的脚本相关的知识,希望对你有一定的参考价值。

```
;for android
::aalog::
clipboard = Ulog.i("");
send ^v
send {left}{left}{left}
return

::aaid::
clipboard = android:id="@+id/"
send ^v
send {left}
return

::aatag::
clipboard = public static final String TAG = "";
send ^v
return ;

::aalay::  
d = android:layout_width="match_parent"
clipboard = %d%
Send ^v{enter}
e = android:layout_height="wrap_content"
clipboard = %e%
Send ^v
return

```
```
::jj0::
clipboard = ☆☆☆☆☆
send ^v
return
::jj1::
clipboard = ★☆☆☆☆
send ^v
return
::jj2::
clipboard = ★★☆☆☆
send ^v
return
::jj3::
clipboard = ★★★☆☆
send ^v
return
::jj4::
clipboard = ★★★★☆
send ^v
return
::jj5::
clipboard = ★★★★★
send ^v
return
```
```
;控制autohotyey
;挂起所有autohotkey按键
#!p::suspend


#Persistent
#SingleInstance Force
;#NoTrayIcon
#NoEnv
```
通过bat文件来执行指定任务
======================

bat任务文件和快捷键绑定
=====================
```
; 启动指定的bat文件(可以在bat文件中启动其他程序)

#a::run win_a
#c::run win_c
#n::run win_n
#q::run win_q
#g::run win_g
#s::run win_s
#v::run win_v
#w::run win_w
#y::run win_y
;#z::run win_z
#!c::run win_alt_c
; #!s::run win_alt_s
; #!x::run win_alt_x
```

1. 新建文件夹`c:/p/shortcut`;
2. 将路径添加到环境变量: `path=c:/p/shortcut`;
3. 添加`win_a.bat`文件;
4. 在`win_a.bat`文件中,执行多个任务(开机后,按下`win+a`一键开启多个应用);

例如我的win_a.bat文件:
```
@echo off
start ditto
start shadowsocks
start wiz
start qq
start everything
start dict
```
```
+#s::
Sleep, 500
; Power off the screen
SendMessage, 0x112, 0xF170, 2,, Program Manager
Return



#l::
; Lock Screen. 模拟Win+L没有成功,执行后Win似乎一直处于按下状态
Run, %A_WinDir%\System32\rundll32.exe user32.dll LockWorkStation 
Sleep, 500
; Power off the screen
SendMessage, 0x112, 0xF170, 2,, Program Manager
Return
```
```
;切换鼠标左右键
#!q::
run control main.cpl
win_class = #32770
winwait ahk_class %win_class%
WinActivate ahk_class %win_class%
winwaitactive ahk_class %win_class%
if errorlevel = 0
{
  send !s
  sleep 500
  send {enter}
}
return
```
```
;取当前鼠标下的屏幕颜色值
!+F9::
MouseGetPos, mouseX, mouseY
PixelGetColor, color, %mouseX%, %mouseY%, RGB
StringRight color,color,6
clipboard = %color%
tooltip, Color: %clipboard%
sleep 2000
tooltip,
return
```
```
;for chrome
#IfWinActive ahk_class Chrome_WidgetWin_1 
!j::Send ^+{Tab} 
!k::Send ^{Tab} 
!t::Send ^t 
return

;for CabinetWClass
#IfWinActive ahk_class CabinetWClass
!j::Send ^+{Tab} 
!k::Send ^{Tab} 
!t::Send ^t 
return

;for eclipse
#IfWinActive ahk_class SWT_Window0
!j::Send ^{pgup}
!k::Send ^{pgdn}
!r::Send {F12} ;激活编辑窗
!a::send ^+s ;保存所有文件
!q::send ^+w ;关闭所有文件
return

;for emacs
;#IfWinActive emacs  ; if in emacs
+Capslock::Capslock ; make shift+Caps-Lock the Caps Lock toggle
Capslock::Control   ; make Caps Lock the control button
;#IfWinActive        ; end if in emacs

#IfWinActive Vim ; if in Vim
!n::
Send !n
return
;关闭
!w::
Send !w
return
#IfWinActive        ; end if in Vim

```
```
; 移动窗口
;(alt + 鼠标左键:移动窗口;注意,窗口处于最大化的情况下将不可移动)
;(alt + 鼠标右键:调整窗口大小;注意,窗口处于最大化的情况下将不可改变)

SetWinDelay,2
CoordMode,Mouse

!LButton::
If DoubleAlt
{
    MouseGetPos,,,KDE_id
    PostMessage,0x112,0xf020,,,ahk_id %KDE_id%
    DoubleAlt := false
    return
}
MouseGetPos,KDE_X1,KDE_Y1,KDE_id
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win
    return
WinGetPos,KDE_WinX1,KDE_WinY1,,,ahk_id %KDE_id%
WinActivate,ahk_id %KDE_id%
Loop
{
    GetKeyState,KDE_Button,LButton,P ; Break if button has been released.
    If KDE_Button = U
        break
    MouseGetPos,KDE_X2,KDE_Y2 ; Get the current mouse position.
    KDE_X2 -= KDE_X1 ; Obtain an offset from the initial mouse position.
    KDE_Y2 -= KDE_Y1
    KDE_WinX2 := (KDE_WinX1 + KDE_X2) ; Apply this offset to the window position.
    KDE_WinY2 := (KDE_WinY1 + KDE_Y2)
    WinMove,ahk_id %KDE_id%,,%KDE_WinX2%,%KDE_WinY2% ; Move the window to the new position.
}
return

!RButton::
If DoubleAlt
{
    MouseGetPos,,,KDE_id
    ; Toggle between maximized and restored state.
    WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
    If KDE_Win
        WinRestore,ahk_id %KDE_id%
    Else
        WinMaximize,ahk_id %KDE_id%
    DoubleAlt := false
    return
}
; Get the initial mouse position and window id, and
; abort if the window is maximized.
MouseGetPos,KDE_X1,KDE_Y1,KDE_id
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win
    return
; Get the initial window position and size.
WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW,KDE_WinH,ahk_id %KDE_id%
; Define the window region the mouse is currently in.
; The four regions are Up and Left, Up and Right, Down and Left, Down and Right.
If (KDE_X1 < KDE_WinX1 + KDE_WinW / 2)
   KDE_WinLeft := 1
Else
   KDE_WinLeft := -1
If (KDE_Y1 < KDE_WinY1 + KDE_WinH / 2)
   KDE_WinUp := 1
Else
   KDE_WinUp := -1
Loop
{
    GetKeyState,KDE_Button,RButton,P ; Break if button has been released.
    If KDE_Button = U
        break
    MouseGetPos,KDE_X2,KDE_Y2 ; Get the current mouse position.
    ; Get the current window position and size.
    WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW,KDE_WinH,ahk_id %KDE_id%
    KDE_X2 -= KDE_X1 ; Obtain an offset from the initial mouse position.
    KDE_Y2 -= KDE_Y1
    ; Then, act according to the defined region.
    WinMove,ahk_id %KDE_id%,, KDE_WinX1 + (KDE_WinLeft+1)/2*KDE_X2  ; X of resized window
                            , KDE_WinY1 +   (KDE_WinUp+1)/2*KDE_Y2  ; Y of resized window
                            , KDE_WinW  -     KDE_WinLeft  *KDE_X2  ; W of resized window
                            , KDE_WinH  -       KDE_WinUp  *KDE_Y2  ; H of resized window
    KDE_X1 := (KDE_X2 + KDE_X1) ; Reset the initial position for the next iteration.
    KDE_Y1 := (KDE_Y2 + KDE_Y1)
}
return


; "Alt + MButton" may be simpler, but I
; like an extra measure of security for
; an operation like this.
!MButton::
    MouseGetPos,,,KDE_id
    WinClose,ahk_id %KDE_id%
return

; This detects "double-clicks" of the alt key.
~Alt::
DoubleAlt := A_PriorHotKey = "~Alt" AND A_TimeSincePriorHotkey < 400
Sleep 0
KeyWait Alt  ; This prevents the keyboard's auto-repeat feature from interfering.
return
```
```
;搜索功能
;用百度搜索 
#!b:: 
Send ^c 
Run http://www.baidu.com/s?wd=%clipboard% 
return 
;用google搜索 
#!g:: 
Send ^c 
Run http://www.google.com/search?q=%clipboard% 
return 
;用google搜索 
!g:: 
Send ^c 
Run http://www.google.com/search?q=%clipboard% 
return 
```
```
;时间输入
;如:14:19:59
::.tt:: 
d = %A_Hour%:%A_Min%:%A_Sec%
clipboard = %d%  
Send ^v  
return

;如:2016.01.16
::.dd::
d = %A_YYYY%.%A_MM%.%A_DD%
clipboard = %d%  
Send ^v  
return

;如:2016-05-08 17:09:10
::.dta::
d = %A_YYYY%-%A_MM%-%A_DD% %A_Hour%:%A_Min%:%A_Sec%
clipboard = %d%  
Send ^v  
return

::.dt::
d =  [%A_MM%.%A_DD% %A_Hour%:%A_Min%]
clipboard = %d%  
Send ^v  
return
```
```
;替换按键
;新建
!n::
Send ^n
return
;关闭
!w::
Send ^w
return
;粘贴
;+!p::
;Send ^v
;return
;粘贴
!v::
Send ^v
return
;剪切
!x::
Send ^x
return
;复制
!c::
Send ^c
return
;保存
!s::
Send ^s
return
!'::Send {delete} ;删除光标后面的一个字母或汉字
;ThinkPad键盘上的右键:PrintScreen
PrintScreen::Send +{F10}

;enter按键
!Capslock::send {enter}
```
```
;特殊符号
;「
![::
clipboard = 「
send ^v
return

!]::
clipboard = 」
send ^v
return

;★输入
!9::
clipboard = ★
send ^v
return
;·输入
!8::
clipboard = ·
send ^v
return
#!]::
```
前一个标签后一个标签
=================
```
!j::Send ^{pgup}
!k::Send ^{pgdn}
```

前进后退
=======
```
;浏览器及资源管理器中使用
;前进
!=::
send, !{right}
return
;回退
!-::
send, !{left}
return 
```

下一个桌面,上一个桌面(Windows 10)
================================
```
^#a::send ^#{left}
^#s::send ^#{right}
```
```
;;音量控制
;静音
#!0::
Send {Volume_Mute}
Return
;增加音量
#!=::
Send {Volume_Up 1} 
Return
;减少音量
#!-::
Send {Volume_Down 1}
Return
```
方向控制
=======

```
;光标方向控制
!i::Send {up} ;光标上移
!,::Send {down} ;光标下移
#!i::Send {pgup} ;光标翻页上移
#!,::Send {pgdn} ;光标翻页下移
!h::Send {left} ;光标左移
!l::Send {right} ;光标右移
!4::  ;到行末
Send, {end}
return
!0::  ;到行首
Send, {home}
return
```

```
;所有编辑器中的快捷操作
Shift & enter::send {end}{enter} ;下起一行
;+^o::send {home}{enter}{up} ;上起一行
+^!h::send,+^{left} ;选中左移一个单词
+^!l::send,+^{right} ;选中右移一个单词
+!i::send,{shiftdown}{up} ;选中上移
+!,::send,{shiftdown}{down} ;选中下移
+!h::send,{shiftdown}{left} ;选中左移
+!l::send,{shiftdown}{right} ;选中右移
+!4::send,+{end} ;选中当前光标位置到行末
+!0::send,+{home} ;选中当前光标位置到行首
;+^k::send,{end}{shiftdown}{home}{ShiftUp}{backspace}{backspace} ;删除当前行 

;复制当前行到剪切板 
+!v::
send,{home}{shiftdown}{end}{ShiftUp}
Send,^c
Send, {end}
Return 

;复制当前行到剪切板 
+!c::
send,{home}{shiftdown}{end}{ShiftUp}
Send,^c
Send, {end}
Return 

;剪切当前行到剪切板 
+!x::
send,{home}{shiftdown}{end}{ShiftUp}
Send,^x
Send, {backspace}
Return 


;删除光标到行末的内容
+!'::
send,+{end}{delete}
return 
;删除光标到行首的内容
+!;::
send,+{home}{delete}
return 
```

说明
====
```
[!]    等价于按键[Alt]
[+]    等价于按键[Shift]
[#]    等价于按键[Windows]
[^]    等价于按键[Ctrl]
```
```
;输入我的分隔符
::jjl::
d = ====== Lou BEG ======
e = ====== Lou END ======
clipboard = %d%
Send ^v{enter}
clipboard = %e%
Send ^v{up}{enter}
return

::jjs::
d = // --------------------
clipboard = %d%
Send ^v{enter}
e = // ~~~~~~~~~~~~~~~~~~~~
clipboard = %e%
Send ^v{up}{enter}{left}
return

::jjss::
d = // --------------------
clipboard = %d%
Send ^v{enter}
return

::jjse::
e = // ~~~~~~~~~~~~~~~~~~~~
clipboard = %e%
Send ^v{enter}
return

;输入邮箱
::jjm::
clipboard = lyloou@qq.com
Send ^v
return
```
```
#z::
;如果没有打开资源管理器,则新建并激活
IfWinNotExist ahk_class CabinetWClass
{
    Run "explorer.exe"
    WinActivate
}
;如果已经有打开,尚未激活,则激活
Else IfWinNotActive ahk_class CabinetWClass
{
    WinActivate
}
;如果已经激活,则最小化
Else
{
    WinMinimize
}
Return
```
```
;隐藏窗口标题栏
#f11::
WinSet, Style, ^0xC00000, A
WinSet, Style, ^0x40000, A
return
```

以上是关于markdown AutoHotkey的脚本的主要内容,如果未能解决你的问题,请参考以下文章

markdown 我的autohotkey要点

markdown 我的autohotkey要点

开机时自动启动的AutoHotkey脚本

开机时自动启动的AutoHotkey脚本

AutoHotKey 的 Atom 脚本包

求做一个Autohotkey脚本:1.鼠标左键点一下。2.间隔30ms按下数字键3,3.间隔30ms按下数字键1。1~3循环