我的AutoHotKey

作者: 鹿角海棠 | 来源:发表于2014-09-17 10:57 被阅读445次

    在日常的工作中有很多东西其实是在重复性操作。
    懒人就想出了许多懒办法来提高效率。除了学习自己编程之外,其他有些东西还是相对简单一些,例如VBA和AutoHotKey等。
    这里谈谈我的AutoHotKey脚本。
    初步看了下手册,目前的水平仅仅写一些最简单的脚本。如果是稍微高级一些的脚本需要对照类似功能的例子来修改。难点在于类似例子不是很好找,需要时间慢慢加深了解,自己来编写自己需要的脚本。


    • 看文献的时候,选中的文字部分自动通过Organic Chemistry Reference网站定位到数据库。这个脚本不是我写的,是Organic Chemistry Reference网站作者提供的,但是我基于这个范本改造出了自己需要的脚本。特别感谢!
     ; Organic Chemistry Reference Resolver lookup (Win-c)
     ;
     #c::
     ;Copy Clipboard to prevClipboard variable, clear Clipboard.
       prevClipboard := ClipboardAll
       Clipboard =
     ;Copy current selection, continue if no errors.
       SendInput, ^c
       ClipWait, 2
       if !(ErrorLevel) {
     ;Convert Clipboard to text, auto-trim leading and trailing spaces and tabs.
         Clipboard = %Clipboard%
     ;Clean Clipboard: change carriage returns to spaces, change >=1 consecutive spaces to +
         Clipboard := RegExReplace(RegExReplace(Clipboard, "\r?\n"," "), "+")
     ;Search http://chemsearch.kovsky.net/
         Run http://chemsearch.kovsky.net/index.php?q=%Clipboard%
     }
     ;Restore Clipboard, clear prevClipboard variable.
       Clipboard := prevClipboard
       prevClipboard =
     return
    

    • 使用快捷键将选中内容放入google搜索
    ;
    ; Search Google with clipboard (Win-g)
    ;
    #g::
     ;Copy Clipboard to prevClipboard variable, clear Clipboard.
       prevClipboard := ClipboardAll
       Clipboard =
     ;Copy current selection, continue if no errors.
       SendInput, ^c
       ClipWait, 2
       if !(ErrorLevel) {
     ;Convert Clipboard to text, auto-trim leading and trailing spaces and tabs.
         Clipboard = %Clipboard%
     ;Clean Clipboard: change carriage returns to spaces, change >=1 consecutive spaces to +
         Clipboard := RegExReplace(RegExReplace(Clipboard, "\r?\n"," "), "+")
     ;Search https://www.google.com/
         Run https://www.google.com/search?q=%clipboard%
     }
     ;Restore Clipboard, clear prevClipboard variable.
       Clipboard := prevClipboard
       prevClipboard =
    return
    

    • 使用快捷键将选中内容放入google scholar搜索
    ;
    ; Search Google Scholar with clipboard (Win-s)
    ;
    #s::
     ;Copy Clipboard to prevClipboard variable, clear Clipboard.
       prevClipboard := ClipboardAll
       Clipboard =
     ;Copy current selection, continue if no errors.
       SendInput, ^c
       ClipWait, 2
       if !(ErrorLevel) {
     ;Convert Clipboard to text, auto-trim leading and trailing spaces and tabs.
         Clipboard = %Clipboard%
     ;Clean Clipboard: change carriage returns to spaces, change >=1 consecutive spaces to +
         Clipboard := RegExReplace(RegExReplace(Clipboard, "\r?\n"," "), "+")
     ;Search http://scholar.google.com/
         Run http://scholar.google.com/scholar?hl=en&q=%Clipboard%
     }
     ;Restore Clipboard, clear prevClipboard variable.
       Clipboard := prevClipboard
       prevClipboard =
    return
    

    • 在英文环境下,将选中的文本部分转换相应的小写格式
    ;
    ; Convert Selection to Lower Case. (Win-2)
    ;
    #2:: 
    bak = %clipboard% 
    Send, ^c 
    StringLower, clipboard, clipboard 
    Send, ^v 
    clipboard = %bak% 
    return 
    

    • 自己改造的脚本,目前还不是很满意。按下快捷键之后,选中内容被复制,然后窗口切换到Endnote界面。然后我还是需要手动把文本粘贴到搜索窗口,按下回车。
      可以考虑用Pulover’s Macro Creator录制,绝对神器。虽然代码不一定是最优的,更键盘精灵比起来优点在于可以保存为AHK格式。
      update经过调试,加上录制,以下代码可用,赞!
    ;
    ; Check the reference in my Endnote (F3)
    ;
    ; This script was created using Pulover's Macro Creator
    #NoEnv
    SetWorkingDir %A_ScriptDir%
    CoordMode, Mouse, Window
    SendMode Input
    #SingleInstance Force
    SetTitleMatchMode 2
    DetectHiddenWindows On
    #WinActivateForce
    SetControlDelay 1
    SetWinDelay 0
    SetKeyDelay -1
    SetMouseDelay -1
    SetBatchLines -1
    F3::
     ;Copy Clipboard to prevClipboard variable, clear Clipboard.
       prevClipboard := ClipboardAll
       Clipboard =
     ;Copy current selection, continue if no errors.
       SendInput, ^c
       ClipWait, 2
    Macro1:
    WinActivate, EndNote X7 - [XXX.enl] ahk_class EndNote X7 Frame
    Sleep, 2
    Click, 82, 122 Left, Down
    Sleep, 2
    Click, 82, 122 Left, Up
    Sleep, 2
    Click, 761, 66 Left, Down
    Sleep, 2
    Click, 761, 66 Left, Up
    Sleep, 2
    Send, {LControl Down}
    Sleep, 2
    Send, {v Down}
    Sleep, 2
    Send, {LControl Up}{v Up}
    Sleep, 2
    Send, {Enter Down}
    Sleep, 2
    Send, {Enter Up}
    Return
    

    相关文章

      网友评论

        本文标题:我的AutoHotKey

        本文链接:https://www.haomeiwen.com/subject/recutttx.html